MCPcopy
hub / github.com/expr-lang/expr / TestInDeltaWrapper

Function TestInDeltaWrapper

internal/testify/assert/forward_assertions_test.go:449–481  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

447}
448
449func 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
483func TestInEpsilonWrapper(t *testing.T) {
484 assert := New(new(testing.T))

Callers

nothing calls this directly

Calls 4

NewFunction · 0.70
TrueFunction · 0.70
FalseFunction · 0.70
InDeltaMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…