-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathassert_test.go
51 lines (43 loc) · 913 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
package xpath
import (
"reflect"
"testing"
)
func assertEqual(tb testing.TB, v1, v2 interface{}) {
if !reflect.DeepEqual(v1, v2) {
tb.Fatalf("'%+v' and '%+v' are not equal", v1, v2)
}
}
func assertNoErr(tb testing.TB, err error) {
if err != nil {
tb.Fatalf("expected no err, but got: %s", err.Error())
}
}
func assertErr(tb testing.TB, err error) {
if err == nil {
tb.Fatal("expected err, but got nil")
}
}
func assertTrue(tb testing.TB, v bool) {
if !v {
tb.Fatal("expected true, but got false")
}
}
func assertFalse(tb testing.TB, v bool) {
if v {
tb.Fatal("expected false, but got true")
}
}
func assertNil(tb testing.TB, v interface{}) {
if v != nil && !reflect.ValueOf(v).IsNil() {
tb.Fatalf("expected nil, but got: %+v", v)
}
}
func assertPanic(t *testing.T, f func()) {
defer func() {
if r := recover(); r == nil {
t.Errorf("The code did not panic")
}
}()
f()
}