-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsome_test.go
36 lines (27 loc) · 825 Bytes
/
some_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
package js_array_method
import "testing"
func TestSomeWithoutCallback(t *testing.T) {
resultFalse := Some([]string{"hey", "hi"}, "hello")
if resultFalse == true {
t.Errorf("Expected %s received %s", "false", "true")
}
resultTrue := Some([]string{"hi", "hello", "hiya"}, "hi")
if resultTrue == false {
t.Errorf("Expected %s received %s", "true", "false")
}
}
func TestSomeWithCallback(t *testing.T) {
users := []User{{Id: 12, Name: "Go"}, {Id: 14, Name: "Lang"}}
resultFalse := Some(users, func(user User, _ int) bool {
return user.Id == 15
})
if resultFalse == true {
t.Errorf("Expected %s received %s", "false", "true")
}
resultTrue := Some(users, func(user User, _ int) bool {
return user.Name == "Go"
})
if resultTrue == false {
t.Errorf("Expected %s received %s", "true", "false")
}
}