File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
kotlin-codepoints-deluxe/src Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ package de.cketti.codepoints.deluxe
2+
3+ import de.cketti.codepoints.appendCodePoint as intAppendCodePoint
4+
5+ /* *
6+ * Appends the string representation of the [codePoint] argument to this sequence.
7+ *
8+ * The argument is appended to the contents of this sequence.
9+ * The length of this sequence increases by [CodePoint.charCount].
10+ *
11+ * The overall effect is exactly as if the argument were converted to a char array by the function
12+ * [CodePoint.toChars] and the characters in that array were then appended to this sequence.
13+ */
14+ fun StringBuilder.appendCodePoint (codePoint : CodePoint ): StringBuilder = intAppendCodePoint(codePoint.value)
Original file line number Diff line number Diff line change 1+ package de.cketti.codepoints.deluxe
2+
3+ import kotlin.test.assertEquals
4+ import kotlin.test.Test
5+
6+ class StringBuilderExtensionsTest {
7+ @Test
8+ fun appendCodePoint () {
9+ val actual = buildString {
10+ appendCodePoint(' a' .toCodePoint())
11+ append(' b' )
12+ appendCodePoint(' \uFFFF ' .toCodePoint())
13+ append(' c' )
14+ appendCodePoint(" \uD83E\uDD95 " .codePointAt(0 ))
15+ }
16+
17+ assertEquals(" ab\uFFFF c\uD83E\uDD95 " , actual)
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments