forked from markcheno/go-quote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquote_test.go
38 lines (33 loc) · 925 Bytes
/
quote_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
package quote
import (
"fmt"
"path/filepath"
"reflect"
"runtime"
"testing"
)
// assert fails the test if the condition is false.
func assert(t *testing.T, condition bool, msg string, v ...interface{}) {
if !condition {
_, file, line, _ := runtime.Caller(1)
fmt.Printf("%s:%d: "+msg+"\n", append([]interface{}{filepath.Base(file), line}, v...)...)
t.FailNow()
}
}
// ok fails the test if an err is not nil.
func ok(t *testing.T, err error) {
if err != nil {
_, file, line, _ := runtime.Caller(1)
fmt.Printf("%s:%d: unexpected error: %s\n", filepath.Base(file), line, err.Error())
t.FailNow()
}
}
// equals fails the test if exp is not equal to act.
func equals(t *testing.T, exp, act interface{}) {
if !reflect.DeepEqual(exp, act) {
_, file, line, _ := runtime.Caller(1)
fmt.Printf("%s:%d:\n\texp: %#v\n\tgot: %#v\n", filepath.Base(file), line, exp, act)
t.FailNow()
}
}
// TODO - everything