21 lines
534 B
Kotlin
21 lines
534 B
Kotlin
package com.infendro.bytes.int
|
|
|
|
import com.infendro.bytes.ByteOrder.LITTLE_ENDIAN
|
|
import kotlin.test.Test
|
|
import kotlin.test.assertContentEquals
|
|
|
|
class IntConversionTest {
|
|
@Test
|
|
fun toByteArray() {
|
|
val expected = byteArrayOf(0x01, 0x23, 0x45, 0x67)
|
|
run {
|
|
val actual = 0x01234567.toByteArray()
|
|
assertContentEquals(expected, actual)
|
|
}
|
|
run {
|
|
val actual = 0x67452301.toByteArray(LITTLE_ENDIAN)
|
|
assertContentEquals(expected, actual)
|
|
}
|
|
}
|
|
}
|