All checks were successful
/ test (pull_request) Successful in 2m47s
It turns out signed math is more performant
22 lines
628 B
Kotlin
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)
|
|
}
|
|
}
|