added translator test
This commit is contained in:
parent
1cf8d5ced7
commit
1e0c3ff550
|
@ -0,0 +1,41 @@
|
||||||
|
package me.teridax.jcash.lang;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static junit.framework.TestCase.assertEquals;
|
||||||
|
import static junit.framework.TestCase.assertTrue;
|
||||||
|
|
||||||
|
public class TranslatorTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLoading() {
|
||||||
|
// test if all locales are read
|
||||||
|
assertTrue(Arrays.deepEquals(Translator.availableLocales(), new String[]{"en_EN", "de_DE", "es_ES", "fr_FR", "zh_Hans"}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTranslationBasic() {
|
||||||
|
// test if basic translation works
|
||||||
|
Translator.setTranslationLocale("de_DE");
|
||||||
|
assertEquals(Translator.translate("Overdraft"), "Überziehungsbetrag");
|
||||||
|
assertEquals(Translator.translate("Load database"), "Datenbank auswählen");
|
||||||
|
assertEquals(Translator.translate("currency must not be blank"), "Betrag darf nicht leer sein");
|
||||||
|
assertEquals(Translator.translate("Deposit money"), "Geld einzahlen");
|
||||||
|
|
||||||
|
Translator.setTranslationLocale("es_ES");
|
||||||
|
assertEquals(Translator.translate("Account"), "Cuenta");
|
||||||
|
assertEquals(Translator.translate("Faulty login attempt"), "Solicitud de autenticación no válida");
|
||||||
|
assertEquals(Translator.translate("Transfer money"), "Transferencia de dinero");
|
||||||
|
|
||||||
|
// test if translation with no available translation works as expected
|
||||||
|
assertEquals(Translator.translate("Guppi guppi guppi"), "Guppi guppi guppi");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInvalidLocales() {
|
||||||
|
// test if app crashes when invalid locale is loaded
|
||||||
|
Translator.setTranslationLocale("ar_TD");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue