diff --git a/src/commonTest/kotlin/BinaryIdTest.kt b/src/commonTest/kotlin/BinaryIdTest.kt index ac8cd42..f6ec93a 100644 --- a/src/commonTest/kotlin/BinaryIdTest.kt +++ b/src/commonTest/kotlin/BinaryIdTest.kt @@ -1,5 +1,11 @@ +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 { @@ -13,4 +19,16 @@ class BinaryIdTest { 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)) + } } \ No newline at end of file