FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update ScalaTest and ScalaCheck versions by xerial · Pull Request #554 · msgpack/msgpack-java · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .sbt  (1) .scala  (4) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 2 additions & 2 deletions build.sbt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ lazy val msgpackCore = Project(id = "msgpack-core", base = file("msgpack-core"))
libraryDependencies ++= Seq(
// msgpack-core should have no external dependencies
junitInterface,
"org.scalatest" %% "scalatest" % "3.0.8" % "test",
"org.scalacheck" %% "scalacheck" % "1.14.0" % "test",
"org.scalatest" %% "scalatest" % "3.2.7" % "test",
"org.scalacheck" %% "scalacheck" % "1.15.4" % "test",
"org.xerial" %% "xerial-core" % "3.6.0" % "test",
"org.msgpack" % "msgpack" % "0.6.12" % "test",
"commons-codec" % "commons-codec" % "1.12" % "test",
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
package org.msgpack.core

import java.io.ByteArrayOutputStream

import org.scalatest._
import org.scalatest.prop.PropertyChecks
import org.scalatest.matchers.should.Matchers
import org.scalatest.prop.TableDrivenPropertyChecks
import org.scalatest.wordspec.AnyWordSpec
import xerial.core.log.{LogLevel, Logger}
import xerial.core.util.{TimeReport, Timer}

import scala.language.implicitConversions

trait MessagePackSpec extends WordSpec with Matchers with GivenWhenThen with OptionValues with BeforeAndAfter with PropertyChecks with Benchmark with Logger {
trait MessagePackSpec extends AnyWordSpec with Matchers with GivenWhenThen with OptionValues with BeforeAndAfter with Benchmark with Logger {

implicit def toTag(s: String): Tag = Tag(s)

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import java.io.ByteArrayOutputStream
import java.math.BigInteger
import java.nio.CharBuffer
import java.nio.charset.{CodingErrorAction, UnmappableCharacterException}

import org.msgpack.core.MessagePack.Code
import org.msgpack.core.MessagePack.{UnpackerConfig, PackerConfig}
import org.msgpack.core.MessagePack.{PackerConfig, UnpackerConfig}
import org.msgpack.value.{Value, Variable}
import org.scalacheck.Arbitrary
import org.scalacheck.Prop.{forAll, propBoolean}

import scala.util.Random

Expand Down Expand Up @@ -176,7 +177,7 @@ class MessagePackTest extends MessagePackSpec {
unpack: MessageUnpacker => A,
packerConfig: PackerConfig = new PackerConfig(),
unpackerConfig: UnpackerConfig = new UnpackerConfig()
): Unit = {
): Boolean = {
var b: Array[Byte] = null
try {
val bs = new ByteArrayOutputStream()
Expand All @@ -189,6 +190,7 @@ class MessagePackTest extends MessagePackSpec {
val unpacker = unpackerConfig.newUnpacker(b)
val ret = unpack(unpacker)
ret shouldBe v
true
} catch {
case e: Exception =>
warn(e.getMessage)
Expand Down Expand Up @@ -357,11 +359,9 @@ class MessagePackTest extends MessagePackSpec {
}

"pack/unpack strings" taggedAs ("string") in {

forAll { (v: String) =>
whenever(isValidUTF8(v)) {
check(v, _.packString(v), _.unpackString)
}
val utf8Strings = Arbitrary.arbitrary[String].suchThat(isValidUTF8 _)
utf8Strings.map { v =>
check(v, _.packString(v), _.unpackString)
}
}

Expand Down Expand Up @@ -532,7 +532,7 @@ class MessagePackTest extends MessagePackSpec {
"pack/unpack extension types" taggedAs ("ext") in {
forAll { (dataLen: Int, tpe: Byte) =>
val l = Math.abs(dataLen)
whenever(l >= 0) {
l >= 0 ==> {
val ext =
new ExtensionTypeHeader(ExtensionTypeHeader.checkedCastToByte(tpe), l)
check(ext, _.packExtensionTypeHeader(ext.getType, ext.getLength), _.unpackExtensionTypeHeader())
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.msgpack.value

import org.msgpack.core.MessagePackSpec
import org.scalacheck.Prop.forAll

/**
*
Expand All @@ -34,7 +35,7 @@ class ValueFactoryTest extends MessagePackSpec {
isMap: Boolean = false,
isExtension: Boolean = false,
isRaw: Boolean = false,
isNumber: Boolean = false) {
isNumber: Boolean = false): Boolean = {
v.isNilValue shouldBe isNil
v.isBooleanValue shouldBe isBoolean
v.isIntegerValue shouldBe isInteger
Expand All @@ -46,6 +47,7 @@ class ValueFactoryTest extends MessagePackSpec {
v.isExtensionValue shouldBe isExtension
v.isRawValue shouldBe isRaw
v.isNumberValue shouldBe isNumber
true
}

"ValueFactory" should {
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ package org.msgpack.value

import java.math.BigInteger
import org.msgpack.core._
import org.scalacheck.Prop.{forAll, propBoolean}

import scala.util.parsing.json.JSON

class ValueTest extends MessagePackSpec {
def checkSuccinctType(pack: MessagePacker => Unit, expectedAtMost: MessageFormat) {
def checkSuccinctType(pack: MessagePacker => Unit, expectedAtMost: MessageFormat): Boolean = {
val b = createMessagePackData(pack)
val v1 = MessagePack.newDefaultUnpacker(b).unpackValue()
val mf = v1.asIntegerValue().mostSuccinctMessageFormat()
Expand All @@ -33,6 +34,8 @@ class ValueTest extends MessagePackSpec {
val mf2 = v2.asIntegerValue().mostSuccinctMessageFormat()
mf2.getValueType shouldBe ValueType.INTEGER
mf2.ordinal() shouldBe <=(expectedAtMost.ordinal())

true
}

"Value" should {
Expand All @@ -53,7 +56,7 @@ class ValueTest extends MessagePackSpec {
checkSuccinctType(_.packBigInteger(BigInteger.valueOf(v)), MessageFormat.INT64)
}
forAll { (v: Long) =>
whenever(v > 0) {
v > 0 ==> {
// Create value between 2^63-1 < v <= 2^64-1
checkSuccinctType(_.packBigInteger(BigInteger.valueOf(Long.MaxValue).add(BigInteger.valueOf(v))), MessageFormat.UINT64)
}
Expand Down

Back | FazBrowse Home | New Git URL