24 lines
659 B
Kotlin
24 lines
659 B
Kotlin
package com.infendro.bytes.intarray
|
|
|
|
import com.infendro.bytes.ByteOrder.LITTLE_ENDIAN
|
|
import kotlin.test.Test
|
|
import kotlin.test.assertContentEquals
|
|
|
|
class IntArrayConversionTest {
|
|
@Test
|
|
fun toByteArray() {
|
|
val expected = byteArrayOf(
|
|
0x01, 0x23, 0x45, 0x67,
|
|
0x67, 0x45, 0x23, 0x01,
|
|
)
|
|
run {
|
|
val actual = intArrayOf(0x01234567, 0x67452301).toByteArray()
|
|
assertContentEquals(expected, actual)
|
|
}
|
|
run {
|
|
val actual = intArrayOf(0x67452301, 0x01234567).toByteArray(order = LITTLE_ENDIAN)
|
|
assertContentEquals(expected, actual)
|
|
}
|
|
}
|
|
}
|