/* * Copyright (c) 2025. Sergey S. Chernov - All Rights Reserved * * You may use, distribute and modify this code under the * terms of the private license, which you must obtain from the author * * To obtain the license, contact the author: https://t.me/real_sergeych or email to * real dot sergeych at gmail. */ 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)) } }