-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
assert_test.go
68 lines (50 loc) · 1012 Bytes
/
assert_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
package lungo
import (
"fmt"
"testing"
)
func TestAssertNil(t *testing.T) {
assertNil(t, nil)
i := (*any)(nil)
assertNil(t, i)
var s []int
assertNil(t, s)
var m map[int]int
assertNil(t, m)
var f func()
assertNil(t, f)
}
func TestAssertNotNil(t *testing.T) {
assertNotNil(t, 1)
assertNotNil(t, "1")
i := struct{ foo string }{foo: "bar"}
assertNotNil(t, i)
s := []int{1}
assertNotNil(t, s)
m := map[int]int{1: 2}
assertNotNil(t, m)
f := func() { fmt.Println("Foo") }
assertNotNil(t, f)
}
func TestAssertEqualNil(t *testing.T) {
assertEqual(t, nil, nil)
i := (*any)(nil)
assertEqual(t, i, i)
var s []int
assertEqual(t, s, s)
var m map[int]int
assertEqual(t, m, m)
var f func()
assertEqual(t, f, f)
}
func TestAssertEqual(t *testing.T) {
assertEqual(t, "a", "a")
assertEqual(t, 1, 1)
assertEqual(t, []int{0}, []int{0})
assertEqual(t, map[int]int{0: 1}, map[int]int{0: 1})
}
func TestAssertPanic(t *testing.T) {
assertPanic(t, "Foo", func() {
panic("Foo")
})
}