nativemodel_windows_test.go 821 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/.
  6. package protocol
  7. import (
  8. "reflect"
  9. "testing"
  10. )
  11. func TestFixupFiles(t *testing.T) {
  12. files := []FileInfo{
  13. {Name: "foo/bar"},
  14. {Name: `foo\bar`},
  15. {Name: "foo/baz"},
  16. {Name: "foo/quux"},
  17. {Name: `foo\fail`},
  18. }
  19. // Filenames should be slash converted, except files which already have
  20. // backslashes in them which are instead filtered out.
  21. expected := []FileInfo{
  22. {Name: `foo\bar`},
  23. {Name: `foo\baz`},
  24. {Name: `foo\quux`},
  25. }
  26. fixed := fixupFiles(files)
  27. if !reflect.DeepEqual(fixed, expected) {
  28. t.Errorf("Got %v, expected %v", fixed, expected)
  29. }
  30. }