-
Notifications
You must be signed in to change notification settings - Fork 0
/
boat_test.go
75 lines (65 loc) · 1.33 KB
/
boat_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package boat
import (
"testing"
)
func TestHead(t *testing.T) {
if *Head([]string{"foo", "bar"}) != "foo" {
t.Fail()
}
}
func TestTail(t *testing.T) {
result := Tail([]string{"foo", "bar", "baz"})
if len(result) != 2 {
t.Fail()
}
if result[0] != "bar" || result[1] != "baz" {
t.Fail()
}
result = Tail([]string{})
if len(result) != 0 {
t.Fail()
}
}
func TestLast(t *testing.T) {
if *Last([]string{"foo", "bar"}) != "bar" {
t.Fail()
}
}
func TestReverse(t *testing.T) {
reversed := Reverse([]string{"foo", "bar", "baz"})
if reversed[0] != "baz" {
t.Fail()
}
if reversed[1] != "bar" {
t.Fail()
}
if reversed[2] != "foo" {
t.Fail()
}
}
func TestIncludes(t *testing.T) {
if !Includes([]string{"foo", "bar"}, "foo") {
t.Fail()
}
if Includes([]string{"foo", "bar"}, "baz") {
t.Fail()
}
}
func TestUniq(t *testing.T) {
result := Uniq([]string{"foo", "bar", "foo"})
if len(result) != 2 {
t.Fail()
}
}
func TestKeys(t *testing.T) {
keys := Keys(map[string]int{"foo": 1, "bar": 2, "baz": 3})
if len(keys) != 3 || !Includes(keys, "foo") || !Includes(keys, "bar") || !Includes(keys, "baz") {
t.Fail()
}
}
func TestValues(t *testing.T) {
values := Values(map[string]int{"foo": 1, "bar": 2, "baz": 3})
if len(values) != 3 || !Includes(values, 1) || !Includes(values, 2) || !Includes(values, 3) {
t.Fail()
}
}