aboutsummaryrefslogblamecommitdiffstats
path: root/util/lamport/clock_testing.go
blob: de66c5c9076900a7b93a22061c61d5c0bcb4338a (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                            
                                     

                                          
                           


                                           
                           






                                           
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(2), val)
	assert.Equal(t, Time(2), c.Time())

	err = c.Witness(42)
	assert.NoError(t, err)
	assert.Equal(t, Time(42), c.Time())

	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())
}