diff options
Diffstat (limited to 'util/lamport/clock_testing.go')
-rw-r--r-- | util/lamport/clock_testing.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/util/lamport/clock_testing.go b/util/lamport/clock_testing.go new file mode 100644 index 00000000..fc59afb2 --- /dev/null +++ b/util/lamport/clock_testing.go @@ -0,0 +1,28 @@ +package lamport + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func testClock(t *testing.T, c Clock) { + assert.Equal(t, Time(1), c.Time()) + + val, err := c.Increment() + assert.NoError(t, err) + assert.Equal(t, Time(1), val) + assert.Equal(t, Time(2), c.Time()) + + err = c.Witness(41) + assert.NoError(t, err) + assert.Equal(t, Time(42), c.Time()) + + err = c.Witness(41) + assert.NoError(t, err) + assert.Equal(t, Time(42), c.Time()) + + err = c.Witness(30) + assert.NoError(t, err) + assert.Equal(t, Time(42), c.Time()) +} |