git-bug/util/lamport/clock_testing.go

29 lines
525 B
Go
Raw Normal View History

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)
2020-11-08 19:53:11 +03:00
assert.Equal(t, Time(2), val)
assert.Equal(t, Time(2), c.Time())
2021-01-04 01:59:25 +03:00
err = c.Witness(42)
assert.NoError(t, err)
assert.Equal(t, Time(42), c.Time())
2021-01-04 01:59:25 +03:00
err = c.Witness(42)
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())
}