@@ -19,10 +19,11 @@ import java.io.ByteArrayOutputStream
1919import java .math .BigInteger
2020import java .nio .CharBuffer
2121import java .nio .charset .{CodingErrorAction , UnmappableCharacterException }
22-
2322import org .msgpack .core .MessagePack .Code
24- import org .msgpack .core .MessagePack .{UnpackerConfig , PackerConfig }
23+ import org .msgpack .core .MessagePack .{PackerConfig , UnpackerConfig }
2524import org .msgpack .value .{Value , Variable }
25+ import org .scalacheck .Arbitrary
26+ import org .scalacheck .Prop .{forAll , propBoolean }
2627
2728import scala .util .Random
2829
@@ -176,7 +177,7 @@ class MessagePackTest extends MessagePackSpec {
176177 unpack : MessageUnpacker => A ,
177178 packerConfig : PackerConfig = new PackerConfig (),
178179 unpackerConfig : UnpackerConfig = new UnpackerConfig ()
179- ): Unit = {
180+ ): Boolean = {
180181 var b : Array [Byte ] = null
181182 try {
182183 val bs = new ByteArrayOutputStream ()
@@ -189,6 +190,7 @@ class MessagePackTest extends MessagePackSpec {
189190 val unpacker = unpackerConfig.newUnpacker(b)
190191 val ret = unpack(unpacker)
191192 ret shouldBe v
193+ true
192194 } catch {
193195 case e : Exception =>
194196 warn(e.getMessage)
@@ -357,11 +359,9 @@ class MessagePackTest extends MessagePackSpec {
357359 }
358360
359361 " pack/unpack strings" taggedAs (" string" ) in {
360-
361- forAll { (v : String ) =>
362- whenever(isValidUTF8(v)) {
363- check(v, _.packString(v), _.unpackString)
364- }
362+ val utf8Strings = Arbitrary .arbitrary[String ].suchThat(isValidUTF8 _)
363+ utf8Strings.map { v =>
364+ check(v, _.packString(v), _.unpackString)
365365 }
366366 }
367367
@@ -532,7 +532,7 @@ class MessagePackTest extends MessagePackSpec {
532532 " pack/unpack extension types" taggedAs (" ext" ) in {
533533 forAll { (dataLen : Int , tpe : Byte ) =>
534534 val l = Math .abs(dataLen)
535- whenever( l >= 0 ) {
535+ l >= 0 ==> {
536536 val ext =
537537 new ExtensionTypeHeader (ExtensionTypeHeader .checkedCastToByte(tpe), l)
538538 check(ext, _.packExtensionTypeHeader(ext.getType, ext.getLength), _.unpackExtensionTypeHeader())
0 commit comments