-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathassertions.go
44 lines (37 loc) · 848 Bytes
/
assertions.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
package tinydate
import (
"reflect"
"testing"
)
func assertEqual(t *testing.T, object1, object2 interface{}) {
if !reflect.DeepEqual(object1, object2) {
t.Helper()
t.Errorf("expected %v and %v to be equal, but they are not equal", object1, object2)
}
}
func assertNil(t *testing.T, object interface{}) {
if !isNil(object) {
t.Helper()
t.Errorf("expected %v to be nil, but wasn't nil", object)
}
}
func assertNotNil(t *testing.T, object interface{}) {
if isNil(object) {
t.Helper()
t.Errorf("expected %v not to be nil, but was nil", object)
}
}
func assertTrue(t *testing.T, b bool) {
t.Helper()
assertEqual(t, b, true)
}
func assertFalse(t *testing.T, b bool) {
t.Helper()
assertEqual(t, b, false)
}
func isNil(object interface{}) bool {
if object == nil {
return true
}
return reflect.ValueOf(object).IsNil()
}