normalization_ut.cpp 747 B

1234567891011121314151617181920212223242526272829303132
  1. #include <library/cpp/testing/unittest/registar.h>
  2. #include <util/charset/wide.h>
  3. #include <library/cpp/unicode/normalization/normalization.h>
  4. Y_UNIT_TEST_SUITE(TUnicodeNormalizationTest) {
  5. template <NUnicode::ENormalization NormType>
  6. void TestInit() {
  7. NUnicode::TNormalizer<NormType> normalizer;
  8. TString s("упячка detected");
  9. TUtf16String w;
  10. UTF8ToWide(s, w);
  11. normalizer.Normalize(w);
  12. }
  13. Y_UNIT_TEST(TestInitNFD) {
  14. TestInit<NUnicode::NFD>();
  15. }
  16. Y_UNIT_TEST(TestInitNFC) {
  17. TestInit<NUnicode::NFC>();
  18. }
  19. Y_UNIT_TEST(TestInitNFKD) {
  20. TestInit<NUnicode::NFKD>();
  21. }
  22. Y_UNIT_TEST(TestInitNFKC) {
  23. TestInit<NUnicode::NFKC>();
  24. }
  25. }