-
Notifications
You must be signed in to change notification settings - Fork 272
/
subtraction_test.go
42 lines (29 loc) · 1.13 KB
/
subtraction_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package funk
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSubtract(t *testing.T) {
is := assert.New(t)
r := Subtract([]int{1, 2, 3, 4, 5}, []int{2, 4, 6})
is.Equal([]int{1, 3, 5}, r)
r = Subtract([]string{"foo", "bar", "hello", "bar", "hi"}, []string{"foo", "bar"})
is.Equal([]string{"hello", "hi"}, r)
r = Subtract([]string{"hello", "foo", "bar", "hello", "bar", "hi"}, []string{"foo", "bar"})
is.Equal([]string{"hello", "hello", "hi"}, r)
r = Subtract([]int{1, 2, 3, 4, 5}, []int{})
is.Equal([]int{1, 2, 3, 4, 5}, r)
r = Subtract([]string{"bar", "bar"}, []string{})
is.Equal([]string{"bar", "bar"}, r)
}
func TestSubtractString(t *testing.T) {
is := assert.New(t)
r := SubtractString([]string{"foo", "bar", "hello", "bar"}, []string{"foo", "bar"})
is.Equal([]string{"hello"}, r)
r = SubtractString([]string{"foo", "bar", "hello", "bar", "world", "world"}, []string{"foo", "bar"})
is.Equal([]string{"hello", "world", "world"}, r)
r = SubtractString([]string{"bar", "bar"}, []string{})
is.Equal([]string{"bar", "bar"}, r)
r = SubtractString([]string{}, []string{"bar", "bar"})
is.Equal([]string{}, r)
}