Debian Codegraph @

assert_test.go

raw
1 package xpath
2
3 import (
4 "reflect"
5 "testing"
6 )
7
8 func assertEqual(tb testing.TB, v1, v2 interface{}) {
9 if !reflect.DeepEqual(v1, v2) {
10 tb.Fatalf("'%+v' and '%+v' are not equal", v1, v2)
11 }
12 }
13
14 func assertNoErr(tb testing.TB, err error) {
15 if err != nil {
16 tb.Fatalf("expected no err, but got: %s", err.Error())
17 }
18 }
19
20 func assertErr(tb testing.TB, err error) {
21 if err == nil {
22 tb.Fatal("expected err, but got nil")
23 }
24 }
25
26 func assertTrue(tb testing.TB, v bool) {
27 if !v {
28 tb.Fatal("expected true, but got false")
29 }
30 }
31
32 func assertFalse(tb testing.TB, v bool) {
33 if v {
34 tb.Fatal("expected false, but got true")
35 }
36 }
37
38 func assertNil(tb testing.TB, v interface{}) {
39 if v != nil && !reflect.ValueOf(v).IsNil() {
40 tb.Fatalf("expected nil, but got: %+v", v)
41 }
42 }
43
44 func assertPanic(t *testing.T, f func()) {
45 defer func() {
46 if r := recover(); r == nil {
47 t.Errorf("The code did not panic")
48 }
49 }()
50 f()
51 }