308 // |
354 // |
309 // assert.Greater(t, 2, 1) |
355 // assert.Greater(t, 2, 1) |
310 // assert.Greater(t, float64(2), float64(1)) |
356 // assert.Greater(t, float64(2), float64(1)) |
311 // assert.Greater(t, "b", "a") |
357 // assert.Greater(t, "b", "a") |
312 func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { |
358 func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { |
313 return compareTwoValues(t, e1, e2, []CompareType{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs) |
359 if h, ok := t.(tHelper); ok { |
|
360 h.Helper() |
|
361 } |
|
362 return compareTwoValues(t, e1, e2, []CompareType{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...) |
314 } |
363 } |
315 |
364 |
316 // GreaterOrEqual asserts that the first element is greater than or equal to the second |
365 // GreaterOrEqual asserts that the first element is greater than or equal to the second |
317 // |
366 // |
318 // assert.GreaterOrEqual(t, 2, 1) |
367 // assert.GreaterOrEqual(t, 2, 1) |
319 // assert.GreaterOrEqual(t, 2, 2) |
368 // assert.GreaterOrEqual(t, 2, 2) |
320 // assert.GreaterOrEqual(t, "b", "a") |
369 // assert.GreaterOrEqual(t, "b", "a") |
321 // assert.GreaterOrEqual(t, "b", "b") |
370 // assert.GreaterOrEqual(t, "b", "b") |
322 func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { |
371 func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { |
323 return compareTwoValues(t, e1, e2, []CompareType{compareGreater, compareEqual}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs) |
372 if h, ok := t.(tHelper); ok { |
|
373 h.Helper() |
|
374 } |
|
375 return compareTwoValues(t, e1, e2, []CompareType{compareGreater, compareEqual}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...) |
324 } |
376 } |
325 |
377 |
326 // Less asserts that the first element is less than the second |
378 // Less asserts that the first element is less than the second |
327 // |
379 // |
328 // assert.Less(t, 1, 2) |
380 // assert.Less(t, 1, 2) |
329 // assert.Less(t, float64(1), float64(2)) |
381 // assert.Less(t, float64(1), float64(2)) |
330 // assert.Less(t, "a", "b") |
382 // assert.Less(t, "a", "b") |
331 func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { |
383 func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { |
332 return compareTwoValues(t, e1, e2, []CompareType{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs) |
384 if h, ok := t.(tHelper); ok { |
|
385 h.Helper() |
|
386 } |
|
387 return compareTwoValues(t, e1, e2, []CompareType{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...) |
333 } |
388 } |
334 |
389 |
335 // LessOrEqual asserts that the first element is less than or equal to the second |
390 // LessOrEqual asserts that the first element is less than or equal to the second |
336 // |
391 // |
337 // assert.LessOrEqual(t, 1, 2) |
392 // assert.LessOrEqual(t, 1, 2) |
338 // assert.LessOrEqual(t, 2, 2) |
393 // assert.LessOrEqual(t, 2, 2) |
339 // assert.LessOrEqual(t, "a", "b") |
394 // assert.LessOrEqual(t, "a", "b") |
340 // assert.LessOrEqual(t, "b", "b") |
395 // assert.LessOrEqual(t, "b", "b") |
341 func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { |
396 func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { |
342 return compareTwoValues(t, e1, e2, []CompareType{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs) |
397 if h, ok := t.(tHelper); ok { |
|
398 h.Helper() |
|
399 } |
|
400 return compareTwoValues(t, e1, e2, []CompareType{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...) |
343 } |
401 } |
344 |
402 |
345 // Positive asserts that the specified element is positive |
403 // Positive asserts that the specified element is positive |
346 // |
404 // |
347 // assert.Positive(t, 1) |
405 // assert.Positive(t, 1) |
348 // assert.Positive(t, 1.23) |
406 // assert.Positive(t, 1.23) |
349 func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool { |
407 func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool { |
|
408 if h, ok := t.(tHelper); ok { |
|
409 h.Helper() |
|
410 } |
350 zero := reflect.Zero(reflect.TypeOf(e)) |
411 zero := reflect.Zero(reflect.TypeOf(e)) |
351 return compareTwoValues(t, e, zero.Interface(), []CompareType{compareGreater}, "\"%v\" is not positive", msgAndArgs) |
412 return compareTwoValues(t, e, zero.Interface(), []CompareType{compareGreater}, "\"%v\" is not positive", msgAndArgs...) |
352 } |
413 } |
353 |
414 |
354 // Negative asserts that the specified element is negative |
415 // Negative asserts that the specified element is negative |
355 // |
416 // |
356 // assert.Negative(t, -1) |
417 // assert.Negative(t, -1) |
357 // assert.Negative(t, -1.23) |
418 // assert.Negative(t, -1.23) |
358 func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) bool { |
419 func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) bool { |
|
420 if h, ok := t.(tHelper); ok { |
|
421 h.Helper() |
|
422 } |
359 zero := reflect.Zero(reflect.TypeOf(e)) |
423 zero := reflect.Zero(reflect.TypeOf(e)) |
360 return compareTwoValues(t, e, zero.Interface(), []CompareType{compareLess}, "\"%v\" is not negative", msgAndArgs) |
424 return compareTwoValues(t, e, zero.Interface(), []CompareType{compareLess}, "\"%v\" is not negative", msgAndArgs...) |
361 } |
425 } |
362 |
426 |
363 func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []CompareType, failMessage string, msgAndArgs ...interface{}) bool { |
427 func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []CompareType, failMessage string, msgAndArgs ...interface{}) bool { |
364 if h, ok := t.(tHelper); ok { |
428 if h, ok := t.(tHelper); ok { |
365 h.Helper() |
429 h.Helper() |