-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevery_test.go
More file actions
38 lines (29 loc) · 826 Bytes
/
every_test.go
File metadata and controls
38 lines (29 loc) · 826 Bytes
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
package js_array_method
import (
"testing"
)
func TestEveryWithoutCallback(t *testing.T) {
resultFalse := Every([]string{"hey", "hi"}, "hi")
if resultFalse == true {
t.Errorf("Expected %s received %s", "false", "true")
}
resultTrue := Every([]string{"hi", "hi", "hi"}, "hi")
if resultTrue == false {
t.Errorf("Expected %s received %s", "true", "false")
}
}
func TestEveryWithCallback(t *testing.T) {
users := []User{{Id: 12, Name: "Go"}, {Id: 14, Name: "Go"}}
resultFalse := Every(users, func(user User, _ int) bool {
return user.Id == 12
})
if resultFalse == true {
t.Errorf("Expected %s received %s", "false", "true")
}
resultTrue := Every(users, func(user User, _ int) bool {
return user.Name == "Go"
})
if resultTrue == false {
t.Errorf("Expected %s received %s", "true", "false")
}
}