acme-dns/vendor/github.com/gavv/monotime/monotime_test.go
2018-01-22 11:19:33 +02:00

30 lines
675 B
Go

// Copyright (C) 2016 Arista Networks, Inc.
// Use of this source code is governed by the Apache License 2.0
// that can be found in the COPYING file.
package monotime
import "testing"
func TestNow(t *testing.T) {
for i := 0; i < 100; i++ {
t1 := Now()
t2 := Now()
// I honestly thought that we needed >= here, but in some environments
// two consecutive calls can return the same value!
if t1 > t2 {
t.Fatalf("t1=%d should have been less than or equal to t2=%d", t1, t2)
}
}
}
func TestSince(t *testing.T) {
for i := 0; i < 100; i++ {
ts := Now()
d := Since(ts)
if d < 0 {
t.Fatalf("d=%d should be greater than or equal to zero", d)
}
}
}