Skip to content

Commit

Permalink
Added test for capitalize and trimToNull
Browse files Browse the repository at this point in the history
Signed-off-by: Arnau Mora <[email protected]>
  • Loading branch information
ArnyminerZ committed Jul 15, 2024
1 parent 932b816 commit 279db1f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/src/test/java/at/bitfire/vcard4android/UtilsTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package at.bitfire.vcard4android

import at.bitfire.vcard4android.Utils.capitalize
import at.bitfire.vcard4android.Utils.trimToNull
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test

class UtilsTest {
@Test
fun testCapitalize() {
assertEquals("Utils Test", "utils test".capitalize()) // Test multiple words
assertEquals("Utils", "utils".capitalize()) // Test single word
assertEquals("", "".capitalize()) // Test empty string
}

@Test
fun testTrimToNull() {
assertEquals("test", " test".trimToNull()) // Test spaces only before
assertEquals("test", "test ".trimToNull()) // Test spaces only after
assertEquals("test", " test ".trimToNull()) // Test spaces before and after
assertNull(" ".trimToNull()) // Test spaces
assertNull("".trimToNull()) // Test empty string
}
}

0 comments on commit 279db1f

Please sign in to comment.