From: Carl Hetherington Date: Tue, 17 Jan 2023 20:50:59 +0000 (+0100) Subject: Allow Collators to have their language specified, and specify it for tests. X-Git-Tag: v2.16.41~14 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=af25866f2b77d856121ce67ba11ba7e9f997bfe1;ds=sidebyside Allow Collators to have their language specified, and specify it for tests. --- diff --git a/src/lib/collator.cc b/src/lib/collator.cc index ba504fb6e..8de1857ab 100644 --- a/src/lib/collator.cc +++ b/src/lib/collator.cc @@ -36,10 +36,10 @@ using std::string; using std::vector; -Collator::Collator() +Collator::Collator(char const* locale) { UErrorCode status = U_ZERO_ERROR; - _collator = ucol_open(nullptr, &status); + _collator = ucol_open(locale, &status); if (_collator) { ucol_setAttribute(_collator, UCOL_NORMALIZATION_MODE, UCOL_ON, &status); /* Ignore case and character encoding (and probably some other things) */ diff --git a/src/lib/collator.h b/src/lib/collator.h index 1768c43c0..3cbb40748 100644 --- a/src/lib/collator.h +++ b/src/lib/collator.h @@ -32,7 +32,7 @@ struct UCollator; class Collator { public: - Collator(); + Collator(char const* locale = nullptr); ~Collator(); Collator(Collator const &) = delete; diff --git a/test/collator_test.cc b/test/collator_test.cc index e88d71b06..477b3747f 100644 --- a/test/collator_test.cc +++ b/test/collator_test.cc @@ -25,7 +25,7 @@ BOOST_AUTO_TEST_CASE(collator_compare_works_and_ignores_case) { - Collator collator; + Collator collator("en"); BOOST_CHECK_EQUAL(collator.compare("So often YOU won't even notice", "SO OFTEN you won't even NOTiCE"), 0); BOOST_CHECK_EQUAL(collator.compare("So often YOU won't even notice", "SO OFTEN you won't even see"), -1); @@ -35,7 +35,7 @@ BOOST_AUTO_TEST_CASE(collator_compare_works_and_ignores_case) BOOST_AUTO_TEST_CASE(collator_search_works_and_ignores_case) { - Collator collator; + Collator collator("en"); BOOST_CHECK(collator.find("outh", "With filthy mouths, and bad attitudes")); BOOST_CHECK(collator.find("with", "With filthy mouths, and bad attitudes"));