34 lines
1.0 KiB
Kotlin
34 lines
1.0 KiB
Kotlin
import kotlinx.coroutines.test.runTest
|
|
import net.sergeych.bintools.toDump
|
|
import net.sergeych.bipack.BipackEncoder
|
|
import net.sergeych.crypto2.BinaryId
|
|
import net.sergeych.crypto2.ByteChunk
|
|
import net.sergeych.crypto2.initCrypto
|
|
import kotlin.test.Test
|
|
import kotlin.test.assertContentEquals
|
|
import kotlin.test.assertEquals
|
|
|
|
class BinaryIdTest {
|
|
@Test
|
|
fun testSizes() {
|
|
val a = BinaryId.createRandom(5, 4)
|
|
// println(a.id.toDump())
|
|
// println(pack(a).toDump())
|
|
assertEquals(2, a.body.size)
|
|
assertEquals(5, a.magic)
|
|
assertEquals(4, a.id.size)
|
|
|
|
}
|
|
|
|
@Test
|
|
fun testByteChunkSizes() = runTest {
|
|
initCrypto()
|
|
val x = ByteChunk.random(3)
|
|
assertEquals(3, x.data.size)
|
|
assertEquals(3, x.toByteArray().size)
|
|
assertEquals(3, x.toUByteArray().size)
|
|
println(BipackEncoder.encode(x).toDump())
|
|
assertEquals(4, BipackEncoder.encode(x).size)
|
|
assertContentEquals(BipackEncoder.encode(x.toByteArray()), BipackEncoder.encode(x))
|
|
}
|
|
} |