Skip to content

Commit b1e30b2

Browse files
committed
added test code for PackerConfig and UnpackerConfig
1 parent 61184bf commit b1e30b2

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

msgpack-core/src/main/java/org/msgpack/core/MessagePack.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,6 @@ public static class UnpackerConfig
380380

381381
private int bufferSize = 8192;
382382

383-
/**
384-
*
385-
*/
386383
private int stringDecoderBufferSize = 8192;
387384

388385
public UnpackerConfig()
@@ -416,6 +413,7 @@ public boolean equals(Object obj)
416413
&& this.actionOnMalformedString == o.actionOnMalformedString
417414
&& this.actionOnUnmappableString == o.actionOnUnmappableString
418415
&& this.stringSizeLimit == o.stringSizeLimit
416+
&& this.stringDecoderBufferSize == o.stringDecoderBufferSize
419417
&& this.bufferSize == o.bufferSize;
420418
}
421419

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

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class MessagePackTest extends MessagePackSpec {
4747
}
4848
}
4949

50-
5150
"MessagePack" should {
5251
"detect fixint values" in {
5352

@@ -498,4 +497,42 @@ class MessagePackTest extends MessagePackSpec {
498497
}
499498

500499
}
500+
501+
"MessagePack.PackerConfig" should {
502+
"be immutable" in {
503+
val a = new MessagePack.PackerConfig()
504+
val b = a.withBufferSize(64*1024)
505+
a.equals(b) shouldBe false
506+
}
507+
508+
"implement equals" in {
509+
val a = new MessagePack.PackerConfig()
510+
val b = new MessagePack.PackerConfig()
511+
a.equals(b) shouldBe true
512+
a.withBufferSize(64*1024).equals(b) shouldBe false
513+
a.withSmallStringOptimizationThreshold(64).equals(b) shouldBe false
514+
a.withBufferFlushThreshold(64*1024).equals(b) shouldBe false
515+
}
516+
}
517+
518+
"MessagePack.UnpackerConfig" should {
519+
"be immutable" in {
520+
val a = new MessagePack.UnpackerConfig()
521+
val b = a.withBufferSize(64*1024)
522+
a.equals(b) shouldBe false
523+
}
524+
525+
"implement equals" in {
526+
val a = new MessagePack.UnpackerConfig()
527+
val b = new MessagePack.UnpackerConfig()
528+
a.equals(b) shouldBe true
529+
a.withBufferSize(64*1024).equals(b) shouldBe false
530+
a.withAllowReadingStringAsBinary(false).equals(b) shouldBe false
531+
a.withAllowReadingBinaryAsString(false).equals(b) shouldBe false
532+
a.withActionOnMalformedString(CodingErrorAction.REPORT).equals(b) shouldBe false
533+
a.withActionOnUnmappableString(CodingErrorAction.REPORT).equals(b) shouldBe false
534+
a.withStringSizeLimit(32).equals(b) shouldBe false
535+
a.withStringDecoderBufferSize(32).equals(b) shouldBe false
536+
}
537+
}
501538
}

0 commit comments

Comments
 (0)