summaryrefslogtreecommitdiff
path: root/libs/utils/src/test/java/org
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2024-07-15 23:52:28 +0200
committerJoel Klinghed <the_jk@spawned.biz>2024-07-16 00:25:07 +0200
commit42564c71cfb70c28831c662a3b6bf4084e079353 (patch)
tree111456fd3e8dce884d0380a81d70950062c7d212 /libs/utils/src/test/java/org
parent4a8f6807c9d3ee6bcfac25aee832163036b4e6fe (diff)
Break out io code in libs
Preparing for adding more io implementations. Really tried writing the convention plugins in kotlin dsl but could not find the exact right hacks to get it to work.
Diffstat (limited to 'libs/utils/src/test/java/org')
-rw-r--r--libs/utils/src/test/java/org/the_jk/cleversync/StringUtilsTest.kt40
1 files changed, 40 insertions, 0 deletions
diff --git a/libs/utils/src/test/java/org/the_jk/cleversync/StringUtilsTest.kt b/libs/utils/src/test/java/org/the_jk/cleversync/StringUtilsTest.kt
new file mode 100644
index 0000000..6a36156
--- /dev/null
+++ b/libs/utils/src/test/java/org/the_jk/cleversync/StringUtilsTest.kt
@@ -0,0 +1,40 @@
+package org.the_jk.cleversync
+
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+
+class StringUtilsTest {
+ @Test
+ fun splitEmpty() {
+ assertThat(StringUtils.split("", '.', keepEmpty = true)).containsExactly("")
+ assertThat(StringUtils.split("", '.', keepEmpty = false)).isEmpty()
+ }
+
+ @Test
+ fun splitSanity() {
+ assertThat(StringUtils.split("a.bb.a", '.')).containsExactly("a", "bb", "a").inOrder()
+ assertThat(StringUtils.split(".a.bb.a", '.', keepEmpty = true)).containsExactly("", "a", "bb", "a").inOrder()
+ assertThat(StringUtils.split(".a.bb.a", '.', keepEmpty = false)).containsExactly("a", "bb", "a").inOrder()
+ assertThat(StringUtils.split(".a.bb.a.", '.', keepEmpty = true))
+ .containsExactly("", "a", "bb", "a", "").inOrder()
+ assertThat(StringUtils.split(".a.bb.a.", '.', keepEmpty = false)).containsExactly("a", "bb", "a").inOrder()
+ }
+
+ @Test
+ fun splitDouble() {
+ assertThat(StringUtils.split("foo..bar", '.', keepEmpty = true)).containsExactly("foo", "", "bar").inOrder()
+ assertThat(StringUtils.split("foo..bar", '.', keepEmpty = false)).containsExactly("foo", "bar").inOrder()
+ }
+
+ @Test
+ fun splitLimit() {
+ assertThat(StringUtils.split("a.bb.a", '.', limit = 1)).containsExactly("a.bb.a")
+ assertThat(StringUtils.split("a.bb.a", '.', limit = 2)).containsExactly("a", "bb.a").inOrder()
+ assertThat(StringUtils.split("a.bb.a", '.', limit = 3)).containsExactly("a", "bb", "a").inOrder()
+ assertThat(StringUtils.split("a.bb.a.", '.', limit = 3, keepEmpty = true))
+ .containsExactly("a", "bb", "a.").inOrder()
+ assertThat(StringUtils.split("a.bb.a.", '.', limit = 3, keepEmpty = false))
+ .containsExactly("a", "bb", "a").inOrder()
+ assertThat(StringUtils.split("a.bb.a", '.', limit = 1000)).containsExactly("a", "bb", "a").inOrder()
+ }
+}