#include "gtest/gtest.h"
#include "I18n.hpp"
#if defined(__APPLE__)
#include <CoreFoundation/CoreFoundation.h>
#elif defined(__unix__) || defined(__linux__)
#include <locale>
#endif
TEST(I18nTest, DefaultLocaleSystem_1) {
i18n.setSupportedLocales<LocaleFr, LocaleEn>();
DefaultLocale* current = i18n.getLocale();
ASSERT_NE(current, nullptr) << "Current locale must be set after injection.";
EXPECT_EQ(current->languageCode(),
getSystemCode()) <<
"Default locale should be the first injected ('en').";
}
TEST(I18nTest, DefautLocaleEn_2) {
i18n.setSupportedLocales<LocaleEs, LocaleEn>();
DefaultLocale* current = i18n.getLocale();
ASSERT_NE(current, nullptr) << "Current locale must be set after injection.";
EXPECT_EQ(current->languageCode(), "en") << "Default locale should be the first injected ('en').";
}
TEST(I18nTest, DefaultLocaleFirst_3) {
i18n.setSupportedLocales<LocaleEs>();
DefaultLocale* current = i18n.getLocale();
ASSERT_NE(current, nullptr) << "Current locale must be set after injection.";
EXPECT_EQ(current->getButtonCancel(), "Cancelar");
}
TEST(I18nTest, SetupLocaleFr_4) {
EXPECT_EQ(i18n.setLocale("fr"), true);
DefaultLocale* current = i18n.getLocale();
ASSERT_NE(current, nullptr) << "Current locale must be set after injection.";
EXPECT_EQ(current->languageCode(), "fr");
EXPECT_EQ(current->getButtonCancel(), "Annuler");
EXPECT_EQ(current->getButtonSubmit(), "Valider");
EXPECT_EQ(current->getLoginSubTitle(), "Bienvenue !");
EXPECT_EQ(current->getSignInTitle(), "Connexion");
EXPECT_EQ(current->getSignUpTitle(), "Inscription");
}
std::tuple< LocaleEn, LocaleEs, LocaleFr, LocaleIt > SupportedLocales
Definition SupportedLocales.hpp:23
std::string getSystemCode()
Definition SystemCode.hpp:23
TEST(I18nTest, DefaultLocaleSystem_1)
Definition TestCXX20.cpp:23
static I18n< T > & getInstance()
Get the I18n singleton instance.
Definition I18n.hpp:46