Skip to content

Commit

Permalink
Add more tests on empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
Schahen committed Aug 6, 2024
1 parent 00b11da commit 0a0925c
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ class ManagedStringTest {
assertEquals("你好", s3)
}

@Test
fun emptyStringTest() {
val s = ManagedString("")
assertEquals("", s.toString())
}

@Test
fun canCreateAndReadManagedString() {
val ms1 = ManagedString("Hello")
Expand All @@ -39,6 +33,9 @@ class ManagedStringTest {

val ms3 = ManagedString("你好!")
assertEquals("你好!", ms3.toString())

val msEmpty = ManagedString("")
assertEquals("", msEmpty.toString())
}

@Test
Expand All @@ -51,6 +48,9 @@ class ManagedStringTest {

val ms3 = ManagedString("你好").append(",世界")
assertEquals("你好,世界", ms3.toString())

val msEmpty = ManagedString("Empty string").append("")
assertEquals("Empty string", msEmpty.toString())
}

@Test
Expand All @@ -63,6 +63,9 @@ class ManagedStringTest {

val ms3 = ManagedString("世界").insert(0,"你好,")
assertEquals("你好,世界", ms3.toString())

val msEmpty = ManagedString("Empty string").insert(1, "").insert(0, "")
assertEquals("Empty string", msEmpty.toString())
}

@Test
Expand All @@ -78,5 +81,8 @@ class ManagedStringTest {

val ms4 = ManagedString("你好,世界!").remove(from = 2, length = 3) // ',' is 1 symbol
assertEquals("你好!", ms4.toString())

val msEmpty = ManagedString("World!").remove(from = 2, length = 0)
assertEquals("World!", msEmpty.toString())
}
}

0 comments on commit 0a0925c

Please sign in to comment.