-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools_test.go
52 lines (44 loc) · 1.05 KB
/
tools_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
package diskqueue
import (
"path/filepath"
"reflect"
"runtime"
"testing"
)
func assert(t *testing.T, condition bool, msg string, v ...interface{}) {
if !condition {
_, file, line, _ := runtime.Caller(1)
t.Logf("\033[31m%s:%d: "+msg+"\033[39m\n\n",
append([]interface{}{filepath.Base(file), line}, v...)...)
t.FailNow()
}
}
func equal(t *testing.T, act, exp interface{}) {
if !reflect.DeepEqual(exp, act) {
_, file, line, _ := runtime.Caller(1)
t.Logf("\033[31m%s:%d:\n\n\texp: %#v\n\n\tgot: %#v\033[39m\n\n",
filepath.Base(file), line, exp, act)
t.FailNow()
}
}
func nequal(t *testing.T, act, exp interface{}) {
if reflect.DeepEqual(exp, act) {
_, file, line, _ := runtime.Caller(1)
t.Logf("\033[31m%s:%d:\n\n\tnexp: %#v\n\n\tgot: %#v\033[39m\n\n",
filepath.Base(file), line, exp, act)
t.FailNow()
}
}
type tbLog interface {
Log(...interface{})
}
type testLogger struct {
tbLog
}
func (tl *testLogger) Output(maxdepth int, s string) error {
tl.Log(s)
return nil
}
func newTestLogger(tbl tbLog) logger {
return &testLogger{tbl}
}