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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
package assert
import (
"git.sr.ht/~eugenetriguba/checkmate"
"git.sr.ht/~eugenetriguba/checkmate/check"
)
// Nil asserts whether the value equals nil.
func Nil(t checkmate.TestingT, value any, msgAndArgs ...any) {
if ht, ok := t.(helperT); ok {
ht.Helper()
}
if passed := check.Nil(t, value, msgAndArgs...); !passed {
t.FailNow()
}
}
// NotNil asserts whether the value does not equal nil.
func NotNil(t checkmate.TestingT, value any, msgAndArgs ...any) {
if ht, ok := t.(helperT); ok {
ht.Helper()
}
if passed := check.NotNil(t, value, msgAndArgs...); !passed {
t.FailNow()
}
}
// True asserts whether the condition is true.
func True(t checkmate.TestingT, condition bool, msgAndArgs ...any) {
if ht, ok := t.(helperT); ok {
ht.Helper()
}
if passed := check.True(t, condition, msgAndArgs...); !passed {
t.FailNow()
}
}
// False asserts whether the condition is false.
func False(t checkmate.TestingT, condition bool, msgAndArgs ...any) {
if ht, ok := t.(helperT); ok {
ht.Helper()
}
if passed := check.False(t, condition, msgAndArgs...); !passed {
t.FailNow()
}
}
// ErrorIs asserts whether the target error occurs within err's error tree.
func ErrorIs(t checkmate.TestingT, err error, target error, msgAndArgs ...any) {
if ht, ok := t.(helperT); ok {
ht.Helper()
}
if passed := check.ErrorIs(t, err, target, msgAndArgs...); !passed {
t.FailNow()
}
}
// NotErrorIs asserts whether the target error does not occur within
// the err's error tree.
func NotErrorIs(t checkmate.TestingT, err error, target error, msgAndArgs ...any) {
if ht, ok := t.(helperT); ok {
ht.Helper()
}
if passed := check.NotErrorIs(t, err, target, msgAndArgs...); !passed {
t.FailNow()
}
}
// ErrorContains asserts whether the given err contains the errText in the err.Error() output.
func ErrorContains(t checkmate.TestingT, err error, errText string, msgAndArgs ...any) {
if ht, ok := t.(helperT); ok {
ht.Helper()
}
if passed := check.ErrorContains(t, err, errText, msgAndArgs...); !passed {
t.FailNow()
}
}
// NotErrorContains asserts whether the given err does not contain the errText
// in the err.Error() output.
func NotErrorContains(t checkmate.TestingT, err error, errText string, msgAndArgs ...any) {
if ht, ok := t.(helperT); ok {
ht.Helper()
}
if passed := check.NotErrorContains(t, err, errText, msgAndArgs...); !passed {
t.FailNow()
}
}
// DeepEqual asserts that two values are deeply equal. If they are not equal,
// it logs the differences.
func DeepEqual(t checkmate.TestingT, actual, expected any, msgAndArgs ...any) {
if ht, ok := t.(helperT); ok {
ht.Helper()
}
if passed := check.DeepEqual(t, actual, expected, msgAndArgs...); !passed {
t.FailNow()
}
}
// NotDeepEqual asserts if two values are not deeply equal.
func NotDeepEqual(t checkmate.TestingT, actual, expected any, msgAndArgs ...any) {
if ht, ok := t.(helperT); ok {
ht.Helper()
}
if passed := check.NotDeepEqual(t, actual, expected, msgAndArgs...); !passed {
t.FailNow()
}
}
// Equal asserts if two primitive values are equal.
func Equal(t checkmate.TestingT, actual, expected any, msgAndArgs ...any) {
if ht, ok := t.(helperT); ok {
ht.Helper()
}
if passed := check.Equal(t, actual, expected, msgAndArgs...); !passed {
t.FailNow()
}
}
// NotEqual asserts if two values are not equal.
func NotEqual(t checkmate.TestingT, actual, expected any, msgAndArgs ...any) {
if ht, ok := t.(helperT); ok {
ht.Helper()
}
if passed := check.NotEqual(t, actual, expected, msgAndArgs...); !passed {
t.FailNow()
}
}
type helperT interface {
Helper()
}
|