Files
bytes.kt/src/commonTest/kotlin/com/infendro/bytes/ubytearray/String.kt
Infendro ff0e17b5ad
All checks were successful
/ test (pull_request) Successful in 2m47s
switch to signed-first approach
It turns out signed math is more performant
2026-01-15 14:10:14 +01:00

22 lines
628 B
Kotlin

package com.infendro.bytes.ubytearray
import kotlin.test.Test
import kotlin.test.assertContentEquals
import kotlin.test.assertEquals
class UByteArrayStringTest {
@Test
fun encodeToUByteArray() {
val expected = ubyteArrayOf(0x50U, 0x41U, 0x53U, 0x53U, 0x57U, 0x4FU, 0x52U, 0x44U)
val actual = "PASSWORD".encodeToUByteArray()
assertContentEquals(expected, actual)
}
@Test
fun decodeToString() {
val expected = "PASSWORD"
val actual = ubyteArrayOf(0x50U, 0x41U, 0x53U, 0x53U, 0x57U, 0x4FU, 0x52U, 0x44U).decodeToString()
assertEquals(expected, actual)
}
}