Files
kotlin-fork/libraries/stdlib/test/text/StringBuilderJVMTest.kt
T
Laszlo Hornyak 6fda0816f3 buildString with initial capacity for the StringBuilder instance
this method helps save computation time when the developer knows or have a good
educated guess about the size of the generated string and have to use control
structures while filling the string builder

Signed-off-by: Laszlo Hornyak <laszlo.hornyak@gmail.com>

Signed-off-by: Laszlo Hornyak <laszlo.hornyak@gmail.com>
2016-08-10 18:23:32 +03:00

23 lines
437 B
Kotlin

package test.text
import kotlin.*
import kotlin.test.*
import org.junit.Test as test
class StringBuilderJVMTest() {
@test fun stringBuildWithInitialCapacity() {
val s = buildString(123) {
assertEquals(123, capacity())
}
}
@test fun getAndSetChar() {
val sb = StringBuilder("abc")
sb[1] = 'z'
assertEquals("azc", sb.toString())
assertEquals('c', sb[2])
}
}