folding_test.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright (C) 2017 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 fs
  7. import "testing"
  8. func TestUnicodeLowercase(t *testing.T) {
  9. cases := [][2]string{
  10. {"", ""},
  11. {"hej", "hej"},
  12. {"HeJ!@#", "hej!@#"},
  13. // Western Europe diacritical stuff is trivial
  14. {"ÜBERRÄKSMÖRGÅS", "überräksmörgås"},
  15. // Cyrillic seems regular as well
  16. {"Привет", "привет"},
  17. // Greek has multiple lower case characters for things depending on
  18. // context; we should always choose the right one.
  19. {"Ὀδυσσεύς", "ὀδυσσεύσ"},
  20. {"ὈΔΥΣΣΕΎΣ", "ὀδυσσεύσ"},
  21. // German ß doesn't really have an upper case variant, and we
  22. // shouldn't mess things up when lower casing it either. We don't
  23. // attempt to make ß equivalent to "ss".
  24. {"Reichwaldstraße", "reichwaldstraße"},
  25. // The Turks do their thing with the Is.... Like the Greek example
  26. // we pick just the one canonicalized "i" although you can argue
  27. // with this... From what I understand most operating systems don't
  28. // get this right anyway.
  29. {"İI", "ii"},
  30. // Arabic doesn't do case folding.
  31. {"العَرَبِيَّة", "العَرَبِيَّة"},
  32. // Neither does Hebrew.
  33. {"עברית", "עברית"},
  34. // Nor Chinese, in any variant.
  35. {"汉语/漢語 or 中文", "汉语/漢語 or 中文"},
  36. // Niether katakana as far as I can tell.
  37. {"チャーハン", "チャーハン"},
  38. }
  39. for _, tc := range cases {
  40. res := UnicodeLowercase(tc[0])
  41. if res != tc[1] {
  42. t.Errorf("UnicodeLowercase(%q) => %q, expected %q", tc[0], res, tc[1])
  43. }
  44. }
  45. }