folding_test.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. // Some special unicode characters, however, are folded by OSes
  39. {"\u212A", "k"},
  40. }
  41. for _, tc := range cases {
  42. res := UnicodeLowercase(tc[0])
  43. if res != tc[1] {
  44. t.Errorf("UnicodeLowercase(%q) => %q, expected %q", tc[0], res, tc[1])
  45. }
  46. }
  47. }