github.com/sunvim/utils@v0.1.0/lamport/clock_testing.go (about) 1 package lamport 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func testClock(t *testing.T, c Clock) { 10 assert.Equal(t, Time(1), c.Time()) 11 12 val, err := c.Increment() 13 assert.NoError(t, err) 14 assert.Equal(t, Time(2), val) 15 assert.Equal(t, Time(2), c.Time()) 16 17 err = c.Witness(42) 18 assert.NoError(t, err) 19 assert.Equal(t, Time(42), c.Time()) 20 21 err = c.Witness(42) 22 assert.NoError(t, err) 23 assert.Equal(t, Time(42), c.Time()) 24 25 err = c.Witness(30) 26 assert.NoError(t, err) 27 assert.Equal(t, Time(42), c.Time()) 28 }