| 447 | } |
| 448 | |
| 449 | func TestInDeltaWrapper(t *testing.T) { |
| 450 | assert := New(new(testing.T)) |
| 451 | |
| 452 | True(t, assert.InDelta(1.001, 1, 0.01), "|1.001 - 1| <= 0.01") |
| 453 | True(t, assert.InDelta(1, 1.001, 0.01), "|1 - 1.001| <= 0.01") |
| 454 | True(t, assert.InDelta(1, 2, 1), "|1 - 2| <= 1") |
| 455 | False(t, assert.InDelta(1, 2, 0.5), "Expected |1 - 2| <= 0.5 to fail") |
| 456 | False(t, assert.InDelta(2, 1, 0.5), "Expected |2 - 1| <= 0.5 to fail") |
| 457 | False(t, assert.InDelta("", nil, 1), "Expected non numerals to fail") |
| 458 | |
| 459 | cases := []struct { |
| 460 | a, b interface{} |
| 461 | delta float64 |
| 462 | }{ |
| 463 | {uint8(2), uint8(1), 1}, |
| 464 | {uint16(2), uint16(1), 1}, |
| 465 | {uint32(2), uint32(1), 1}, |
| 466 | {uint64(2), uint64(1), 1}, |
| 467 | |
| 468 | {int(2), int(1), 1}, |
| 469 | {int8(2), int8(1), 1}, |
| 470 | {int16(2), int16(1), 1}, |
| 471 | {int32(2), int32(1), 1}, |
| 472 | {int64(2), int64(1), 1}, |
| 473 | |
| 474 | {float32(2), float32(1), 1}, |
| 475 | {float64(2), float64(1), 1}, |
| 476 | } |
| 477 | |
| 478 | for _, tc := range cases { |
| 479 | True(t, assert.InDelta(tc.a, tc.b, tc.delta), "Expected |%V - %V| <= %v", tc.a, tc.b, tc.delta) |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | func TestInEpsilonWrapper(t *testing.T) { |
| 484 | assert := New(new(testing.T)) |