github.com/go-playground/pkg/v5@v5.29.1/time/instant_test.go (about) 1 //go:build go1.18 2 // +build go1.18 3 4 package timeext 5 6 import ( 7 "testing" 8 ) 9 10 func TestInstant(t *testing.T) { 11 i := NewInstant() 12 if i.Elapsed() < 0 { 13 t.Fatalf("elapsed time should be always be monotonically increasing") 14 } 15 i2 := NewInstant() 16 if i2.Since(i) < 0 { 17 t.Fatalf("time since instant should always be after") 18 } 19 if i.Since(i2) != 0 { 20 t.Fatalf("time since instant should be zero") 21 } 22 }