Fix bug in login page
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / utils / StringsTest.kt
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 (file)
index 0000000..e567c0f
--- /dev/null
@@ -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())
+       }
+
+}