--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "TranslatedString.hpp"
+
+#include <gtest/gtest.h>
+
+TEST(TranslatedString, translationExistingKey)
+{
+ EXPECT_TRUE(setlocale(LC_ALL, "C"));
+ EXPECT_EQ(TranslatedString{"IDS_MSG_ACBUTTON_DONE_ABB"}.str(), std::string{"IDS_MSG_ACBUTTON_DONE_ABB"});
+ EXPECT_TRUE(setlocale(LC_ALL, "en_US.UTF-8"));
+ EXPECT_EQ(TranslatedString{"IDS_MSG_ACBUTTON_DONE_ABB"}.str(), std::string{"DONE"});
+}
+
+TEST(TranslatedString, translationNotExistingKey)
+{
+ EXPECT_TRUE(setlocale(LC_ALL, "C"));
+ EXPECT_EQ(TranslatedString{"IDS_ACCESSIBILITY_TEST_KEY"}.str(), std::string{"IDS_ACCESSIBILITY_TEST_KEY"});
+ EXPECT_TRUE(setlocale(LC_ALL, "en_US.UTF-8"));
+ EXPECT_EQ(TranslatedString{"IDS_ACCESSIBILITY_TEST_KEY"}.str(), std::string{"IDS_ACCESSIBILITY_TEST_KEY"});
+}
+
+TEST(TranslatedString, createFormatedStringDouble)
+{
+ EXPECT_TRUE(setlocale(LC_ALL, "C"));
+ EXPECT_EQ(TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", 0.11).str(), std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS"});
+ EXPECT_TRUE(setlocale(LC_ALL, "en_GB.UTF-8"));
+ EXPECT_EQ(TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", 0.11).str(), std::string{"0.1 seconds"});
+}
+
+TEST(TranslatedString, createFormatedStringInt)
+{
+ EXPECT_TRUE(setlocale(LC_ALL, "C"));
+ EXPECT_EQ(TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SWITCHES", 5).str(), std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SWITCHES"});
+ EXPECT_TRUE(setlocale(LC_ALL, "en_GB.UTF-8"));
+ EXPECT_EQ(TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SWITCHES", 5).str(), std::string{"5 Switches"});
+}
+
+TEST(TranslatedString, addTranslatedString)
+{
+ EXPECT_TRUE(setlocale(LC_ALL, "C"));
+ auto sum_1 = TranslatedString{"IDS_MSG_ACBUTTON_DONE_ABB"} + TranslatedString{"IDS_MSG_ACBUTTON_DONE_ABB"};
+ sum_1 += TranslatedString{"IDS_MSG_ACBUTTON_DONE_ABB"};
+ EXPECT_EQ(sum_1.str(), std::string{"IDS_MSG_ACBUTTON_DONE_ABBIDS_MSG_ACBUTTON_DONE_ABBIDS_MSG_ACBUTTON_DONE_ABB"});
+ EXPECT_TRUE(setlocale(LC_ALL, "en_GB.UTF-8"));
+ auto sum_2 = TranslatedString{"IDS_MSG_ACBUTTON_DONE_ABB"} + TranslatedString{"IDS_MSG_ACBUTTON_DONE_ABB"};
+ sum_2 += TranslatedString{"IDS_MSG_ACBUTTON_DONE_ABB"};
+ EXPECT_EQ(sum_2.str(), std::string{"DONEDONEDONE"});
+}
+
+int main(int argc, char *argv[])
+{
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+ try {
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+ } catch (...) {
+ return 1;
+ }
+}