add more tests and fixed more glitches
This commit is contained in:
1 parent
2823692b03
commit
d97de2c3ea
5 files changed
+37
-11
No files matched your search
@@ -23,10 +23,10 @@ interface DataSink {
|
||||
for(d in data) writeByte(d)
|
||||
}
|
||||
|
||||
fun writeVarUInt(value: UInt) { Varint.encodeUnsigned(value.toULong())}
|
||||
fun writeVarInt(value: UInt) { Varint.encodeSigned(value.toLong())}
|
||||
fun writeSmartUInt(value: UInt) { Smartint.encodeUnsigned(value.toULong())}
|
||||
fun writeSmartInt(value: UInt) { Smartint.encodeSigned(value.toLong())}
|
||||
fun writeVarUInt(value: UInt) { Varint.encodeUnsigned(value.toULong(), this)}
|
||||
fun writeVarInt(value: UInt) { Varint.encodeSigned(value.toLong(), this)}
|
||||
fun writeSmartUInt(value: UInt) { Smartint.encodeUnsigned(value.toULong(), this)}
|
||||
fun writeSmartInt(value: UInt) { Smartint.encodeSigned(value.toLong(), this)}
|
||||
}
|
||||
|
||||
inline fun <reified T:Any>DataSink.writeNumber(value: T) {
|
||||
|
||||
@@ -112,6 +112,7 @@ fun ByteArray.toDumpLines(wide: Boolean = false): List<String> {
|
||||
}
|
||||
val remainder = from % lineSize
|
||||
if (remainder > 0) {
|
||||
if( remainder < lineSize/2) b.append(' ')
|
||||
var cnt = lineSize - remainder
|
||||
while (cnt-- > 0) b.append(' ')
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class BipackDecoder(val input: DataSource, var elementsCount: Int = 0,val isColl
|
||||
var count = descriptor.elementsCount
|
||||
for (a in descriptor.annotations) {
|
||||
if (a is Extendable)
|
||||
count = source.readSmartUInt().toInt()
|
||||
count = source.readVarUInt().toInt()
|
||||
else if (a is Framed) {
|
||||
val code = CRC.crc32(descriptor.serialName.encodeToByteArray())
|
||||
// if we fail to read CRC, it is IO error, so DataSource.EndOfData will be
|
||||
|
||||
@@ -73,7 +73,7 @@ class BipackEncoder(val output: DataSink) : AbstractEncoder() {
|
||||
CRC.crc32(descriptor.serialName.encodeToByteArray())
|
||||
)
|
||||
} else if (a is Extendable) {
|
||||
sink.writeSmartUInt(descriptor.elementsCount.toUInt())
|
||||
sink.writeVarUInt(descriptor.elementsCount.toUInt())
|
||||
}
|
||||
}
|
||||
return BipackEncoder(sink)
|
||||
|
||||
Reference in new issue
Block a user