-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.go
40 lines (36 loc) · 839 Bytes
/
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
package helpers
import (
"strings"
"testing"
)
func TestExpect(t *testing.T, e1 interface{}, e2 interface{}, msg string) {
if e1 != e2 {
errorMsg := "Expected '%v' to be '%v'"
if msg != "" {
errorMsg = "%s -> " + errorMsg
} else {
errorMsg = "%s" + errorMsg
}
t.Errorf(errorMsg, msg, e1, e2)
}
}
func TestStringContains(t *testing.T, s, substring, msg string) {
if !strings.Contains(s, substring) {
errorMsg := "Expected '%s' to contain '%s'"
if msg != "" {
errorMsg = "%s -> " + errorMsg
} else {
errorMsg = "%s" + errorMsg
}
t.Errorf(errorMsg, msg, s, substring)
}
}
func TestExpectArrEq(t *testing.T, e1, e2 []string, msg string) {
if !ArraysEqual(e1, e2) {
errorMsg := "Expected '%v' to be '%v'"
if msg != "" {
errorMsg = "%s -> " + errorMsg
}
t.Errorf(errorMsg, msg, e1, e2)
}
}