clock_test.go 559 B

123456789101112131415161718192021222324
  1. // Copyright (C) 2014 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at http://mozilla.org/MPL/2.0/.
  6. package lamport
  7. import "testing"
  8. var inputs = []int64{0, 42, 2, 3, 4, 8, 9, 33, 44, 112, 100}
  9. func TestClock(t *testing.T) {
  10. c := Clock{}
  11. var prev int64
  12. for _, input := range inputs {
  13. cur := c.Tick(input)
  14. if cur <= prev || cur <= input {
  15. t.Error("Clock moving backwards")
  16. }
  17. prev = cur
  18. }
  19. }