gitlab.com/aquachain/aquachain@v1.17.16-rc3.0.20221018032414-e3ddf1e1c055/common/mclock/internal/monotime/nanotime_test.go (about) 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 5 // Package monotime provides a fast monotonic clock source. 6 package monotime 7 8 import ( 9 "testing" 10 ) 11 12 func TestNow(t *testing.T) { 13 for i := 0; i < 100; i++ { 14 t1 := Now() 15 t2 := Now() 16 // I honestly thought that we needed >= here, but in some environments 17 // two consecutive calls can return the same value! 18 if t1 > t2 { 19 t.Fatalf("t1=%d should have been less than or equal to t2=%d", t1, t2) 20 } 21 if t1 == t2 { 22 t.Log("warn: t1 == t2") 23 } 24 } 25 }