ref #35 bitwise pack/unpack for integers

This commit is contained in:
sergeych committed 2025-07-11 06:09:09 +03:00
1 parent 987b80e44d
commit d969993997
3 files changed
+27 -4

No files matched your search

+16 -3
View File
@@ -37,13 +37,26 @@ class LynonTests {
}
@Test
fun testPackInteger() {
fun testUnsignedPackInteger() {
val bout = MemoryBitOutput()
bout.packUnsigned(147179UL)
bout.packUnsigned(1471792UL)
bout.close()
println(bout.toUByteArray().toDump())
val bin = MemoryBitInput(bout.toUByteArray())
assertEquals(147179UL, bin.unpackUnsigned())
assertEquals(1471792UL, bin.unpackUnsigned())
}
@Test
fun testSignedPackInteger() {
val bout = MemoryBitOutput()
bout.packSigned(-1471792L)
bout.packSigned(1471792L)
// bout.packSigned(147179L)
bout.close()
println(bout.toUByteArray().toDump())
val bin = MemoryBitInput(bout.toUByteArray())
assertEquals(-1471792L, bin.unpackSigned())
assertEquals(1471792L, bin.unpackSigned())
}
}