-
Notifications
You must be signed in to change notification settings - Fork 25
/
assert_test.go
55 lines (44 loc) · 939 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
// Copyright 2018 The go-bindata Authors. All rights reserved.
// Use of this source code is governed by a CC0 1.0 Universal (CC0 1.0)
// Public Domain Dedication license that can be found in the LICENSE file.
package bindata
import (
"log"
"os"
"reflect"
"runtime"
"testing"
)
// nolint: gochecknoglobals
var (
_traces = make([]byte, 1024)
lerr = log.New(os.Stderr, "", 0)
)
func printStack() {
var lines, start, end int
runtime.Stack(_traces, false)
for x, b := range _traces {
if b != '\n' {
continue
}
lines++
if lines == 5 {
start = x + 1
} else if lines == 7 {
end = x + 1
break
}
}
lerr.Println("!!! ERR " + string(_traces[start:end]))
}
// nolint: unparam
func assert(t *testing.T, exp, got interface{}, equal bool) {
if reflect.DeepEqual(exp, got) == equal {
return
}
printStack()
t.Fatalf("\n"+
">>> Expecting '%+v'\n"+
" got '%+v'\n", exp, got)
os.Exit(1)
}