Files
bytes.kt/src/commonTest/kotlin/com/infendro/bytes/long/Conversion.kt
2026-02-05 14:19:51 +01:00

21 lines
585 B
Kotlin

package com.infendro.bytes.long
import com.infendro.bytes.ByteOrder.LITTLE_ENDIAN
import kotlin.test.Test
import kotlin.test.assertContentEquals
class LongConversionTest {
@Test
fun toByteArray() {
val expected = byteArrayOf(0x01, 0x23, 0x45, 0x67, -0x77, -0x55, -0x33, -0x11)
run {
val actual = 0x0123456789abcdefL.toByteArray()
assertContentEquals(expected, actual)
}
run {
val actual = (-0x1032547698badcffL).toByteArray(LITTLE_ENDIAN)
assertContentEquals(expected, actual)
}
}
}