clock_test.go 1003 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (C) 2014 The Syncthing Authors.
  2. //
  3. // This program is free software: you can redistribute it and/or modify it
  4. // under the terms of the GNU General Public License as published by the Free
  5. // Software Foundation, either version 3 of the License, or (at your option)
  6. // any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful, but WITHOUT
  9. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. // more details.
  12. //
  13. // You should have received a copy of the GNU General Public License along
  14. // with this program. If not, see <http://www.gnu.org/licenses/>.
  15. package lamport
  16. import "testing"
  17. var inputs = []uint64{0, 42, 2, 3, 4, 8, 9, 33, 44, 112, 100}
  18. func TestClock(t *testing.T) {
  19. c := Clock{}
  20. var prev uint64
  21. for _, input := range inputs {
  22. cur := c.Tick(input)
  23. if cur <= prev || cur <= input {
  24. t.Error("Clock moving backwards")
  25. }
  26. prev = cur
  27. }
  28. }