@@ -251,6 +251,82 @@ func TestLessOrEqual(t *testing.T) {
251251 }
252252}
253253
254+ func TestPositive (t * testing.T ) {
255+ mockT := new (testing.T )
256+
257+ if ! Positive (mockT , 1 ) {
258+ t .Error ("Positive should return true" )
259+ }
260+
261+ if ! Positive (mockT , 1.23 ) {
262+ t .Error ("Positive should return true" )
263+ }
264+
265+ if Positive (mockT , - 1 ) {
266+ t .Error ("Positive should return false" )
267+ }
268+
269+ if Positive (mockT , - 1.23 ) {
270+ t .Error ("Positive should return false" )
271+ }
272+
273+ // Check error report
274+ for _ , currCase := range []struct {
275+ e interface {}
276+ msg string
277+ }{
278+ {e : int (- 1 ), msg : `"-1" is not positive` },
279+ {e : int8 (- 1 ), msg : `"-1" is not positive` },
280+ {e : int16 (- 1 ), msg : `"-1" is not positive` },
281+ {e : int32 (- 1 ), msg : `"-1" is not positive` },
282+ {e : int64 (- 1 ), msg : `"-1" is not positive` },
283+ {e : float32 (- 1.23 ), msg : `"-1.23" is not positive` },
284+ {e : float64 (- 1.23 ), msg : `"-1.23" is not positive` },
285+ } {
286+ out := & outputT {buf : bytes .NewBuffer (nil )}
287+ False (t , Positive (out , currCase .e ))
288+ Contains (t , string (out .buf .Bytes ()), currCase .msg )
289+ }
290+ }
291+
292+ func TestNegative (t * testing.T ) {
293+ mockT := new (testing.T )
294+
295+ if ! Negative (mockT , - 1 ) {
296+ t .Error ("Negative should return true" )
297+ }
298+
299+ if ! Negative (mockT , - 1.23 ) {
300+ t .Error ("Negative should return true" )
301+ }
302+
303+ if Negative (mockT , 1 ) {
304+ t .Error ("Negative should return false" )
305+ }
306+
307+ if Negative (mockT , 1.23 ) {
308+ t .Error ("Negative should return false" )
309+ }
310+
311+ // Check error report
312+ for _ , currCase := range []struct {
313+ e interface {}
314+ msg string
315+ }{
316+ {e : int (1 ), msg : `"1" is not negative` },
317+ {e : int8 (1 ), msg : `"1" is not negative` },
318+ {e : int16 (1 ), msg : `"1" is not negative` },
319+ {e : int32 (1 ), msg : `"1" is not negative` },
320+ {e : int64 (1 ), msg : `"1" is not negative` },
321+ {e : float32 (1.23 ), msg : `"1.23" is not negative` },
322+ {e : float64 (1.23 ), msg : `"1.23" is not negative` },
323+ } {
324+ out := & outputT {buf : bytes .NewBuffer (nil )}
325+ False (t , Negative (out , currCase .e ))
326+ Contains (t , string (out .buf .Bytes ()), currCase .msg )
327+ }
328+ }
329+
254330func Test_compareTwoValuesDifferentValuesTypes (t * testing.T ) {
255331 mockT := new (testing.T )
256332
0 commit comments