35 lines
902 B
Kotlin
35 lines
902 B
Kotlin
package com.infendro.bytes.bytearray
|
|
|
|
import kotlin.test.Test
|
|
import kotlin.test.assertContentEquals
|
|
|
|
class ByteArrayOperatorTest {
|
|
@Test
|
|
fun and() {
|
|
val expected = byteArrayOf(0x18, 0x00)
|
|
val actual = byteArrayOf(0x5C, 0x70) and byteArrayOf(0x3A, 0x0F)
|
|
assertContentEquals(expected, actual)
|
|
}
|
|
|
|
@Test
|
|
fun or() {
|
|
val expected = byteArrayOf(0x7E, 0x7F)
|
|
val actual = byteArrayOf(0x5C, 0x70) or byteArrayOf(0x3A, 0x0F)
|
|
assertContentEquals(expected, actual)
|
|
}
|
|
|
|
@Test
|
|
fun xor() {
|
|
val expected = byteArrayOf(0x66, 0x7F)
|
|
val actual = byteArrayOf(0x5C, 0x70) xor byteArrayOf(0x3A, 0x0F)
|
|
assertContentEquals(expected, actual)
|
|
}
|
|
|
|
@Test
|
|
fun not() {
|
|
val expected = byteArrayOf(-0x01, -0x20)
|
|
val actual = !byteArrayOf(0x00, 0x1F)
|
|
assertContentEquals(expected, actual)
|
|
}
|
|
}
|