-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinclude_test.go
More file actions
31 lines (22 loc) · 779 Bytes
/
include_test.go
File metadata and controls
31 lines (22 loc) · 779 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
package js_array_method
import (
"testing"
)
func TestIncludeWithoutCallback(t *testing.T) {
languages := []string{"go", "PHP", "MySql", "TypeScript"}
if !Includes(languages, "TypeScript") {
t.Errorf("Expected %s received %s", "true", "false")
}
if Includes(languages, "Hack") {
t.Errorf("Expected %s received %s", "false", "true")
}
}
func TestIncludeWithCallback(t *testing.T) {
languages := []User{{Id: 12, Name: "Go"}, {Id: 14, Name: "Lang"}, {Id: 15, Name: "Typescript"}}
if !Includes(languages, func(ln User, _ int) bool { return ln.Name == "Go" }) {
t.Errorf("Expected %s received %s", "true", "false")
}
if Includes(languages, func(ln User, _ int) bool { return ln.Name == "MySql" }) {
t.Errorf("Expected %s received %s", "false", "true")
}
}