-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
assert.go
49 lines (40 loc) · 1.1 KB
/
assert.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
47
48
49
package testes
import "reflect"
func AssertLessThan[T Ordered](got, want T) bool {
return got < want
}
func AssertGreaterThan[T Ordered](got, want T) bool {
return got > want
}
func AssertContains[T comparable, E ~[]T](needle T, haystack E) bool {
for _, v := range haystack {
if v == needle {
return true
}
}
return false
}
func AssertNotContains[T comparable, E ~[]T](needle T, haystack E) bool {
for _, v := range haystack {
if v == needle {
return false
}
}
return true
}
func AssertEqual[T comparable](got, want T) bool {
return got == want
// t.Errorf("AssertEqual: %v(%v) = %v, want %v", name, arg, got, want)
}
func AssertNotEqual[T comparable](got, want T) bool {
return got != want
// t.Errorf("AssertEqual: %v(%v) = %v, want %v", name, arg, got, want)
}
func AssertDeepEqual[T any](got, want T) bool {
return reflect.DeepEqual(got, want)
// t.Errorf("AssertDeepEqual: %v(%v) = %v, want %v", name, arg, got, want)
}
func AssertNotDeepEqual[T any](got, want T) bool {
return !reflect.DeepEqual(got, want)
// t.Errorf("AssertDeepEqual: %v(%v) = %v, want %v", name, arg, got, want)
}