X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Futils%2FStringsTest.kt;fp=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Futils%2FStringsTest.kt;h=e567c0fe73113272f68f11a4bf4c91c81c666ae7;hb=d5bf199171aa509d295985453db0cc130c3665a8;hp=0000000000000000000000000000000000000000;hpb=ab31cd5e716ab4c680051d288e4ad12168d4c0eb;p=Sone.git diff --git a/src/test/kotlin/net/pterodactylus/sone/utils/StringsTest.kt b/src/test/kotlin/net/pterodactylus/sone/utils/StringsTest.kt new file mode 100644 index 0000000..e567c0f --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/sone/utils/StringsTest.kt @@ -0,0 +1,33 @@ +package net.pterodactylus.sone.utils + +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.nullValue +import org.junit.Test + +/** + * Unit test for [StringsKt]. + */ +class StringsTest { + + @Test + fun `non-empty string is returned as-is`() { + assertThat("non-empty".emptyToNull, equalTo("non-empty")) + } + + @Test + fun `string with whitespace only is returned as null`() { + assertThat(" ".emptyToNull, nullValue()) + } + + @Test + fun `zero-length string is returned as null`() { + assertThat("".emptyToNull, nullValue()) + } + + @Test + fun `null is returned as null`() { + assertThat(null.emptyToNull, nullValue()) + } + +}