clock_test.go 516 B

12345678910111213141516171819202122
  1. // Copyright (C) 2014 Jakob Borg and Contributors (see the CONTRIBUTORS file).
  2. // All rights reserved. Use of this source code is governed by an MIT-style
  3. // license that can be found in the LICENSE file.
  4. package lamport
  5. import "testing"
  6. var inputs = []uint64{0, 42, 2, 3, 4, 8, 9, 33, 44, 112, 100}
  7. func TestClock(t *testing.T) {
  8. c := Clock{}
  9. var prev uint64
  10. for _, input := range inputs {
  11. cur := c.Tick(input)
  12. if cur <= prev || cur <= input {
  13. t.Error("Clock moving backwards")
  14. }
  15. prev = cur
  16. }
  17. }