-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_helpers.go
46 lines (39 loc) · 972 Bytes
/
test_helpers.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
package projecteuler
import "testing"
func AssertInt(got int, expected int, t *testing.T) {
if got != expected {
t.Errorf("Expected %v, got %v", expected, got)
}
}
func AssertInt64(got int64, expected int64, t *testing.T) {
if got != expected {
t.Errorf("Expected %v, got %v", expected, got)
}
}
func AssertTrue(got bool, t *testing.T) {
if got != true {
t.Errorf("Expected true, got false")
}
}
func AssertFalse(got bool, t *testing.T) {
if got != false {
t.Errorf("Expected false, got true")
}
}
func AssertIntArray(got []int, expected []int, t *testing.T) {
if len(got) != len(expected) {
t.Errorf("Expected len %v, got len %v", len(expected), len(got))
} else {
for i := range got {
if got[i] != expected[i] {
t.Errorf("Expected idx %v to be %v, got %v", i, expected[i], got[i])
break
}
}
}
}
func AssertString(got string, expected string, t *testing.T) {
if got != expected {
t.Errorf("Expected false, got true")
}
}