Get rid of deprecated annotations and modifiers in stdlib (besides JS)

This commit is contained in:
Denis Zharkov
2015-09-14 16:35:30 +03:00
parent 9c4564a5a6
commit 5cecaa6f87
133 changed files with 1203 additions and 1085 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ import org.junit.Test as test
class CharJVMTest {
test fun getCategory() {
@test fun getCategory() {
assertEquals(CharCategory.DECIMAL_DIGIT_NUMBER, '7'.category())
assertEquals(CharCategory.CURRENCY_SYMBOL, '$'.category())
assertEquals(CharCategory.LOWERCASE_LETTER, 'a'.category())
+1 -1
View File
@@ -7,7 +7,7 @@ import org.junit.Test as test
class RegexJVMTest {
test fun matchGroups() {
@test fun matchGroups() {
val input = "1a 2b 3c"
val regex = "(\\d)(\\w)".toRegex()
+11 -11
View File
@@ -7,7 +7,7 @@ import org.junit.Test as test
class RegexTest {
test fun matchResult() {
@test fun matchResult() {
val p = "\\d+".toRegex()
val input = "123 456 789"
@@ -35,12 +35,12 @@ class RegexTest {
assertEquals(null, noMatch)
}
test fun matchIgnoreCase() {
@test fun matchIgnoreCase() {
for (input in listOf("ascii", "shrödinger"))
assertTrue(input.toUpperCase().matches(input.toLowerCase().toRegex(RegexOption.IGNORE_CASE)))
}
test fun matchSequence() {
@test fun matchSequence() {
val input = "123 456 789"
val pattern = "\\d+".toRegex()
@@ -54,7 +54,7 @@ class RegexTest {
assertEquals(listOf(0..2, 4..6, 8..10), matches.map { it.range }.toList())
}
test fun matchAllSequence() {
@test fun matchAllSequence() {
val input = "test"
val pattern = ".*".toRegex()
val matches = pattern.matchAll(input).toList()
@@ -63,7 +63,7 @@ class RegexTest {
assertEquals(2, matches.size())
}
test fun matchGroups() {
@test fun matchGroups() {
val input = "1a 2b 3c"
val pattern = "(\\d)(\\w)".toRegex()
@@ -79,7 +79,7 @@ class RegexTest {
assertEquals("b", m2.groups[2]?.value)
}
test fun matchOptionalGroup() {
@test fun matchOptionalGroup() {
val pattern = "(hi)|(bye)".toRegex(RegexOption.IGNORE_CASE)
val m1 = pattern.match("Hi!")!!
@@ -93,19 +93,19 @@ class RegexTest {
assertEquals("bye", m2.groups[2]?.value)
}
test fun matchMultiline() {
@test fun matchMultiline() {
val regex = "^[a-z]*$".toRegex(setOf(RegexOption.IGNORE_CASE, RegexOption.MULTILINE))
val matchedValues = regex.matchAll("test\n\nLine").map { it.value }.toList()
assertEquals(listOf("test", "", "Line"), matchedValues)
}
test fun escapeLiteral() {
@test fun escapeLiteral() {
val literal = """[-\/\\^$*+?.()|[\]{}]"""
assertTrue(Regex.fromLiteral(literal).matches(literal))
assertTrue(Regex.escape(literal).toRegex().matches(literal))
}
test fun replace() {
@test fun replace() {
val input = "123-456"
val pattern = "(\\d+)".toRegex()
assertEquals("(123)-(456)", pattern.replace(input, "($1)"))
@@ -114,14 +114,14 @@ class RegexTest {
assertEquals("X-456", pattern.replaceFirst(input, "X"))
}
test fun replaceEvaluator() {
@test fun replaceEvaluator() {
val input = "/12/456/7890/"
val pattern = "\\d+".toRegex()
assertEquals("/2/3/4/", pattern.replace(input, { it.value.length().toString() } ))
}
test fun split() {
@test fun split() {
val input = """
some ${"\t"} word
split
@@ -5,7 +5,7 @@ import org.junit.Test as test
class StringBuilderTest {
test fun stringBuild() {
@test fun stringBuild() {
val s = StringBuilder {
append("a")
append(true)
@@ -13,13 +13,13 @@ class StringBuilderTest {
assertEquals("atrue", s)
}
test fun appendMany() {
@test fun appendMany() {
assertEquals("a1", StringBuilder().append("a", "1").toString())
assertEquals("a1", StringBuilder().append("a", 1).toString())
assertEquals("a1", StringBuilder().append("a", StringBuilder().append("1")).toString())
}
test fun append() {
@test fun append() {
// this test is needed for JS implementation
assertEquals("em", StringBuilder {
append("element", 2, 4)
+40 -40
View File
@@ -6,7 +6,7 @@ import kotlin.test.*
import org.junit.Test as test
class StringJVMTest {
test fun stringBuilderIterator() {
@test fun stringBuilderIterator() {
var sum = 0
val sb = StringBuilder()
for(c in "239")
@@ -19,7 +19,7 @@ class StringJVMTest {
assertTrue(sum == 14)
}
test fun orEmpty() {
@test fun orEmpty() {
val s: String? = "hey"
val ns: String? = null
@@ -27,25 +27,25 @@ class StringJVMTest {
assertEquals("", ns.orEmpty())
}
test fun toShort() {
@test fun toShort() {
assertEquals(77.toShort(), "77".toShort())
}
test fun toInt() {
@test fun toInt() {
assertEquals(77, "77".toInt())
}
test fun toLong() {
@test fun toLong() {
assertEquals(77.toLong(), "77".toLong())
}
test fun count() {
@test fun count() {
val text = "hello there\tfoo\nbar"
val whitespaceCount = text.count { it.isWhitespace() }
assertEquals(3, whitespaceCount)
}
test fun testSplitByChar() {
@test fun testSplitByChar() {
val s = "ab\n[|^$&\\]^cd"
var list = s.split('b');
assertEquals(2, list.size())
@@ -59,7 +59,7 @@ class StringJVMTest {
assertEquals(s, list[0])
}
test fun testSplitByPattern() {
@test fun testSplitByPattern() {
val s = "ab1cd2def3"
val isDigit = "\\d".toRegex()
assertEquals(listOf("ab", "cd", "def", ""), s.split(isDigit))
@@ -73,7 +73,7 @@ class StringJVMTest {
}
}
test fun repeat() {
@test fun repeat() {
fails{ "foo".repeat(-1) }
assertEquals("", "foo".repeat(0))
assertEquals("foo", "foo".repeat(1))
@@ -81,24 +81,24 @@ class StringJVMTest {
assertEquals("foofoofoo", "foo".repeat(3))
}
test fun filter() {
@test fun filter() {
assertEquals("acdca", "abcdcba".filter { !it.equals('b') })
assertEquals("1234", "a1b2c3d4".filter { it.isDigit() })
}
test fun filterNot() {
@test fun filterNot() {
assertEquals("acdca", "abcdcba".filterNot { it.equals('b') })
assertEquals("abcd", "a1b2c3d4".filterNot { it.isDigit() })
}
test fun forEach() {
@test fun forEach() {
val data = "abcd1234"
var count = 0
data.forEach{ count++ }
assertEquals(data.length(), count)
}
test fun all() {
@test fun all() {
val data = "AbCd"
assertTrue {
data.all { it.isJavaLetter() }
@@ -108,7 +108,7 @@ class StringJVMTest {
}
}
test fun any() {
@test fun any() {
val data = "a1bc"
assertTrue {
data.any() { it.isDigit() }
@@ -118,33 +118,33 @@ class StringJVMTest {
}
}
test fun joinTo() {
@test fun joinTo() {
val data = "kotlin".toList()
val sb = StringBuilder()
data.joinTo(sb, "^", "<", ">")
assertEquals("<k^o^t^l^i^n>", sb.toString())
}
test fun find() {
@test fun find() {
val data = "a1b2c3"
assertEquals('1', data.first { it.isDigit() })
assertNull(data.firstOrNull { it.isUpperCase() })
}
test fun findNot() {
@test fun findNot() {
val data = "1a2b3c"
assertEquals('a', data.filterNot { it.isDigit() }.firstOrNull())
assertNull(data.filterNot { it.isJavaLetterOrDigit() }.firstOrNull())
}
test fun partition() {
@test fun partition() {
val data = "a1b2c3"
val pair = data.partition { it.isDigit() }
assertEquals("123", pair.first, "pair.first")
assertEquals("abc", pair.second, "pair.second")
}
test fun map() {
@test fun map() {
assertEquals(arrayListOf('a', 'b', 'c'), "abc".map({ it }))
assertEquals(arrayListOf(true, false, true), "AbC".map({ it.isUpperCase() }))
@@ -154,7 +154,7 @@ class StringJVMTest {
assertEquals(arrayListOf(97, 98, 99), "abc".map({ it.toInt() }))
}
test fun mapTo() {
@test fun mapTo() {
val result1 = arrayListOf<Char>()
val return1 = "abc".mapTo(result1, { it })
assertEquals(result1, return1)
@@ -176,14 +176,14 @@ class StringJVMTest {
assertEquals(arrayListOf(97, 98, 99), result4)
}
test fun flatMap() {
@test fun flatMap() {
val data = "abcd"
val result = data.flatMap { listOf(it) }
assertEquals(data.length(), result.count())
assertEquals(data.toCharList(), result)
}
test fun fold() {
@test fun fold() {
// calculate number of digits in the string
val data = "a1b2c3def"
val result = data.fold(0, { digits, c -> if(c.isDigit()) digits + 1 else digits } )
@@ -196,7 +196,7 @@ class StringJVMTest {
assertEquals(data, data.fold("", { s, c -> s + c }))
}
test fun foldRight() {
@test fun foldRight() {
// calculate number of digits in the string
val data = "a1b2c3def"
val result = data.foldRight(0, { c, digits -> if(c.isDigit()) digits + 1 else digits })
@@ -209,7 +209,7 @@ class StringJVMTest {
assertEquals(data, data.foldRight("", { s, c -> "" + s + c }))
}
test fun reduce() {
@test fun reduce() {
// get the smallest character(by char value)
assertEquals('a', "bacfd".reduce { v, c -> if (v > c) c else v })
@@ -218,7 +218,7 @@ class StringJVMTest {
}
}
test fun reduceRight() {
@test fun reduceRight() {
// get the smallest character(by char value)
assertEquals('a', "bacfd".reduceRight { c, v -> if (v > c) c else v })
@@ -227,7 +227,7 @@ class StringJVMTest {
}
}
test fun groupBy() {
@test fun groupBy() {
// group characters by their case
val data = "abAbaABcD"
val result = data.groupBy { it.isLowerCase() }
@@ -235,7 +235,7 @@ class StringJVMTest {
assertEquals(listOf('a','b','b','a','c'), result.get(true))
}
test fun joinToString() {
@test fun joinToString() {
val data = "abcd".toList()
val result = data.joinToString("_", "(", ")")
assertEquals("(a_b_c_d)", result)
@@ -249,7 +249,7 @@ class StringJVMTest {
assertEquals("A, 1, /, B", result3)
}
test fun join() {
@test fun join() {
val data = "abcd".map { it.toString() }
val result = data.join("_", "(", ")")
assertEquals("(a_b_c_d)", result)
@@ -259,14 +259,14 @@ class StringJVMTest {
assertEquals("[v-e-r-y-l-o-n-g-s-t-r-oops]", result2)
}
test fun dropWhile() {
@test fun dropWhile() {
val data = "ab1cd2"
assertEquals("1cd2", data.dropWhile { it.isJavaLetter() })
assertEquals("", data.dropWhile { true })
assertEquals("ab1cd2", data.dropWhile { false })
}
test fun drop() {
@test fun drop() {
val data = "abcd1234"
assertEquals("d1234", data.drop(3))
fails {
@@ -275,14 +275,14 @@ class StringJVMTest {
assertEquals("", data.drop(data.length() + 5))
}
test fun takeWhile() {
@test fun takeWhile() {
val data = "ab1cd2"
assertEquals("ab", data.takeWhile { it.isJavaLetter() })
assertEquals("", data.takeWhile { false })
assertEquals("ab1cd2", data.takeWhile { true })
}
test fun take() {
@test fun take() {
val data = "abcd1234"
assertEquals("abc", data.take(3))
fails {
@@ -291,7 +291,7 @@ class StringJVMTest {
assertEquals(data, data.take(data.length() + 42))
}
test fun formatter() {
@test fun formatter() {
assertEquals("12", "%d%d".format(1, 2))
assertEquals("1,234,567.890", "%,.3f".format(Locale.ENGLISH, 1234567.890))
@@ -299,14 +299,14 @@ class StringJVMTest {
assertEquals("1 234 567,890", "%,.3f".format(Locale("fr"), 1234567.890))
}
test fun toByteArrayEncodings() {
@test fun toByteArrayEncodings() {
val s = "hello"
val defaultCharset = java.nio.charset.Charset.defaultCharset()!!
assertEquals(String(s.toByteArray()), String(s.toByteArray(defaultCharset)))
assertEquals(String(s.toByteArray()), String(s.toByteArray(defaultCharset.name())))
}
test fun testReplaceAllClosure() {
@test fun testReplaceAllClosure() {
val s = "test123zzz"
val result = s.replace("\\d+".toRegex()) { mr ->
"[" + mr.value + "]"
@@ -314,7 +314,7 @@ class StringJVMTest {
assertEquals("test[123]zzz", result)
}
test fun testReplaceAllClosureAtStart() {
@test fun testReplaceAllClosureAtStart() {
val s = "123zzz"
val result = s.replace("\\d+".toRegex()) { mr ->
"[" + mr.value + "]"
@@ -322,7 +322,7 @@ class StringJVMTest {
assertEquals("[123]zzz", result)
}
test fun testReplaceAllClosureAtEnd() {
@test fun testReplaceAllClosureAtEnd() {
val s = "test123"
val result = s.replace("\\d+".toRegex()) { mr ->
"[" + mr.value + "]"
@@ -330,7 +330,7 @@ class StringJVMTest {
assertEquals("test[123]", result)
}
test fun testReplaceAllClosureEmpty() {
@test fun testReplaceAllClosureEmpty() {
val s = ""
val result = s.replace("\\d+".toRegex()) { mr ->
"x"
@@ -339,7 +339,7 @@ class StringJVMTest {
}
test fun slice() {
@test fun slice() {
val iter = listOf(4, 3, 0, 1)
val builder = StringBuilder()
@@ -360,7 +360,7 @@ class StringJVMTest {
}
test fun orderIgnoringCase() {
@test fun orderIgnoringCase() {
val list = listOf("Beast", "Ast", "asterisk")
assertEquals(listOf("Ast", "Beast", "asterisk"), list.sort())
assertEquals(listOf("Ast", "asterisk", "Beast"), list.sortBy(String.CASE_INSENSITIVE_ORDER))
+44 -44
View File
@@ -11,7 +11,7 @@ class IsEmptyCase(val value: String?, val isNull: Boolean = false, val isEmpty:
class StringTest {
test fun isEmptyAndBlank() {
@test fun isEmptyAndBlank() {
val cases = listOf(
IsEmptyCase(null, isNull = true),
@@ -32,7 +32,7 @@ class StringTest {
}
}
test fun startsWithString() {
@test fun startsWithString() {
assertTrue("abcd".startsWith("ab"))
assertTrue("abcd".startsWith("abcd"))
assertTrue("abcd".startsWith("a"))
@@ -46,7 +46,7 @@ class StringTest {
assertTrue("abcd".startsWith("aB", ignoreCase = true))
}
test fun endsWithString() {
@test fun endsWithString() {
assertTrue("abcd".endsWith("d"))
assertTrue("abcd".endsWith("abcd"))
assertFalse("abcd".endsWith("b"))
@@ -57,7 +57,7 @@ class StringTest {
assertTrue("".endsWith(""))
}
test fun startsWithChar() {
@test fun startsWithChar() {
assertTrue("abcd".startsWith('a'))
assertFalse("abcd".startsWith('b'))
assertFalse("abcd".startsWith('A', ignoreCase = false))
@@ -65,7 +65,7 @@ class StringTest {
assertFalse("".startsWith('a'))
}
test fun endsWithChar() {
@test fun endsWithChar() {
assertTrue("abcd".endsWith('d'))
assertFalse("abcd".endsWith('b'))
assertFalse("strö".endsWith('Ö', ignoreCase = false))
@@ -73,7 +73,7 @@ class StringTest {
assertFalse("".endsWith('a'))
}
test fun commonPrefix() {
@test fun commonPrefix() {
assertEquals("", "".commonPrefixWith(""))
assertEquals("", "any".commonPrefixWith(""))
assertEquals("", "".commonPrefixWith("any"))
@@ -90,7 +90,7 @@ class StringTest {
}
test fun commonSuffix() {
@test fun commonSuffix() {
assertEquals("", "".commonSuffixWith(""))
assertEquals("", "any".commonSuffixWith(""))
assertEquals("", "".commonSuffixWith("any"))
@@ -106,14 +106,14 @@ class StringTest {
assertEquals("$dth54", "d$dth54".commonSuffixWith("s$dth54"))
}
test fun capitalize() {
@test fun capitalize() {
assertEquals("A", "A".capitalize())
assertEquals("A", "a".capitalize())
assertEquals("Abcd", "abcd".capitalize())
assertEquals("Abcd", "Abcd".capitalize())
}
test fun decapitalize() {
@test fun decapitalize() {
assertEquals("a", "A".decapitalize())
assertEquals("a", "a".decapitalize())
assertEquals("abcd", "abcd".decapitalize())
@@ -121,7 +121,7 @@ class StringTest {
assertEquals("uRL", "URL".decapitalize())
}
test fun slice() {
@test fun slice() {
val iter = listOf(4, 3, 0, 1)
// abcde
// 01234
@@ -130,19 +130,19 @@ class StringTest {
assertEquals("edab", "abcde".slice(iter))
}
test fun reverse() {
@test fun reverse() {
assertEquals("dcba", "abcd".reversed())
assertEquals("4321", "1234".reversed())
assertEquals("", "".reversed())
}
test fun indices() {
@test fun indices() {
assertEquals(0..4, "abcde".indices)
assertEquals(0..0, "a".indices)
assertTrue("".indices.isEmpty())
}
test fun replaceRange() {
@test fun replaceRange() {
val s = "sample text"
assertEquals("sa??e text", s.replaceRange(2, 5, "??"))
assertEquals("sa?? text", s.replaceRange(2..5, "??"))
@@ -157,7 +157,7 @@ class StringTest {
assertEquals("??", s.replaceRange(s.indices, "??"))
}
test fun removeRange() {
@test fun removeRange() {
val s = "sample text"
assertEquals("sae text", s.removeRange(2, 5))
assertEquals("sa text", s.removeRange(2..5))
@@ -172,7 +172,7 @@ class StringTest {
assertEquals(s.replaceRange(2..5, ""), s.removeRange(2..5))
}
test fun substringDelimited() {
@test fun substringDelimited() {
val s = "-1,22,3+"
// chars
assertEquals("22,3+", s.substringAfter(','))
@@ -196,7 +196,7 @@ class StringTest {
}
test fun replaceDelimited() {
@test fun replaceDelimited() {
val s = "/user/folder/file.extension"
// chars
assertEquals("/user/folder/file.doc", s.replaceAfter('.', "doc"))
@@ -219,14 +219,14 @@ class StringTest {
assertEquals("xxx", s.replaceBeforeLast("=", "/new/path", "xxx"))
}
test fun stringIterator() {
@test fun stringIterator() {
var sum = 0
for(c in "239")
sum += (c.toInt() - '0'.toInt())
assertTrue(sum == 14)
}
test fun trimStart() {
@test fun trimStart() {
assertEquals("", "".trimStart())
assertEquals("a", "a".trimStart())
assertEquals("a", " a".trimStart())
@@ -245,7 +245,7 @@ class StringTest {
assertEquals("123a", "ab123a".trimStart { it < '0' || it > '9' }) // TODO: Use !it.isDigit when available in JS
}
test fun trimEnd() {
@test fun trimEnd() {
assertEquals("", "".trimEnd())
assertEquals("a", "a".trimEnd())
assertEquals("a", "a ".trimEnd())
@@ -264,7 +264,7 @@ class StringTest {
assertEquals("ab123", "ab123a".trimEnd { it < '0' || it > '9' }) // TODO: Use !it.isDigit when available in JS
}
test fun trimStartAndEnd() {
@test fun trimStartAndEnd() {
val examples = arrayOf("a",
" a ",
" a ",
@@ -293,7 +293,7 @@ class StringTest {
}
}
test fun padStart() {
@test fun padStart() {
assertEquals("s", "s".padStart(0))
assertEquals("s", "s".padStart(1))
assertEquals(" ", "".padStart(2))
@@ -303,7 +303,7 @@ class StringTest {
}
}
test fun padEnd() {
@test fun padEnd() {
assertEquals("s", "s".padEnd(0))
assertEquals("s", "s".padEnd(1))
assertEquals(" ", "".padEnd(2))
@@ -313,21 +313,21 @@ class StringTest {
}
}
test fun removePrefix() {
@test fun removePrefix() {
assertEquals("fix", "prefix".removePrefix("pre"), "Removes prefix")
assertEquals("prefix", "preprefix".removePrefix("pre"), "Removes prefix once")
assertEquals("sample", "sample".removePrefix("value"))
assertEquals("sample", "sample".removePrefix(""))
}
test fun removeSuffix() {
@test fun removeSuffix() {
assertEquals("suf", "suffix".removeSuffix("fix"), "Removes suffix")
assertEquals("suffix", "suffixfix".removeSuffix("fix"), "Removes suffix once")
assertEquals("sample", "sample".removeSuffix("value"))
assertEquals("sample", "sample".removeSuffix(""))
}
test fun removeSurrounding() {
@test fun removeSurrounding() {
assertEquals("value", "<value>".removeSurrounding("<", ">"))
assertEquals("<value>", "<<value>>".removeSurrounding("<", ">"), "Removes surrounding once")
assertEquals("<value", "<value".removeSurrounding("<", ">"), "Only removes surrounding when both prefix and suffix present")
@@ -353,7 +353,7 @@ class StringTest {
*/
test fun split() {
@test fun split() {
assertEquals(listOf(""), "".split(";"))
assertEquals(listOf("test"), "test".split(*charArrayOf()), "empty list of delimiters, none matched -> entire string returned")
assertEquals(listOf("test"), "test".split(*arrayOf<String>()), "empty list of delimiters, none matched -> entire string returned")
@@ -368,7 +368,7 @@ class StringTest {
assertEquals(listOf("", "", "b", "b", "", ""), "abba".split("a", ""))
}
test fun splitToLines() {
@test fun splitToLines() {
val string = "first line\rsecond line\nthird line\r\nlast line"
assertEquals(listOf("first line", "second line", "third line", "last line"), string.lines())
@@ -378,7 +378,7 @@ class StringTest {
}
test fun indexOfAnyChar() {
@test fun indexOfAnyChar() {
val string = "abracadabra"
val chars = charArrayOf('d', 'b')
assertEquals(1, string.indexOfAny(chars))
@@ -392,7 +392,7 @@ class StringTest {
assertEquals(-1, string.indexOfAny(charArrayOf()))
}
test fun indexOfAnyCharIgnoreCase() {
@test fun indexOfAnyCharIgnoreCase() {
val string = "abraCadabra"
val chars = charArrayOf('B', 'c')
assertEquals(1, string.indexOfAny(chars, ignoreCase = true))
@@ -404,7 +404,7 @@ class StringTest {
assertEquals(-1, string.lastIndexOfAny(chars, startIndex = 0, ignoreCase = true))
}
test fun indexOfAnyString() {
@test fun indexOfAnyString() {
val string = "abracadabra"
val substrings = listOf("rac", "ra")
assertEquals(2, string.indexOfAny(substrings))
@@ -421,7 +421,7 @@ class StringTest {
assertEquals(-1, string.indexOfAny(listOf()))
}
test fun indexOfAnyStringIgnoreCase() {
@test fun indexOfAnyStringIgnoreCase() {
val string = "aBraCadaBrA"
val substrings = listOf("rAc", "Ra")
@@ -434,7 +434,7 @@ class StringTest {
assertEquals(-1, string.lastIndexOfAny(substrings, startIndex = 1, ignoreCase = true))
}
test fun findAnyOfStrings() {
@test fun findAnyOfStrings() {
val string = "abracadabra"
val substrings = listOf("rac", "ra")
assertEquals(2 to "rac", string.findAnyOf(substrings))
@@ -451,7 +451,7 @@ class StringTest {
assertEquals(null, string.findAnyOf(listOf()))
}
test fun findAnyOfStringsIgnoreCase() {
@test fun findAnyOfStringsIgnoreCase() {
val string = "aBraCadaBrA"
val substrings = listOf("rAc", "Ra")
@@ -464,7 +464,7 @@ class StringTest {
assertEquals(null, string.findLastAnyOf(substrings, startIndex = 1, ignoreCase = true))
}
test fun indexOfChar() {
@test fun indexOfChar() {
val string = "bcedef"
assertEquals(-1, string.indexOf('a'))
assertEquals(2, string.indexOf('e'))
@@ -480,7 +480,7 @@ class StringTest {
}
test fun indexOfCharIgnoreCase() {
@test fun indexOfCharIgnoreCase() {
val string = "bCEdef"
assertEquals(-1, string.indexOf('a', ignoreCase = true))
assertEquals(2, string.indexOf('E', ignoreCase = true))
@@ -496,7 +496,7 @@ class StringTest {
}
}
test fun indexOfString() {
@test fun indexOfString() {
val string = "bceded"
for (index in string.indices)
assertEquals(index, string.indexOf("", index))
@@ -505,7 +505,7 @@ class StringTest {
assertEquals(-1, string.indexOf("abcdefgh"))
}
test fun indexOfStringIgnoreCase() {
@test fun indexOfStringIgnoreCase() {
val string = "bceded"
for (index in string.indices)
assertEquals(index, string.indexOf("", index, ignoreCase = true))
@@ -515,7 +515,7 @@ class StringTest {
}
test fun contains() {
@test fun contains() {
assertTrue("pl" in "sample")
assertFalse("PL" in "sample")
assertTrue("sömple".contains("Ö", ignoreCase = true))
@@ -528,13 +528,13 @@ class StringTest {
assertTrue("sömple".contains('Ö', ignoreCase = true))
}
test fun equalsIgnoreCase() {
@test fun equalsIgnoreCase() {
assertFalse("sample".equals("Sample", ignoreCase = false))
assertTrue("sample".equals("Sample", ignoreCase = true))
}
test fun replace() {
@test fun replace() {
val input = "abbAb"
assertEquals("abb${'$'}b", input.replace('A', '$'))
assertEquals("/bb/b", input.replace('A', '/', ignoreCase = true))
@@ -545,7 +545,7 @@ class StringTest {
assertEquals("-a-b-b-A-b-", input.replace("", "-"))
}
test fun replaceFirst() {
@test fun replaceFirst() {
val input = "AbbabA"
assertEquals("Abb${'$'}bA", input.replaceFirst('a','$'))
assertEquals("${'$'}bbabA", input.replaceFirst('a','$', ignoreCase = true))
@@ -558,7 +558,7 @@ class StringTest {
assertEquals("-test", "test".replaceFirst("", "-"))
}
test fun trimMargin() {
@test fun trimMargin() {
// WARNING
// DO NOT REFORMAT AS TESTS MAY FAIL DUE TO INDENTATION CHANGE
@@ -605,7 +605,7 @@ class StringTest {
assertEquals("\u0000|ABC", "${"\u0000"}|ABC".trimMargin())
}
test fun trimIndent() {
@test fun trimIndent() {
// WARNING
// DO NOT REFORMAT AS TESTS MAY FAIL DUE TO INDENTATION CHANGE
@@ -669,7 +669,7 @@ ${" "}
assertEquals(1, deindented.lines().count { it.isEmpty() })
}
test fun testIndent() {
@test fun testIndent() {
assertEquals(" ABC\n 123", "ABC\n123".prependIndent(" "))
assertEquals(" ABC\n \n 123", "ABC\n\n123".prependIndent(" "))
assertEquals(" ABC\n \n 123", "ABC\n \n123".prependIndent(" "))
+1 -1
View File
@@ -5,7 +5,7 @@ import kotlin.test.*
import org.junit.Test as test
class StringUtilTest() {
test fun toPattern() {
@test fun toPattern() {
val re = """foo""".toPattern()
val list = re.split("hellofoobar").toList()
assertEquals(listOf("hello", "bar"), list)