@@ -9,10 +9,11 @@ import (
9
9
// DeepEqual tests the deep equality between actual and expect parameters. It'll set the result to
10
10
// fail if they are not deeply equal, and it doesn't stop the execution.
11
11
//
12
- // assertion.DeepEqual(1, 1) // success
13
- // assertion.DeepEqual("ABC", "ABC") // success
14
- // assertion.DeepEqual(1, 0) // fail
15
- // assertion.DeepEqual(1, int64(1)) // fail
12
+ // a := assert.New(t)
13
+ // a.DeepEqual(1, 1) // success
14
+ // a.DeepEqual("ABC", "ABC") // success
15
+ // a.DeepEqual(1, 0) // fail
16
+ // a.DeepEqual(1, int64(1)) // fail
16
17
func (a * Assertion ) DeepEqual (actual , expect any , message ... any ) error {
17
18
a .Helper ()
18
19
@@ -22,9 +23,10 @@ func (a *Assertion) DeepEqual(actual, expect any, message ...any) error {
22
23
// DeepEqualNow tests the deep equality between actual and expect parameters, and it'll stop the
23
24
// execution if they are not deeply equal.
24
25
//
25
- // assertion.DeepEqualNow(1, 1) // success
26
- // assertion.DeepEqualNow("ABC", "ABC") // success
27
- // assertion.DeepEqualNow(1, int64(1)) // fail and terminate
26
+ // a := assert.New(t)
27
+ // a.DeepEqualNow(1, 1) // success
28
+ // a.DeepEqualNow("ABC", "ABC") // success
29
+ // a.DeepEqualNow(1, int64(1)) // fail and terminate
28
30
// // never run
29
31
func (a * Assertion ) DeepEqualNow (actual , expect any , message ... any ) error {
30
32
a .Helper ()
@@ -35,10 +37,11 @@ func (a *Assertion) DeepEqualNow(actual, expect any, message ...any) error {
35
37
// NotDeepEqual tests the deep inequality between actual and expected parameters. It'll set the
36
38
// result to fail if they are deeply equal, but it doesn't stop the execution.
37
39
//
38
- // assertion.NotDeepEqual(1, 0) // success
39
- // assertion.NotDeepEqual(1, int64(1)) // success
40
- // assertion.NotDeepEqual(1, 1) // fail
41
- // assertion.NotDeepEqual("ABC", "ABC") // fail
40
+ // a := assert.New(t)
41
+ // a.NotDeepEqual(1, 0) // success
42
+ // a.NotDeepEqual(1, int64(1)) // success
43
+ // a.NotDeepEqual(1, 1) // fail
44
+ // a.NotDeepEqual("ABC", "ABC") // fail
42
45
func (a * Assertion ) NotDeepEqual (actual , expect any , message ... any ) error {
43
46
a .Helper ()
44
47
@@ -48,9 +51,10 @@ func (a *Assertion) NotDeepEqual(actual, expect any, message ...any) error {
48
51
// NotDeepEqualNow tests the deep inequality between actual and expected parameters, and it'll stop
49
52
// the execution if they are deeply equal.
50
53
//
51
- // assertion.NotDeepEqual1, 0) // success
52
- // assertion.NotDeepEqual1, int64(1)) // success
53
- // assertion.NotDeepEqual"ABC", "ABC") // fail and terminate
54
+ // a := assert.New(t)
55
+ // a.NotDeepEqual1, 0) // success
56
+ // a.NotDeepEqual1, int64(1)) // success
57
+ // a.NotDeepEqual"ABC", "ABC") // fail and terminate
54
58
// // never run
55
59
func (a * Assertion ) NotDeepEqualNow (actual , expect any , message ... any ) error {
56
60
a .Helper ()
@@ -89,11 +93,12 @@ func tryNotDeepEqual(t *testing.T, failedNow bool, actual, expect any, message .
89
93
// Equal tests the equality between actual and expect parameters. It'll set the result to fail if
90
94
// they are not equal, and it doesn't stop the execution.
91
95
//
92
- // assertion.Equal(1, 1) // success
93
- // assertion.Equal("ABC", "ABC") // success
94
- // assertion.Equal(1, int64(1)) // success
95
- // assertion.Equal(1, uint64(1)) // fail
96
- // assertion.Equal(1, 0) // fail
96
+ // a := assert.New(t)
97
+ // a.Equal(1, 1) // success
98
+ // a.Equal("ABC", "ABC") // success
99
+ // a.Equal(1, int64(1)) // success
100
+ // a.Equal(1, uint64(1)) // fail
101
+ // a.Equal(1, 0) // fail
97
102
func (a * Assertion ) Equal (actual , expect any , message ... any ) error {
98
103
a .Helper ()
99
104
@@ -103,10 +108,11 @@ func (a *Assertion) Equal(actual, expect any, message ...any) error {
103
108
// EqualNow tests the equality between actual and expect parameters, and it'll stop the execution
104
109
// if they are not equal.
105
110
//
106
- // assertion.EqualNow(1, 1) // success
107
- // assertion.EqualNow("ABC", "ABC") // success
108
- // assertion.EqualNow(1, int64(1)) // success
109
- // assertion.EqualNow(1, 0) // fail and terminate
111
+ // a := assert.New(t)
112
+ // a.EqualNow(1, 1) // success
113
+ // a.EqualNow("ABC", "ABC") // success
114
+ // a.EqualNow(1, int64(1)) // success
115
+ // a.EqualNow(1, 0) // fail and terminate
110
116
// never run
111
117
func (a * Assertion ) EqualNow (actual , expect any , message ... any ) error {
112
118
a .Helper ()
@@ -117,12 +123,13 @@ func (a *Assertion) EqualNow(actual, expect any, message ...any) error {
117
123
// NotEqual tests the inequality between actual and expected parameters. It'll set the result to
118
124
// fail if they are equal, but it doesn't stop the execution.
119
125
//
120
- // assertion.NotEqual(1, 0) // success
121
- // assertion.NotEqual("ABC", "CBA") // success
122
- // assertion.NotEqual(1, uint64(1)) // success
123
- // assertion.NotEqual(1, 1) // fail
124
- // assertion.NotEqual("ABC", "ABC") // fail
125
- // assertion.NotEqual(1, int64(1)) // fail
126
+ // a := assert.New(t)
127
+ // a.NotEqual(1, 0) // success
128
+ // a.NotEqual("ABC", "CBA") // success
129
+ // a.NotEqual(1, uint64(1)) // success
130
+ // a.NotEqual(1, 1) // fail
131
+ // a.NotEqual("ABC", "ABC") // fail
132
+ // a.NotEqual(1, int64(1)) // fail
126
133
func (a * Assertion ) NotEqual (actual , expect any , message ... any ) error {
127
134
a .Helper ()
128
135
@@ -132,9 +139,10 @@ func (a *Assertion) NotEqual(actual, expect any, message ...any) error {
132
139
// NotEqualNow tests the inequality between actual and expected parameters, and it'll stop the
133
140
// execution if they are equal.
134
141
//
135
- // assertion.NotEqualNow(1, 0) // success
136
- // assertion.NotEqualNow("ABC", "CBA") // success
137
- // assertion.NotEqualNow(1, 1) // fail and terminate
142
+ // a := assert.New(t)
143
+ // a.NotEqualNow(1, 0) // success
144
+ // a.NotEqualNow("ABC", "CBA") // success
145
+ // a.NotEqualNow(1, 1) // fail and terminate
138
146
// // never run
139
147
func (a * Assertion ) NotEqualNow (actual , expect any , message ... any ) error {
140
148
a .Helper ()
@@ -174,11 +182,12 @@ func tryNotEqual(t *testing.T, failedNow bool, actual, expect any, message ...an
174
182
// always return false if the value is a bool, an integer, a floating number, a complex, or a
175
183
// string.
176
184
//
185
+ // a := assert.New(t)
177
186
// var err error // nil
178
- // assertion .Nil(err) // success
187
+ // a .Nil(err) // success
179
188
//
180
189
// err = errors.New("some error")
181
- // assertion .Nil(err) // fail
190
+ // a .Nil(err) // fail
182
191
func (a * Assertion ) Nil (val any , message ... any ) error {
183
192
a .Helper ()
184
193
@@ -191,11 +200,12 @@ func (a *Assertion) Nil(val any, message ...any) error {
191
200
//
192
201
// This function will set the result to fail, and stop the execution if the value is not nil.
193
202
//
203
+ // a := assert.New(t)
194
204
// var err error // nil
195
- // assertion .NilNow(err) // success
205
+ // a .NilNow(err) // success
196
206
//
197
207
// err = errors.New("some error")
198
- // assertion .NilNow(err) // fail and terminate
208
+ // a .NilNow(err) // fail and terminate
199
209
// // never run
200
210
func (a * Assertion ) NilNow (val any , message ... any ) error {
201
211
a .Helper ()
@@ -207,11 +217,12 @@ func (a *Assertion) NilNow(val any, message ...any) error {
207
217
// always return true if the value is a bool, an integer, a floating number, a complex, or a
208
218
// string.
209
219
//
220
+ // a := assert.New(t)
210
221
// var err error // nil
211
- // assertion .NotNil(err) // fail
222
+ // a .NotNil(err) // fail
212
223
//
213
224
// err = errors.New("some error")
214
- // assertion .NotNil(err) // success
225
+ // a .NotNil(err) // success
215
226
func (a * Assertion ) NotNil (val any , message ... any ) error {
216
227
a .Helper ()
217
228
@@ -224,11 +235,12 @@ func (a *Assertion) NotNil(val any, message ...any) error {
224
235
//
225
236
// This function will set the result to fail, and stop the execution if the value is nil.
226
237
//
238
+ // a := assert.New(t)
227
239
// var err error = errors.New("some error")
228
- // assertion .NotNilNow(err) // success
240
+ // a .NotNilNow(err) // success
229
241
//
230
242
// err = nil
231
- // assertion .NotNilNow(err) // fail and terminate
243
+ // a .NotNilNow(err) // fail and terminate
232
244
// // never run
233
245
func (a * Assertion ) NotNilNow (val any , message ... any ) error {
234
246
a .Helper ()
@@ -267,10 +279,11 @@ func tryNotNil(t *testing.T, failedNow bool, val any, message ...any) error {
267
279
// slice, a truthy value should not be nil, and its length must be greater than 0. For nil, the
268
280
// value is always falsy.
269
281
//
270
- // assertion.True(1) // success
271
- // assertion.True("test") // success
272
- // assertion.True(0) // fail
273
- // assertion.True("") // fail
282
+ // a := assert.New(t)
283
+ // a.True(1) // success
284
+ // a.True("test") // success
285
+ // a.True(0) // fail
286
+ // a.True("") // fail
274
287
func (a * Assertion ) True (val any , message ... any ) error {
275
288
a .Helper ()
276
289
@@ -284,9 +297,10 @@ func (a *Assertion) True(val any, message ...any) error {
284
297
//
285
298
// The function will stop the execution if the value is falsy.
286
299
//
287
- // assertion.TrueNow(1) // success
288
- // assertion.TrueNow("test") // success
289
- // assertion.TrueNow("") // fail and terminate
300
+ // a := assert.New(t)
301
+ // a.TrueNow(1) // success
302
+ // a.TrueNow("test") // success
303
+ // a.TrueNow("") // fail and terminate
290
304
// // never run
291
305
func (a * Assertion ) TrueNow (val any , message ... any ) error {
292
306
a .Helper ()
@@ -299,10 +313,11 @@ func (a *Assertion) TrueNow(val any, message ...any) error {
299
313
// slice, a truthy value should not be nil, and its length must be greater than 0. For nil, the
300
314
// value is always falsy.
301
315
//
302
- // assertion.NotTrue(0) // success
303
- // assertion.NotTrue("") // success
304
- // assertion.NotTrue(1) // fail
305
- // assertion.NotTrue("test") // fail
316
+ // a := assert.New(t)
317
+ // a.NotTrue(0) // success
318
+ // a.NotTrue("") // success
319
+ // a.NotTrue(1) // fail
320
+ // a.NotTrue("test") // fail
306
321
func (a * Assertion ) NotTrue (val any , message ... any ) error {
307
322
a .Helper ()
308
323
@@ -316,9 +331,10 @@ func (a *Assertion) NotTrue(val any, message ...any) error {
316
331
//
317
332
// The function will stop the execution if the value is truthy.
318
333
//
319
- // assertion.NotTrueNow(0) // success
320
- // assertion.NotTrueNow("") // success
321
- // assertion.NotTrueNow("test") // fail and terminate
334
+ // a := assert.New(t)
335
+ // a.NotTrueNow(0) // success
336
+ // a.NotTrueNow("") // success
337
+ // a.NotTrueNow("test") // fail and terminate
322
338
// // never run
323
339
func (a * Assertion ) NotTrueNow (val any , message ... any ) error {
324
340
a .Helper ()
0 commit comments