Add a test for CharSequence/String.regionMatches
This commit is contained in:
@@ -96,6 +96,24 @@ class StringTest {
|
|||||||
assertEquals("", ns.orEmpty())
|
assertEquals("", ns.orEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test fun regionMatchesForCharSequence() = withTwoCharSequenceArgs { arg1, arg2 ->
|
||||||
|
assertTrue(arg1("abcd").regionMatches(1, arg2("debc"), 2, 2))
|
||||||
|
assertFalse(arg1("abcd").regionMatches(1, arg2("DEBc"), 2, 2, ignoreCase = false))
|
||||||
|
assertTrue(arg1("abcd").regionMatches(1, arg2("DEBc"), 2, 2, ignoreCase = true))
|
||||||
|
|
||||||
|
assertFalse(arg1("abcd").regionMatches(3, arg2(""), 2, 1))
|
||||||
|
assertTrue(arg1("abcd").regionMatches(4, arg2(""), 0, 0))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun regionMatchesForString() {
|
||||||
|
assertTrue("abcd".regionMatches(1, "debc", 2, 2))
|
||||||
|
assertFalse("abcd".regionMatches(1, "DEBc", 2, 2, ignoreCase = false))
|
||||||
|
assertTrue("abcd".regionMatches(1, "DEBc", 2, 2, ignoreCase = true))
|
||||||
|
|
||||||
|
assertFalse("abcd".regionMatches(3, "", 2, 1))
|
||||||
|
assertTrue("abcd".regionMatches(4, "", 0, 0))
|
||||||
|
}
|
||||||
|
|
||||||
@Test fun startsWithString() {
|
@Test fun startsWithString() {
|
||||||
assertTrue("abcd".startsWith("ab"))
|
assertTrue("abcd".startsWith("ab"))
|
||||||
assertTrue("abcd".startsWith("abcd"))
|
assertTrue("abcd".startsWith("abcd"))
|
||||||
|
|||||||
Reference in New Issue
Block a user