Files
bytes.kt/src/commonTest/kotlin/com/infendro/bytearray/ULong.kt
2025-12-01 16:24:58 +01:00

32 lines
945 B
Kotlin

package com.infendro.bytearray
import com.infendro.bytearray.ByteOrder.LITTLE_ENDIAN
import kotlin.test.Test
import kotlin.test.assertContentEquals
class `ULong Test` {
@Test
fun `toByteArray()`() {
assertContentEquals(
byteArrayOf(0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78),
0x1234567812345678UL.toByteArray()
)
assertContentEquals(
byteArrayOf(0x78, 0x56, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12),
0x1234567812345678UL.toByteArray(LITTLE_ENDIAN)
)
}
@Test
fun `toUByteArray()`() {
assertContentEquals(
ubyteArrayOf(0x12U, 0x34U, 0x56U, 0x78U, 0x12U, 0x34U, 0x56U, 0x78U),
0x1234567812345678UL.toUByteArray()
)
assertContentEquals(
ubyteArrayOf(0x78U, 0x56U, 0x34U, 0x12U, 0x78U, 0x56U, 0x34U, 0x12U),
0x1234567812345678UL.toUByteArray(LITTLE_ENDIAN)
)
}
}