conflict_test.go 762 B

12345678910111213141516171819202122232425
  1. // Copyright (C) 2015 The Protocol Authors.
  2. package protocol
  3. import "testing"
  4. func TestWinsConflict(t *testing.T) {
  5. testcases := [][2]FileInfo{
  6. // The first should always win over the second
  7. {{ModifiedS: 42}, {ModifiedS: 41}},
  8. {{ModifiedS: 41}, {ModifiedS: 42, Deleted: true}},
  9. {{Deleted: true}, {ModifiedS: 10, RawInvalid: true}},
  10. {{ModifiedS: 41, Version: Vector{Counters: []Counter{{ID: 42, Value: 2}, {ID: 43, Value: 1}}}}, {ModifiedS: 41, Version: Vector{Counters: []Counter{{ID: 42, Value: 1}, {ID: 43, Value: 2}}}}},
  11. }
  12. for _, tc := range testcases {
  13. if !WinsConflict(tc[0], tc[1]) {
  14. t.Errorf("%v should win over %v", tc[0], tc[1])
  15. }
  16. if WinsConflict(tc[1], tc[0]) {
  17. t.Errorf("%v should not win over %v", tc[1], tc[0])
  18. }
  19. }
  20. }