diff --git a/src/unittests/common/I18NTests.cpp b/src/unittests/common/I18NTests.cpp index 8b6511eb0..7a38ac974 100644 --- a/src/unittests/common/I18NTests.cpp +++ b/src/unittests/common/I18NTests.cpp @@ -48,21 +48,31 @@ void I18NTests::detectedLangTest() QVERIFY(m_langMap.contains(lang)); } -void I18NTests::check639NameTest() +void I18NTests::check639NameTest_validMapValues() { for (const auto &lang : m_langMap.keys()) QCOMPARE(I18N::nativeTo639Name(lang), m_langMap.value(lang)); } -void I18NTests::toNativeNameTest() +void I18NTests::check639NameTest_invalidName() +{ + QCOMPARE(I18N::nativeTo639Name("INVALID"), QString()); +} + +void I18NTests::toNativeNameTest_validMapValues() { for (const auto &lang : m_langMap.values()) QCOMPARE(I18N::toNativeName(lang), m_langMap.key(lang)); } -void I18NTests::setLangTest() +void I18NTests::toNativeNameTest_invalidName() { - // make sure we are not staring with our language set to the maps first value + QCOMPARE(I18N::toNativeName("INVALID"), QString()); +} + +void I18NTests::setLangTest_validLangs() +{ + // make sure we are not staring with our language set to the maps last value // ensures a languageChanged signal will be emited for each itteration of the testing loop I18N::setLanguage(m_langMap.value(m_langMap.lastKey())); QSignalSpy spy(I18N::instance(), &I18N::languageChanged); @@ -73,6 +83,20 @@ void I18NTests::setLangTest() QCOMPARE(spy.count(), m_langMap.count()); } +void I18NTests::setLangTest_invalidLang() +{ + QSignalSpy spy(I18N::instance(), &I18N::languageChanged); + I18N::setLanguage("INVALID-LANGUAGE"); + QCOMPARE(spy.count(), 0); +} + +void I18NTests::setLangTest_currentLang() +{ + QSignalSpy spy(I18N::instance(), &I18N::languageChanged); + I18N::setLanguage(I18N::currentLanguage()); + QCOMPARE(spy.count(), 0); +} + void I18NTests::reDetectTest() { QSignalSpy spy(I18N::instance(), &I18N::languagesChanged); diff --git a/src/unittests/common/I18NTests.h b/src/unittests/common/I18NTests.h index 56f86d1a1..86d9f9b37 100644 --- a/src/unittests/common/I18NTests.h +++ b/src/unittests/common/I18NTests.h @@ -13,9 +13,13 @@ private Q_SLOTS: void initTestCase(); void creationTest(); void detectedLangTest(); - void check639NameTest(); - void toNativeNameTest(); - void setLangTest(); + void check639NameTest_validMapValues(); + void check639NameTest_invalidName(); + void toNativeNameTest_validMapValues(); + void toNativeNameTest_invalidName(); + void setLangTest_validLangs(); + void setLangTest_invalidLang(); + void setLangTest_currentLang(); void reDetectTest(); private: