KT-20357: Add samples for indexOf

This commit is contained in:
Burak Eregar
2019-01-02 21:46:35 +00:00
committed by Ilya Gorbunov
parent a6f829f267
commit e30d87ee01
2 changed files with 14 additions and 0 deletions
@@ -204,6 +204,7 @@ class Strings {
val noPadding = "abcde".padEnd(3)
assertPrints("'$noPadding'", "'abcde'")
}
@Sample
fun clearStringBuilder() {
val builder = StringBuilder()
@@ -357,4 +358,15 @@ class Strings {
assertPrints(string.map { it.toUpperCase() }, "[K, O, T, L, I, N]")
}
@Sample
fun indexOf() {
fun getSubstringDetails(str: String, toFind: String): String {
return "Found $toFind in $str at position ${str.indexOf(toFind)}"
}
val str = "Kotlin"
val toFind = "otli"
assertPrints(getSubstringDetails(str, toFind), "Found otli in Kotlin at position 1")
}
}