Add samples for joinToString
KT-20357
This commit is contained in:
@@ -311,6 +311,17 @@ class Collections {
|
||||
assertPrints(moreFrequencies, "{o=1, t=4, f=2, s=2, e=2, n=1}")
|
||||
}
|
||||
|
||||
@Sample
|
||||
fun joinToString() {
|
||||
val numbers = listOf(1, 2, 3, 4, 5, 6)
|
||||
assertPrints(numbers.joinToString(), "1, 2, 3, 4, 5, 6")
|
||||
assertPrints(numbers.joinToString(prefix = "[", postfix = "]"), "[1, 2, 3, 4, 5, 6]")
|
||||
assertPrints(numbers.joinToString(prefix = "<", postfix = ">", separator = "•"), "<1•2•3•4•5•6>")
|
||||
|
||||
val chars = charArrayOf('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q')
|
||||
assertPrints(chars.joinToString(limit = 5, truncated = "...!") { it.toUpperCase().toString() }, "A, B, C, D, E, ...!")
|
||||
}
|
||||
|
||||
@Sample
|
||||
fun chunked() {
|
||||
val words = "one two three four five six seven eight nine ten".split(' ')
|
||||
|
||||
Reference in New Issue
Block a user