Add support for i18n_plural(): Translation of plural forms
[libi2ncommon] / test / test_i18n.cpp
index c7fa4d1..c43ea7d 100644 (file)
@@ -97,4 +97,36 @@ BOOST_AUTO_TEST_CASE(StdStringInput)
     BOOST_CHECK_EQUAL("dummy test string", result);
 }
 
+BOOST_AUTO_TEST_CASE(PluralString0)
+{
+    // Zero elements get the plural message (in the default "plural" configuration)
+    BOOST_CHECK_EQUAL("xxx new messages", i18n_plural("One new message", "xxx new messages", 0));
+}
+
+BOOST_AUTO_TEST_CASE(PluralString1)
+{
+    BOOST_CHECK_EQUAL("One new message", i18n_plural("One new message", "xxx new messages", 1));
+}
+
+BOOST_AUTO_TEST_CASE(PluralString2)
+{
+    BOOST_CHECK_EQUAL("xxx new messages", i18n_plural("One new message", "xxx new messages", 2));
+}
+
+BOOST_AUTO_TEST_CASE(PluralStringWithParamter1)
+{
+    vector<string> data;
+    data.push_back("1");
+
+    BOOST_CHECK_EQUAL("1 new message", i18n_get_string(i18n_plural("$0 new message", "$0 new messages", 1), data));
+}
+
+BOOST_AUTO_TEST_CASE(PluralStringWithParamter2)
+{
+    vector<string> data;
+    data.push_back("500");
+
+    BOOST_CHECK_EQUAL("500 new messages", i18n_get_string(i18n_plural("$0 new message", "$0 new messages", 500), data));
+}
+
 BOOST_AUTO_TEST_SUITE_END()