nanotime_test.go 617 B

12345678910111213141516171819202122232425
  1. // Copyright (c) 2016 Arista Networks, Inc.
  2. // Use of this source code is governed by the Apache License 2.0
  3. // that can be found in the COPYING file.
  4. // Package monotime provides a fast monotonic clock source.
  5. package monotime_test
  6. import (
  7. "testing"
  8. . "notabug.org/themusicgod1/goarista/monotime"
  9. )
  10. func TestNow(t *testing.T) {
  11. for i := 0; i < 100; i++ {
  12. t1 := Now()
  13. t2 := Now()
  14. // I honestly thought that we needed >= here, but in some environments
  15. // two consecutive calls can return the same value!
  16. if t1 > t2 {
  17. t.Fatalf("t1=%d should have been less than or equal to t2=%d", t1, t2)
  18. }
  19. }
  20. }