Skip to content

Commit f8544b5

Browse files
committed
Add test to make sure the bug in buffer does not appear in v0.7
1 parent ee9860e commit f8544b5

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

msgpack-core/src/test/scala/org/msgpack/core/MessageUnpackerTest.scala

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class MessageUnpackerTest extends MessagePackSpec {
149149
val mapLen = unpacker.unpackMapHeader()
150150
debug(s"map size: $mapLen")
151151
case ValueType.INTEGER =>
152-
val i = unpacker.unpackInt()
152+
val i = unpacker.unpackLong()
153153
debug(s"int value: $i")
154154
case ValueType.STRING =>
155155
val s = unpacker.unpackString()
@@ -301,6 +301,24 @@ class MessageUnpackerTest extends MessagePackSpec {
301301

302302
}
303303

304+
"read numeric data at buffer boundary" taggedAs("boundary2") in {
305+
val out = new ByteArrayOutputStream
306+
val packer = MessagePack.newDefaultPacker(out)
307+
(0 until 1170).foreach{i =>
308+
packer.packLong(0x0011223344556677L)
309+
packer.packString("hello")
310+
}
311+
packer.close
312+
val data = out.toByteArray
313+
314+
val unpacker = new MessageUnpacker(new InputStreamBufferInput(new ByteArrayInputStream(data), 8192))
315+
(0 until 1170).foreach { i =>
316+
unpacker.unpackLong() shouldBe 0x0011223344556677L
317+
unpacker.unpackString() shouldBe "hello"
318+
}
319+
unpacker.close()
320+
}
321+
304322
"be faster then msgpack-v6 skip" taggedAs ("cmp-skip") in {
305323

306324
val data = testData3(10000)

0 commit comments

Comments
 (0)