MCPcopy Create free account
hub / github.com/stretchr/testify / TestWithinDuration

Function TestWithinDuration

assert/assertions_test.go:1845–1862  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1843}
1844
1845func TestWithinDuration(t *testing.T) {
1846
1847 mockT := new(testing.T)
1848 a := time.Now()
1849 b := a.Add(10 * time.Second)
1850
1851 True(t, WithinDuration(mockT, a, b, 10*time.Second), "A 10s difference is within a 10s time difference")
1852 True(t, WithinDuration(mockT, b, a, 10*time.Second), "A 10s difference is within a 10s time difference")
1853
1854 False(t, WithinDuration(mockT, a, b, 9*time.Second), "A 10s difference is not within a 9s time difference")
1855 False(t, WithinDuration(mockT, b, a, 9*time.Second), "A 10s difference is not within a 9s time difference")
1856
1857 False(t, WithinDuration(mockT, a, b, -9*time.Second), "A 10s difference is not within a 9s time difference")
1858 False(t, WithinDuration(mockT, b, a, -9*time.Second), "A 10s difference is not within a 9s time difference")
1859
1860 False(t, WithinDuration(mockT, a, b, -11*time.Second), "A 10s difference is not within a 9s time difference")
1861 False(t, WithinDuration(mockT, b, a, -11*time.Second), "A 10s difference is not within a 9s time difference")
1862}
1863
1864func TestWithinRange(t *testing.T) {
1865

Callers

nothing calls this directly

Calls 3

TrueFunction · 0.70
WithinDurationFunction · 0.70
FalseFunction · 0.70

Tested by

no test coverage detected