Skip to content

Commit 40a1665

Browse files
committed
README
1 parent 46bd2c0 commit 40a1665

File tree

2 files changed

+15
-38
lines changed

2 files changed

+15
-38
lines changed

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,33 @@ import (
1111
"fmt"
1212
"path/filepath"
1313
"runtime"
14+
"reflect"
1415
"testing"
1516
)
1617

18+
// assert fails the test if the condition is false.
1719
func assert(tb testing.TB, condition bool, msg string, v ...interface{}) {
1820
if !condition {
1921
_, file, line, _ := runtime.Caller(1)
20-
v = append([]interface{}{filepath.Base(file), line}, v...)
21-
fmt.Printf("%s:%d: "+msg+"\n", v...)
22+
fmt.Printf("\033[31m%s:%d: "+msg+"\033[39m\n\n", append([]interface{}{filepath.Base(file), line}, v...)...)
2223
tb.FailNow()
2324
}
2425
}
2526

27+
// ok fails the test if an err is not nil.
28+
func ok(tb testing.TB, err error) {
29+
if err != nil {
30+
_, file, line, _ := runtime.Caller(1)
31+
fmt.Printf("\033[31m%s:%d: unexpected error: %s\033[39m\n\n", filepath.Base(file), line, err.Error())
32+
tb.FailNow()
33+
}
34+
}
35+
36+
// equals fails the test if exp is not equal to act.
2637
func equals(tb testing.TB, exp, act interface{}) {
27-
if exp != act {
38+
if !reflect.DeepEqual(exp, act) {
2839
_, file, line, _ := runtime.Caller(1)
29-
fmt.Printf("%s:%d: exp: %#v, got: %#v\n", filepath.Base(file), line, exp, act)
40+
fmt.Printf("\033[31m%s:%d:\n\n\texp: %#v\n\n\tgot: %#v\033[39m\n\n", filepath.Base(file), line, exp, act)
3041
tb.FailNow()
3142
}
3243
}

doc.go

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)