github.com/rogpeppe/clock@v0.0.0-20190514195947-2896927a307a/monotonic/monotonic_test.go (about)

     1  // Copyright 2017 Canonical Ltd.
     2  // Licensed under the LGPLv3, see LICENCE file for details.
     3  
     4  package monotonic_test
     5  
     6  import (
     7  	"testing"
     8  	"time"
     9  
    10  	"github.com/rogpeppe/clock/monotonic"
    11  )
    12  
    13  func TestNow(t *testing.T) {
    14  	var prev time.Duration
    15  	for i := 0; i < 1000; i++ {
    16  		val := monotonic.Now()
    17  		if val < prev {
    18  			t.Fatal("now is less than previous value")
    19  		}
    20  		prev = val
    21  	}
    22  }