Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Split test case for redability
  • Loading branch information
xerial committed Apr 8, 2016
commit dfcf588e08891230be8a266a2e66ebf4affc3384
Original file line number Diff line number Diff line change
Expand Up @@ -295,26 +295,26 @@ class MessagePackerTest extends MessagePackSpec {

"be able to disable STR8 for backward compatibility" in {
val config = new PackerConfig()
.withSmallStringOptimizationThreshold(0) // Disable small string optimiztion
.withStr8FormatSupport(false)

{
val packer = config.newBufferPacker()
packer.packString("Hello. This is a string longer than 32 characters!")
val unpacker = MessagePack.newDefaultUnpacker(packer.toByteArray)
val f = unpacker.getNextFormat
f shouldBe MessageFormat.STR16
}
val packer = config.newBufferPacker()
packer.packString("Hello. This is a string longer than 32 characters!")
val unpacker = MessagePack.newDefaultUnpacker(packer.toByteArray)
val f = unpacker.getNextFormat
f shouldBe MessageFormat.STR16
}

{
val packer2 = config.newBufferPacker()
packer2.packString("small string")
packer2.flush()
val unpacker2 = MessagePack.newDefaultUnpacker(packer2.toByteArray)
val f2 = unpacker2.getNextFormat
f2 shouldNot be (MessageFormat.STR8)
val s = unpacker2.unpackString()
s shouldBe "small string"
}
"be able to disable STR8 when using CharsetEncoder" in {
val config = new PackerConfig()
.withStr8FormatSupport(false)
.withSmallStringOptimizationThreshold(0) // Disable small string optimization

val packer = config.newBufferPacker()
packer.packString("small string")
val unpacker = MessagePack.newDefaultUnpacker(packer.toByteArray)
val f = unpacker.getNextFormat
f shouldNot be (MessageFormat.STR8)
val s = unpacker.unpackString()
s shouldBe "small string"
}
}