blob: 477d14217b0e740104445460879e0fb44feb4df9 [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package clock
import (
"testing"
)
type systemClockMockImpl struct {
now int64
}
func (sc *systemClockMockImpl) Now() int64 {
return sc.now
}
func (sc *systemClockMockImpl) setNow(now int64) {
sc.now = now
}
var (
_ SystemClock = (*systemClockImpl)(nil)
)
func TestVClock(t *testing.T) {
clock := NewVClock()
sysClock := &systemClockMockImpl{}
writeTs := int64(4)
sysClock.setNow(writeTs)
clock.SetSystemClock(sysClock)
ts := clock.Now()
if ts != writeTs {
t.Errorf("timestamp expected to be %q but found to be %q", writeTs, ts)
}
}