@@ -157,16 +157,16 @@ func testNil(t *testing.T, assertion *Assertion, v any, isNil bool) {
157157func testNotNil (t * testing.T , assertion * Assertion , v any , isNil bool ) {
158158 err := assertion .NotNil (v )
159159 if isNil && err == nil {
160- t .Errorf ("Nil (%v) = nil, want error" , v )
160+ t .Errorf ("NotNil (%v) = nil, want error" , v )
161161 } else if ! isNil && err != nil {
162- t .Errorf ("Nil (%v) = %v, want nil" , v , err )
162+ t .Errorf ("NotNil (%v) = %v, want nil" , v , err )
163163 }
164164
165165 err = NotNil (assertion .T , v )
166166 if isNil && err == nil {
167- t .Errorf ("Nil (%v) = nil, want error" , v )
167+ t .Errorf ("NotNil (%v) = nil, want error" , v )
168168 } else if ! isNil && err != nil {
169- t .Errorf ("Nil (%v) = %v, want nil" , v , err )
169+ t .Errorf ("NotNil (%v) = %v, want nil" , v , err )
170170 }
171171}
172172
@@ -209,3 +209,101 @@ func testNotNilNow(t *testing.T, assertion *Assertion, v any, isNil bool) {
209209 t .Error ("execution do not stopped, want stop" )
210210 }
211211}
212+
213+ func TestTrueAndNotTrue (t * testing.T ) {
214+ mockT := new (testing.T )
215+ assert := New (mockT )
216+
217+ testTrueAndNotTrue (t , assert , nil , false )
218+ testTrueAndNotTrue (t , assert , []int {}, false )
219+ testTrueAndNotTrue (t , assert , []int {0 }, true )
220+ testTrueAndNotTrue (t , assert , 0 , false )
221+ testTrueAndNotTrue (t , assert , 1 , true )
222+ testTrueAndNotTrue (t , assert , 0.0 , false )
223+ testTrueAndNotTrue (t , assert , 1.0 , true )
224+ testTrueAndNotTrue (t , assert , "" , false )
225+ testTrueAndNotTrue (t , assert , "test" , true )
226+ testTrueAndNotTrue (t , assert , func () {}, true )
227+ }
228+
229+ func testTrueAndNotTrue (t * testing.T , assertion * Assertion , v any , isTruthy bool ) {
230+ testTrue (t , assertion , v , isTruthy )
231+
232+ testNotTrue (t , assertion , v , isTruthy )
233+
234+ testTrueNow (t , assertion , v , isTruthy )
235+
236+ testNotTrueNow (t , assertion , v , isTruthy )
237+ }
238+
239+ func testTrue (t * testing.T , assertion * Assertion , v any , isTruthy bool ) {
240+ err := assertion .True (v )
241+ if isTruthy && err != nil {
242+ t .Errorf ("True(%v) = %v, want nil" , v , err )
243+ } else if ! isTruthy && err == nil {
244+ t .Errorf ("True(%v) = nil, want error" , v )
245+ }
246+
247+ err = True (assertion .T , v )
248+ if isTruthy && err != nil {
249+ t .Errorf ("True(%v) = %v, want nil" , v , err )
250+ } else if ! isTruthy && err == nil {
251+ t .Errorf ("True(%v) = nil, want error" , v )
252+ }
253+ }
254+
255+ func testNotTrue (t * testing.T , assertion * Assertion , v any , isTruthy bool ) {
256+ err := assertion .NotTrue (v )
257+ if isTruthy && err == nil {
258+ t .Errorf ("NotTrue(%v) = nil, want error" , v )
259+ } else if ! isTruthy && err != nil {
260+ t .Errorf ("NotTrue(%v) = %v, want nil" , v , err )
261+ }
262+
263+ err = NotTrue (assertion .T , v )
264+ if isTruthy && err == nil {
265+ t .Errorf ("NotTrue(%v) = nil, want error" , v )
266+ } else if ! isTruthy && err != nil {
267+ t .Errorf ("NotTrue(%v) = %v, want nil" , v , err )
268+ }
269+ }
270+
271+ func testTrueNow (t * testing.T , assertion * Assertion , v any , isTruthy bool ) {
272+ isTerminated := internal .CheckTermination (func () {
273+ assertion .TrueNow (v )
274+ })
275+ if isTruthy && isTerminated {
276+ t .Error ("execution stopped, want do not stop" )
277+ } else if ! isTruthy && ! isTerminated {
278+ t .Error ("execution do not stopped, want stop" )
279+ }
280+
281+ isTerminated = internal .CheckTermination (func () {
282+ TrueNow (assertion .T , v )
283+ })
284+ if isTruthy && isTerminated {
285+ t .Error ("execution stopped, want do not stop" )
286+ } else if ! isTruthy && ! isTerminated {
287+ t .Error ("execution do not stopped, want stop" )
288+ }
289+ }
290+
291+ func testNotTrueNow (t * testing.T , assertion * Assertion , v any , isTruthy bool ) {
292+ isTerminated := internal .CheckTermination (func () {
293+ assertion .NotTrueNow (v )
294+ })
295+ if ! isTruthy && isTerminated {
296+ t .Error ("execution stopped, want do not stop" )
297+ } else if isTruthy && ! isTerminated {
298+ t .Error ("execution do not stopped, want stop" )
299+ }
300+
301+ isTerminated = internal .CheckTermination (func () {
302+ NotTrueNow (assertion .T , v )
303+ })
304+ if ! isTruthy && isTerminated {
305+ t .Error ("execution stopped, want do not stop" )
306+ } else if isTruthy && ! isTerminated {
307+ t .Error ("execution do not stopped, want stop" )
308+ }
309+ }
0 commit comments