KT-20357 Add samples for padStart() and padEnd()

This commit is contained in:
Gen
2018-08-06 23:38:19 +09:00
committed by Ilya Gorbunov
parent 36a99da820
commit a90b72ffd8
2 changed files with 21 additions and 2 deletions
@@ -1,8 +1,6 @@
package samples.text
import samples.*
import kotlin.test.*
import java.util.*
class Strings {
@@ -104,4 +102,21 @@ class Strings {
assertPrints("Iced frappé!".toUpperCase(), "ICED FRAPPÉ!")
}
@Sample
fun padStart() {
val padWithSpace = "a".padStart(3)
assertPrints("'$padWithSpace'", "' a'")
val padWithChar = "a".padStart(3, '#')
assertPrints("'$padWithChar'", "'##a'")
}
@Sample
fun padEnd() {
val padWithSpace = "a".padEnd(3)
assertPrints("'$padWithSpace'", "'a '")
val padWithChar = "a".padEnd(3, '#')
assertPrints("'$padWithChar'", "'a##'")
}
}