From 242cc7d0f5e519ec96baee51bd80cc8e824f0fbc Mon Sep 17 00:00:00 2001 From: sergeych Date: Fri, 29 Nov 2024 15:42:54 +0700 Subject: [PATCH] more tests --- src/commonTest/kotlin/BinaryIdTest.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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