Merge pull request #958 from whym/kotlin

Convert tests into Kotlin
This commit is contained in:
Josephine Lim 2017-11-15 16:06:36 +10:00 committed by GitHub
commit b419140c66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 35 deletions

View file

@ -1,32 +0,0 @@
package fr.free.nrw.commons;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
public class UtilsTest {
@Test public void stripLocalizedStringPass() {
Assert.assertThat(Utils.stripLocalizedString("Hello"), is("Hello"));
}
@Test public void stripLocalizedStringJa() {
Assert.assertThat(Utils.stripLocalizedString("\"こんにちは\"@ja"), is("こんにちは"));
}
@Test public void capitalizeLowercase() {
Assert.assertThat(Utils.capitalize("hello"), is("Hello"));
}
@Test public void capitalizeFullCaps() {
Assert.assertThat(Utils.capitalize("HELLO"), is("HELLO"));
}
@Test public void capitalizeNumbersPass() {
Assert.assertThat(Utils.capitalize("12x"), is("12x"));
}
@Test public void capitalizeJaPass() {
Assert.assertThat(Utils.capitalize("こんにちは"), is("こんにちは"));
}
}

View file

@ -0,0 +1,32 @@
package fr.free.nrw.commons
import org.hamcrest.CoreMatchers.`is` as _is
import org.junit.Assert
import org.junit.Test
class UtilsTest {
@Test fun `strip nothing from non-localized string`() {
Assert.assertThat(Utils.stripLocalizedString("Hello"), _is("Hello"))
}
@Test fun `strip tag from Japanese string`() {
Assert.assertThat(Utils.stripLocalizedString("\"こんにちは\"@ja"), _is("こんにちは"))
}
@Test fun `capitalize first letter`() {
Assert.assertThat(Utils.capitalize("hello"), _is("Hello"))
}
@Test fun `capitalize - pass all-capital string as it is`() {
Assert.assertThat(Utils.capitalize("HELLO"), _is("HELLO"))
}
@Test fun `capitalize - pass numbers`() {
Assert.assertThat(Utils.capitalize("12x"), _is("12x"))
}
@Test fun `capitalize - pass Japanase characters`() {
Assert.assertThat(Utils.capitalize("こんにちは"), _is("こんにちは"))
}
}