MCPcopy
hub / github.com/stretchr/testify / TestInEpsilonWrapper

Function TestInEpsilonWrapper

assert/forward_assertions_test.go:527–565  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

525}
526
527func TestInEpsilonWrapper(t *testing.T) {
528 t.Parallel()
529
530 assert := New(new(testing.T))
531
532 cases := []struct {
533 a, b interface{}
534 epsilon float64
535 }{
536 {uint8(2), uint16(2), .001},
537 {2.1, 2.2, 0.1},
538 {2.2, 2.1, 0.1},
539 {-2.1, -2.2, 0.1},
540 {-2.2, -2.1, 0.1},
541 {uint64(100), uint8(101), 0.01},
542 {0.1, -0.1, 2},
543 }
544
545 for _, tc := range cases {
546 True(t, assert.InEpsilon(tc.a, tc.b, tc.epsilon, "Expected %V and %V to have a relative difference of %v", tc.a, tc.b, tc.epsilon))
547 }
548
549 cases = []struct {
550 a, b interface{}
551 epsilon float64
552 }{
553 {uint8(2), int16(-2), .001},
554 {uint64(100), uint8(102), 0.01},
555 {2.1, 2.2, 0.001},
556 {2.2, 2.1, 0.001},
557 {2.1, -2.2, 1},
558 {2.1, "bla-bla", 0},
559 {0.1, -0.1, 1.99},
560 }
561
562 for _, tc := range cases {
563 False(t, assert.InEpsilon(tc.a, tc.b, tc.epsilon, "Expected %V and %V to have a relative difference of %v", tc.a, tc.b, tc.epsilon))
564 }
565}
566
567func TestRegexpWrapper(t *testing.T) {
568 t.Parallel()

Callers

nothing calls this directly

Calls 4

NewFunction · 0.70
TrueFunction · 0.70
FalseFunction · 0.70
InEpsilonMethod · 0.45

Tested by

no test coverage detected