-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_utils.go
55 lines (48 loc) · 1.11 KB
/
test_utils.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
// Copyright (c) 2014, Jan Voung
// All rights reserved.
// More methods for testing.
package main
import (
"runtime"
"testing"
)
func ExpectEq(t *testing.T, v1, v2 interface{}) {
if v1 != v2 {
_, file, line, ok := runtime.Caller(1)
if ok {
t.Errorf("(%s:%d) Expected %v == %v", file, line, v1, v2)
} else {
t.Errorf("Expected %v == %v", v1, v2)
}
}
}
func ExpectEqM(t *testing.T, v1, v2 interface{}, s string) {
if v1 != v2 {
_, file, line, ok := runtime.Caller(1)
if ok {
t.Errorf("%s (%s:%d) Expected %v == %v", s, file, line, v1, v2)
} else {
t.Errorf("%s Expected %v == %v", s, v1, v2)
}
}
}
func AssertEq(t *testing.T, v1, v2 interface{}) {
if v1 != v2 {
_, file, line, ok := runtime.Caller(1)
if ok {
t.Fatalf("(%s:%d) Expected %v == %v", file, line, v1, v2)
} else {
t.Fatalf("Expected %v == %v", v1, v2)
}
}
}
func AssertEqM(t *testing.T, v1, v2 interface{}, s string) {
if v1 != v2 {
_, file, line, ok := runtime.Caller(1)
if ok {
t.Fatalf("%s (%s:%d) Expected %v == %v", s, file, line, v1, v2)
} else {
t.Fatalf("%s Expected %v == %v", s, v1, v2)
}
}
}