replace unicode arrows
* ⇒, →, ← * because we don't want to show them in documentation snippets and then it's complicated to avoid that when snippets are located in src/test/scala in individual modules * dont replace object `→` in FSM.scala and PersistentFSM.scala
This commit is contained in:
parent
e4d38f92a4
commit
5c96a5f556
1521 changed files with 18846 additions and 18786 deletions
|
|
@ -24,17 +24,17 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
implicit val betterGeneratorDrivenConfig = PropertyCheckConfig().copy(minSuccessful = 1000)
|
||||
|
||||
def genSimpleByteString(min: Int, max: Int) = for {
|
||||
n ← Gen.choose(min, max)
|
||||
b ← Gen.containerOfN[Array, Byte](n, arbitrary[Byte])
|
||||
from ← Gen.choose(0, b.length)
|
||||
until ← Gen.choose(from, from max b.length)
|
||||
n <- Gen.choose(min, max)
|
||||
b <- Gen.containerOfN[Array, Byte](n, arbitrary[Byte])
|
||||
from <- Gen.choose(0, b.length)
|
||||
until <- Gen.choose(from, from max b.length)
|
||||
} yield ByteString(b).slice(from, until)
|
||||
|
||||
implicit val arbitraryByteString: Arbitrary[ByteString] = Arbitrary {
|
||||
Gen.sized { s ⇒
|
||||
Gen.sized { s =>
|
||||
for {
|
||||
chunks ← Gen.choose(0, s)
|
||||
bytes ← Gen.listOfN(chunks, genSimpleByteString(1, 1 max (s / (chunks max 1))))
|
||||
chunks <- Gen.choose(0, s)
|
||||
bytes <- Gen.listOfN(chunks, genSimpleByteString(1, 1 max (s / (chunks max 1))))
|
||||
} yield bytes.foldLeft(ByteString.empty)(_ ++ _)
|
||||
}
|
||||
}
|
||||
|
|
@ -43,9 +43,9 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
|
||||
implicit val arbitraryByteStringSlice: Arbitrary[ByteStringSlice] = Arbitrary {
|
||||
for {
|
||||
xs ← arbitraryByteString.arbitrary
|
||||
from ← Gen.choose(0, 0 max (xs.length - 1))
|
||||
until ← {
|
||||
xs <- arbitraryByteString.arbitrary
|
||||
from <- Gen.choose(0, 0 max (xs.length - 1))
|
||||
until <- {
|
||||
require(from <= xs.length)
|
||||
Gen.choose(from, xs.length)
|
||||
}
|
||||
|
|
@ -56,8 +56,8 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
|
||||
implicit val arbitraryByteStringGrouped = Arbitrary {
|
||||
for {
|
||||
xs ← arbitraryByteString.arbitrary
|
||||
size ← Gen.choose(1, 1 max xs.length)
|
||||
xs <- arbitraryByteString.arbitrary
|
||||
size <- Gen.choose(1, 1 max xs.length)
|
||||
} yield ByteStringGrouped(xs, size)
|
||||
}
|
||||
|
||||
|
|
@ -65,9 +65,9 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
|
||||
def arbSlice[A](arbArray: Arbitrary[Array[A]]): Arbitrary[ArraySlice[A]] = Arbitrary {
|
||||
for {
|
||||
xs ← arbArray.arbitrary
|
||||
from ← Gen.choose(0, xs.length)
|
||||
until ← Gen.choose(from, xs.length)
|
||||
xs <- arbArray.arbitrary
|
||||
from <- Gen.choose(0, xs.length)
|
||||
until <- Gen.choose(from, xs.length)
|
||||
} yield (xs, from, until)
|
||||
}
|
||||
|
||||
|
|
@ -95,58 +95,58 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
String valueOf encodeHex(os.toByteArray)
|
||||
}
|
||||
|
||||
val arbitraryByteArray: Arbitrary[Array[Byte]] = Arbitrary { Gen.sized { n ⇒ Gen.containerOfN[Array, Byte](n, arbitrary[Byte]) } }
|
||||
val arbitraryByteArray: Arbitrary[Array[Byte]] = Arbitrary { Gen.sized { n => Gen.containerOfN[Array, Byte](n, arbitrary[Byte]) } }
|
||||
implicit val arbitraryByteArraySlice: Arbitrary[ArraySlice[Byte]] = arbSlice(arbitraryByteArray)
|
||||
val arbitraryShortArray: Arbitrary[Array[Short]] = Arbitrary { Gen.sized { n ⇒ Gen.containerOfN[Array, Short](n, arbitrary[Short]) } }
|
||||
val arbitraryShortArray: Arbitrary[Array[Short]] = Arbitrary { Gen.sized { n => Gen.containerOfN[Array, Short](n, arbitrary[Short]) } }
|
||||
implicit val arbitraryShortArraySlice: Arbitrary[ArraySlice[Short]] = arbSlice(arbitraryShortArray)
|
||||
val arbitraryIntArray: Arbitrary[Array[Int]] = Arbitrary { Gen.sized { n ⇒ Gen.containerOfN[Array, Int](n, arbitrary[Int]) } }
|
||||
val arbitraryIntArray: Arbitrary[Array[Int]] = Arbitrary { Gen.sized { n => Gen.containerOfN[Array, Int](n, arbitrary[Int]) } }
|
||||
implicit val arbitraryIntArraySlice: Arbitrary[ArraySlice[Int]] = arbSlice(arbitraryIntArray)
|
||||
val arbitraryLongArray: Arbitrary[Array[Long]] = Arbitrary { Gen.sized { n ⇒ Gen.containerOfN[Array, Long](n, arbitrary[Long]) } }
|
||||
val arbitraryLongArray: Arbitrary[Array[Long]] = Arbitrary { Gen.sized { n => Gen.containerOfN[Array, Long](n, arbitrary[Long]) } }
|
||||
implicit val arbitraryLongArraySlice: Arbitrary[ArraySlice[Long]] = arbSlice(arbitraryLongArray)
|
||||
val arbitraryFloatArray: Arbitrary[Array[Float]] = Arbitrary { Gen.sized { n ⇒ Gen.containerOfN[Array, Float](n, arbitrary[Float]) } }
|
||||
val arbitraryFloatArray: Arbitrary[Array[Float]] = Arbitrary { Gen.sized { n => Gen.containerOfN[Array, Float](n, arbitrary[Float]) } }
|
||||
implicit val arbitraryFloatArraySlice: Arbitrary[ArraySlice[Float]] = arbSlice(arbitraryFloatArray)
|
||||
val arbitraryDoubleArray: Arbitrary[Array[Double]] = Arbitrary { Gen.sized { n ⇒ Gen.containerOfN[Array, Double](n, arbitrary[Double]) } }
|
||||
val arbitraryDoubleArray: Arbitrary[Array[Double]] = Arbitrary { Gen.sized { n => Gen.containerOfN[Array, Double](n, arbitrary[Double]) } }
|
||||
implicit val arbitraryDoubleArraySlice: Arbitrary[ArraySlice[Double]] = arbSlice(arbitraryDoubleArray)
|
||||
|
||||
type ArrayNumBytes[A] = (Array[A], Int)
|
||||
|
||||
implicit val arbitraryLongArrayNumBytes: Arbitrary[ArrayNumBytes[Long]] = Arbitrary {
|
||||
for {
|
||||
xs ← arbitraryLongArray.arbitrary
|
||||
from ← Gen.choose(0, xs.length)
|
||||
until ← Gen.choose(from, xs.length)
|
||||
bytes ← Gen.choose(0, 8)
|
||||
xs <- arbitraryLongArray.arbitrary
|
||||
from <- Gen.choose(0, xs.length)
|
||||
until <- Gen.choose(from, xs.length)
|
||||
bytes <- Gen.choose(0, 8)
|
||||
} yield (xs.slice(from, until), bytes)
|
||||
}
|
||||
|
||||
implicit val arbitraryByteStringBuilder: Arbitrary[ByteStringBuilder] = Arbitrary(ByteString.newBuilder)
|
||||
|
||||
def likeVector(bs: ByteString)(body: IndexedSeq[Byte] ⇒ Any): Boolean = {
|
||||
def likeVector(bs: ByteString)(body: IndexedSeq[Byte] => Any): Boolean = {
|
||||
val vec = Vector(bs: _*)
|
||||
body(bs) == body(vec)
|
||||
}
|
||||
|
||||
def likeVectors(bsA: ByteString, bsB: ByteString)(body: (IndexedSeq[Byte], IndexedSeq[Byte]) ⇒ Any): Boolean = {
|
||||
def likeVectors(bsA: ByteString, bsB: ByteString)(body: (IndexedSeq[Byte], IndexedSeq[Byte]) => Any): Boolean = {
|
||||
val vecA = Vector(bsA: _*)
|
||||
val vecB = Vector(bsB: _*)
|
||||
body(bsA, bsB) == body(vecA, vecB)
|
||||
}
|
||||
|
||||
def likeVecIt(bs: ByteString)(body: BufferedIterator[Byte] ⇒ Any, strict: Boolean = true): Boolean = {
|
||||
def likeVecIt(bs: ByteString)(body: BufferedIterator[Byte] => Any, strict: Boolean = true): Boolean = {
|
||||
val bsIterator = bs.iterator
|
||||
val vecIterator = Vector(bs: _*).iterator.buffered
|
||||
(body(bsIterator) == body(vecIterator)) &&
|
||||
(!strict || (bsIterator.toSeq == vecIterator.toSeq))
|
||||
}
|
||||
|
||||
def likeVecIts(a: ByteString, b: ByteString)(body: (BufferedIterator[Byte], BufferedIterator[Byte]) ⇒ Any, strict: Boolean = true): Boolean = {
|
||||
def likeVecIts(a: ByteString, b: ByteString)(body: (BufferedIterator[Byte], BufferedIterator[Byte]) => Any, strict: Boolean = true): Boolean = {
|
||||
val (bsAIt, bsBIt) = (a.iterator, b.iterator)
|
||||
val (vecAIt, vecBIt) = (Vector(a: _*).iterator.buffered, Vector(b: _*).iterator.buffered)
|
||||
(body(bsAIt, bsBIt) == body(vecAIt, vecBIt)) &&
|
||||
(!strict || (bsAIt.toSeq → bsBIt.toSeq) == (vecAIt.toSeq → vecBIt.toSeq))
|
||||
(!strict || (bsAIt.toSeq -> bsBIt.toSeq) == (vecAIt.toSeq -> vecBIt.toSeq))
|
||||
}
|
||||
|
||||
def likeVecBld(body: Builder[Byte, _] ⇒ Unit): Boolean = {
|
||||
def likeVecBld(body: Builder[Byte, _] => Unit): Boolean = {
|
||||
val bsBuilder = ByteString.newBuilder
|
||||
val vecBuilder = Vector.newBuilder[Byte]
|
||||
|
||||
|
|
@ -164,9 +164,9 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
bytes.asByteBuffer.order(byteOrder).asShortBuffer.get(reference, 0, n)
|
||||
val input = bytes.iterator
|
||||
val decoded = new Array[Short](n)
|
||||
for (i ← 0 until a) decoded(i) = input.getShort(byteOrder)
|
||||
for (i <- 0 until a) decoded(i) = input.getShort(byteOrder)
|
||||
input.getShorts(decoded, a, b - a)(byteOrder)
|
||||
for (i ← b until n) decoded(i) = input.getShort(byteOrder)
|
||||
for (i <- b until n) decoded(i) = input.getShort(byteOrder)
|
||||
(decoded.toSeq == reference.toSeq) && (input.toSeq == bytes.drop(n * elemSize))
|
||||
}
|
||||
|
||||
|
|
@ -178,9 +178,9 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
bytes.asByteBuffer.order(byteOrder).asIntBuffer.get(reference, 0, n)
|
||||
val input = bytes.iterator
|
||||
val decoded = new Array[Int](n)
|
||||
for (i ← 0 until a) decoded(i) = input.getInt(byteOrder)
|
||||
for (i <- 0 until a) decoded(i) = input.getInt(byteOrder)
|
||||
input.getInts(decoded, a, b - a)(byteOrder)
|
||||
for (i ← b until n) decoded(i) = input.getInt(byteOrder)
|
||||
for (i <- b until n) decoded(i) = input.getInt(byteOrder)
|
||||
(decoded.toSeq == reference.toSeq) && (input.toSeq == bytes.drop(n * elemSize))
|
||||
}
|
||||
|
||||
|
|
@ -192,9 +192,9 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
bytes.asByteBuffer.order(byteOrder).asLongBuffer.get(reference, 0, n)
|
||||
val input = bytes.iterator
|
||||
val decoded = new Array[Long](n)
|
||||
for (i ← 0 until a) decoded(i) = input.getLong(byteOrder)
|
||||
for (i <- 0 until a) decoded(i) = input.getLong(byteOrder)
|
||||
input.getLongs(decoded, a, b - a)(byteOrder)
|
||||
for (i ← b until n) decoded(i) = input.getLong(byteOrder)
|
||||
for (i <- b until n) decoded(i) = input.getLong(byteOrder)
|
||||
(decoded.toSeq == reference.toSeq) && (input.toSeq == bytes.drop(n * elemSize))
|
||||
}
|
||||
|
||||
|
|
@ -206,9 +206,9 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
bytes.asByteBuffer.order(byteOrder).asFloatBuffer.get(reference, 0, n)
|
||||
val input = bytes.iterator
|
||||
val decoded = new Array[Float](n)
|
||||
for (i ← 0 until a) decoded(i) = input.getFloat(byteOrder)
|
||||
for (i <- 0 until a) decoded(i) = input.getFloat(byteOrder)
|
||||
input.getFloats(decoded, a, b - a)(byteOrder)
|
||||
for (i ← b until n) decoded(i) = input.getFloat(byteOrder)
|
||||
for (i <- b until n) decoded(i) = input.getFloat(byteOrder)
|
||||
((decoded.toSeq map floatToRawIntBits) == (reference.toSeq map floatToRawIntBits)) &&
|
||||
(input.toSeq == bytes.drop(n * elemSize))
|
||||
}
|
||||
|
|
@ -221,9 +221,9 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
bytes.asByteBuffer.order(byteOrder).asDoubleBuffer.get(reference, 0, n)
|
||||
val input = bytes.iterator
|
||||
val decoded = new Array[Double](n)
|
||||
for (i ← 0 until a) decoded(i) = input.getDouble(byteOrder)
|
||||
for (i <- 0 until a) decoded(i) = input.getDouble(byteOrder)
|
||||
input.getDoubles(decoded, a, b - a)(byteOrder)
|
||||
for (i ← b until n) decoded(i) = input.getDouble(byteOrder)
|
||||
for (i <- b until n) decoded(i) = input.getDouble(byteOrder)
|
||||
((decoded.toSeq map doubleToRawLongBits) == (reference.toSeq map doubleToRawLongBits)) &&
|
||||
(input.toSeq == bytes.drop(n * elemSize))
|
||||
}
|
||||
|
|
@ -234,9 +234,9 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
val reference = new Array[Byte](data.length * elemSize)
|
||||
ByteBuffer.wrap(reference).order(byteOrder).asShortBuffer.put(data)
|
||||
val builder = ByteString.newBuilder
|
||||
for (i ← 0 until from) builder.putShort(data(i))(byteOrder)
|
||||
for (i <- 0 until from) builder.putShort(data(i))(byteOrder)
|
||||
builder.putShorts(data, from, to - from)(byteOrder)
|
||||
for (i ← to until data.length) builder.putShort(data(i))(byteOrder)
|
||||
for (i <- to until data.length) builder.putShort(data(i))(byteOrder)
|
||||
reference.toSeq == builder.result
|
||||
}
|
||||
|
||||
|
|
@ -246,9 +246,9 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
val reference = new Array[Byte](data.length * elemSize)
|
||||
ByteBuffer.wrap(reference).order(byteOrder).asIntBuffer.put(data)
|
||||
val builder = ByteString.newBuilder
|
||||
for (i ← 0 until from) builder.putInt(data(i))(byteOrder)
|
||||
for (i <- 0 until from) builder.putInt(data(i))(byteOrder)
|
||||
builder.putInts(data, from, to - from)(byteOrder)
|
||||
for (i ← to until data.length) builder.putInt(data(i))(byteOrder)
|
||||
for (i <- to until data.length) builder.putInt(data(i))(byteOrder)
|
||||
reference.toSeq == builder.result
|
||||
}
|
||||
|
||||
|
|
@ -258,9 +258,9 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
val reference = new Array[Byte](data.length * elemSize)
|
||||
ByteBuffer.wrap(reference).order(byteOrder).asLongBuffer.put(data)
|
||||
val builder = ByteString.newBuilder
|
||||
for (i ← 0 until from) builder.putLong(data(i))(byteOrder)
|
||||
for (i <- 0 until from) builder.putLong(data(i))(byteOrder)
|
||||
builder.putLongs(data, from, to - from)(byteOrder)
|
||||
for (i ← to until data.length) builder.putLong(data(i))(byteOrder)
|
||||
for (i <- to until data.length) builder.putLong(data(i))(byteOrder)
|
||||
reference.toSeq == builder.result
|
||||
}
|
||||
|
||||
|
|
@ -271,11 +271,11 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
val reference = new Array[Byte](data.length * elemSize)
|
||||
ByteBuffer.wrap(reference).order(byteOrder).asLongBuffer.put(data)
|
||||
val builder = ByteString.newBuilder
|
||||
for (i ← 0 until data.length) builder.putLongPart(data(i), nBytes)(byteOrder)
|
||||
for (i <- 0 until data.length) builder.putLongPart(data(i), nBytes)(byteOrder)
|
||||
|
||||
reference.zipWithIndex.collect({ // Since there is no partial put on LongBuffer, we need to collect only the interesting bytes
|
||||
case (r, i) if byteOrder == ByteOrder.LITTLE_ENDIAN && i % elemSize < nBytes ⇒ r
|
||||
case (r, i) if byteOrder == ByteOrder.BIG_ENDIAN && i % elemSize >= (elemSize - nBytes) ⇒ r
|
||||
case (r, i) if byteOrder == ByteOrder.LITTLE_ENDIAN && i % elemSize < nBytes => r
|
||||
case (r, i) if byteOrder == ByteOrder.BIG_ENDIAN && i % elemSize >= (elemSize - nBytes) => r
|
||||
}).toSeq == builder.result
|
||||
}
|
||||
|
||||
|
|
@ -285,9 +285,9 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
val reference = new Array[Byte](data.length * elemSize)
|
||||
ByteBuffer.wrap(reference).order(byteOrder).asFloatBuffer.put(data)
|
||||
val builder = ByteString.newBuilder
|
||||
for (i ← 0 until from) builder.putFloat(data(i))(byteOrder)
|
||||
for (i <- 0 until from) builder.putFloat(data(i))(byteOrder)
|
||||
builder.putFloats(data, from, to - from)(byteOrder)
|
||||
for (i ← to until data.length) builder.putFloat(data(i))(byteOrder)
|
||||
for (i <- to until data.length) builder.putFloat(data(i))(byteOrder)
|
||||
reference.toSeq == builder.result
|
||||
}
|
||||
|
||||
|
|
@ -297,9 +297,9 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
val reference = new Array[Byte](data.length * elemSize)
|
||||
ByteBuffer.wrap(reference).order(byteOrder).asDoubleBuffer.put(data)
|
||||
val builder = ByteString.newBuilder
|
||||
for (i ← 0 until from) builder.putDouble(data(i))(byteOrder)
|
||||
for (i <- 0 until from) builder.putDouble(data(i))(byteOrder)
|
||||
builder.putDoubles(data, from, to - from)(byteOrder)
|
||||
for (i ← to until data.length) builder.putDouble(data(i))(byteOrder)
|
||||
for (i <- to until data.length) builder.putDouble(data(i))(byteOrder)
|
||||
reference.toSeq == builder.result
|
||||
}
|
||||
|
||||
|
|
@ -616,23 +616,23 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
|
||||
"A ByteString" must {
|
||||
"have correct size" when {
|
||||
"concatenating" in { check((a: ByteString, b: ByteString) ⇒ (a ++ b).size == a.size + b.size) }
|
||||
"dropping" in { check((a: ByteString, b: ByteString) ⇒ (a ++ b).drop(b.size).size == a.size) }
|
||||
"taking" in { check((a: ByteString, b: ByteString) ⇒ (a ++ b).take(a.size) == a) }
|
||||
"takingRight" in { check((a: ByteString, b: ByteString) ⇒ (a ++ b).takeRight(b.size) == b) }
|
||||
"dropping then taking" in { check((a: ByteString, b: ByteString) ⇒ (b ++ a ++ b).drop(b.size).take(a.size) == a) }
|
||||
"droppingRight" in { check((a: ByteString, b: ByteString) ⇒ (b ++ a ++ b).drop(b.size).dropRight(b.size) == a) }
|
||||
"concatenating" in { check((a: ByteString, b: ByteString) => (a ++ b).size == a.size + b.size) }
|
||||
"dropping" in { check((a: ByteString, b: ByteString) => (a ++ b).drop(b.size).size == a.size) }
|
||||
"taking" in { check((a: ByteString, b: ByteString) => (a ++ b).take(a.size) == a) }
|
||||
"takingRight" in { check((a: ByteString, b: ByteString) => (a ++ b).takeRight(b.size) == b) }
|
||||
"dropping then taking" in { check((a: ByteString, b: ByteString) => (b ++ a ++ b).drop(b.size).take(a.size) == a) }
|
||||
"droppingRight" in { check((a: ByteString, b: ByteString) => (b ++ a ++ b).drop(b.size).dropRight(b.size) == a) }
|
||||
}
|
||||
|
||||
"be sequential" when {
|
||||
"taking" in { check((a: ByteString, b: ByteString) ⇒ (a ++ b).take(a.size) == a) }
|
||||
"dropping" in { check((a: ByteString, b: ByteString) ⇒ (a ++ b).drop(a.size) == b) }
|
||||
"taking" in { check((a: ByteString, b: ByteString) => (a ++ b).take(a.size) == a) }
|
||||
"dropping" in { check((a: ByteString, b: ByteString) => (a ++ b).drop(a.size) == b) }
|
||||
}
|
||||
|
||||
"be equal to the original" when {
|
||||
"compacting" in { check { xs: ByteString ⇒ val ys = xs.compact; (xs == ys) && ys.isCompact } }
|
||||
"compacting" in { check { xs: ByteString => val ys = xs.compact; (xs == ys) && ys.isCompact } }
|
||||
"recombining" in {
|
||||
check { (xs: ByteString, from: Int, until: Int) ⇒
|
||||
check { (xs: ByteString, from: Int, until: Int) =>
|
||||
val (tmp, c) = xs.splitAt(until)
|
||||
val (a, b) = tmp.splitAt(from)
|
||||
(a ++ b ++ c) == xs
|
||||
|
|
@ -656,10 +656,10 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
}
|
||||
|
||||
"behave as expected" when {
|
||||
"created from and decoding to String" in { check { s: String ⇒ ByteString(s, "UTF-8").decodeString("UTF-8") == s } }
|
||||
"created from and decoding to String" in { check { s: String => ByteString(s, "UTF-8").decodeString("UTF-8") == s } }
|
||||
|
||||
"compacting" in {
|
||||
check { a: ByteString ⇒
|
||||
check { a: ByteString =>
|
||||
val wasCompact = a.isCompact
|
||||
val b = a.compact
|
||||
((!wasCompact) || (b eq a)) &&
|
||||
|
|
@ -670,28 +670,28 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
}
|
||||
|
||||
"asByteBuffers" in {
|
||||
check { (a: ByteString) ⇒ if (a.isCompact) a.asByteBuffers.size == 1 && a.asByteBuffers.head == a.asByteBuffer else a.asByteBuffers.size > 0 }
|
||||
check { (a: ByteString) ⇒ a.asByteBuffers.foldLeft(ByteString.empty) { (bs, bb) ⇒ bs ++ ByteString(bb) } == a }
|
||||
check { (a: ByteString) ⇒ a.asByteBuffers.forall(_.isReadOnly) }
|
||||
check { (a: ByteString) ⇒
|
||||
check { (a: ByteString) => if (a.isCompact) a.asByteBuffers.size == 1 && a.asByteBuffers.head == a.asByteBuffer else a.asByteBuffers.size > 0 }
|
||||
check { (a: ByteString) => a.asByteBuffers.foldLeft(ByteString.empty) { (bs, bb) => bs ++ ByteString(bb) } == a }
|
||||
check { (a: ByteString) => a.asByteBuffers.forall(_.isReadOnly) }
|
||||
check { (a: ByteString) =>
|
||||
import scala.collection.JavaConverters.iterableAsScalaIterableConverter
|
||||
a.asByteBuffers.zip(a.getByteBuffers().asScala).forall(x ⇒ x._1 == x._2)
|
||||
a.asByteBuffers.zip(a.getByteBuffers().asScala).forall(x => x._1 == x._2)
|
||||
}
|
||||
}
|
||||
|
||||
"toString should start with ByteString(" in {
|
||||
check { (bs: ByteString) ⇒
|
||||
check { (bs: ByteString) =>
|
||||
bs.toString.startsWith("ByteString(")
|
||||
}
|
||||
}
|
||||
}
|
||||
"behave like a Vector" when {
|
||||
"concatenating" in { check { (a: ByteString, b: ByteString) ⇒ likeVectors(a, b) { _ ++ _ } } }
|
||||
"concatenating" in { check { (a: ByteString, b: ByteString) => likeVectors(a, b) { _ ++ _ } } }
|
||||
|
||||
"calling apply" in {
|
||||
check { slice: ByteStringSlice ⇒
|
||||
check { slice: ByteStringSlice =>
|
||||
slice match {
|
||||
case (xs, i1, i2) ⇒ likeVector(xs) { seq ⇒
|
||||
case (xs, i1, i2) => likeVector(xs) { seq =>
|
||||
(if ((i1 >= 0) && (i1 < seq.length)) seq(i1) else 0,
|
||||
if ((i2 >= 0) && (i2 < seq.length)) seq(i2) else 0)
|
||||
}
|
||||
|
|
@ -699,30 +699,30 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
}
|
||||
}
|
||||
|
||||
"calling head" in { check { a: ByteString ⇒ a.isEmpty || likeVector(a) { _.head } } }
|
||||
"calling tail" in { check { a: ByteString ⇒ a.isEmpty || likeVector(a) { _.tail } } }
|
||||
"calling last" in { check { a: ByteString ⇒ a.isEmpty || likeVector(a) { _.last } } }
|
||||
"calling init" in { check { a: ByteString ⇒ a.isEmpty || likeVector(a) { _.init } } }
|
||||
"calling length" in { check { a: ByteString ⇒ likeVector(a) { _.length } } }
|
||||
"calling head" in { check { a: ByteString => a.isEmpty || likeVector(a) { _.head } } }
|
||||
"calling tail" in { check { a: ByteString => a.isEmpty || likeVector(a) { _.tail } } }
|
||||
"calling last" in { check { a: ByteString => a.isEmpty || likeVector(a) { _.last } } }
|
||||
"calling init" in { check { a: ByteString => a.isEmpty || likeVector(a) { _.init } } }
|
||||
"calling length" in { check { a: ByteString => likeVector(a) { _.length } } }
|
||||
|
||||
"calling span" in { check { (a: ByteString, b: Byte) ⇒ likeVector(a)({ _.span(_ != b) match { case (a, b) ⇒ (a, b) } }) } }
|
||||
"calling span" in { check { (a: ByteString, b: Byte) => likeVector(a)({ _.span(_ != b) match { case (a, b) => (a, b) } }) } }
|
||||
|
||||
"calling takeWhile" in { check { (a: ByteString, b: Byte) ⇒ likeVector(a)({ _.takeWhile(_ != b) }) } }
|
||||
"calling dropWhile" in { check { (a: ByteString, b: Byte) ⇒ likeVector(a) { _.dropWhile(_ != b) } } }
|
||||
"calling indexWhere" in { check { (a: ByteString, b: Byte) ⇒ likeVector(a) { _.indexWhere(_ == b) } } }
|
||||
"calling indexOf" in { check { (a: ByteString, b: Byte) ⇒ likeVector(a) { _.indexOf(b) } } }
|
||||
"calling takeWhile" in { check { (a: ByteString, b: Byte) => likeVector(a)({ _.takeWhile(_ != b) }) } }
|
||||
"calling dropWhile" in { check { (a: ByteString, b: Byte) => likeVector(a) { _.dropWhile(_ != b) } } }
|
||||
"calling indexWhere" in { check { (a: ByteString, b: Byte) => likeVector(a) { _.indexWhere(_ == b) } } }
|
||||
"calling indexOf" in { check { (a: ByteString, b: Byte) => likeVector(a) { _.indexOf(b) } } }
|
||||
// this actually behave weird for Vector and negative indexes - SI9936, fixed in Scala 2.12
|
||||
// so let's just skip negative indexes (doesn't make much sense anyway)
|
||||
"calling indexOf(elem, idx)" in { check { (a: ByteString, b: Byte, idx: Int) ⇒ likeVector(a) { _.indexOf(b, math.max(0, idx)) } } }
|
||||
"calling indexOf(elem, idx)" in { check { (a: ByteString, b: Byte, idx: Int) => likeVector(a) { _.indexOf(b, math.max(0, idx)) } } }
|
||||
|
||||
"calling foreach" in { check { a: ByteString ⇒ likeVector(a) { it ⇒ var acc = 0; it foreach { acc += _ }; acc } } }
|
||||
"calling foldLeft" in { check { a: ByteString ⇒ likeVector(a) { _.foldLeft(0) { _ + _ } } } }
|
||||
"calling toArray" in { check { a: ByteString ⇒ likeVector(a) { _.toArray.toSeq } } }
|
||||
"calling foreach" in { check { a: ByteString => likeVector(a) { it => var acc = 0; it foreach { acc += _ }; acc } } }
|
||||
"calling foldLeft" in { check { a: ByteString => likeVector(a) { _.foldLeft(0) { _ + _ } } } }
|
||||
"calling toArray" in { check { a: ByteString => likeVector(a) { _.toArray.toSeq } } }
|
||||
|
||||
"calling slice" in {
|
||||
check { slice: ByteStringSlice ⇒
|
||||
check { slice: ByteStringSlice =>
|
||||
slice match {
|
||||
case (xs, from, until) ⇒ likeVector(xs)({
|
||||
case (xs, from, until) => likeVector(xs)({
|
||||
_.slice(from, until)
|
||||
})
|
||||
}
|
||||
|
|
@ -730,9 +730,9 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
}
|
||||
|
||||
"calling take and drop" in {
|
||||
check { slice: ByteStringSlice ⇒
|
||||
check { slice: ByteStringSlice =>
|
||||
slice match {
|
||||
case (xs, from, until) ⇒ likeVector(xs)({
|
||||
case (xs, from, until) => likeVector(xs)({
|
||||
_.drop(from).take(until - from)
|
||||
})
|
||||
}
|
||||
|
|
@ -740,7 +740,7 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
}
|
||||
|
||||
"calling grouped" in {
|
||||
check { grouped: ByteStringGrouped ⇒
|
||||
check { grouped: ByteStringGrouped =>
|
||||
likeVector(grouped.bs) {
|
||||
_.grouped(grouped.size).toIndexedSeq
|
||||
}
|
||||
|
|
@ -748,9 +748,9 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
}
|
||||
|
||||
"calling copyToArray" in {
|
||||
check { slice: ByteStringSlice ⇒
|
||||
check { slice: ByteStringSlice =>
|
||||
slice match {
|
||||
case (xs, from, until) ⇒ likeVector(xs)({ it ⇒
|
||||
case (xs, from, until) => likeVector(xs)({ it =>
|
||||
val array = new Array[Byte](xs.length)
|
||||
it.slice(from, until).copyToArray(array, from, until)
|
||||
array.toSeq
|
||||
|
|
@ -775,7 +775,7 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
}
|
||||
|
||||
"given all types of ByteString" in {
|
||||
check { bs: ByteString ⇒
|
||||
check { bs: ByteString =>
|
||||
testSer(bs)
|
||||
}
|
||||
}
|
||||
|
|
@ -791,32 +791,32 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
|
||||
"A ByteStringIterator" must {
|
||||
"behave like a buffered Vector Iterator" when {
|
||||
"concatenating" in { check { (a: ByteString, b: ByteString) ⇒ likeVecIts(a, b) { (a, b) ⇒ (a ++ b).toSeq } } }
|
||||
"concatenating" in { check { (a: ByteString, b: ByteString) => likeVecIts(a, b) { (a, b) => (a ++ b).toSeq } } }
|
||||
|
||||
"calling head" in { check { a: ByteString ⇒ a.isEmpty || likeVecIt(a) { _.head } } }
|
||||
"calling next" in { check { a: ByteString ⇒ a.isEmpty || likeVecIt(a) { _.next() } } }
|
||||
"calling hasNext" in { check { a: ByteString ⇒ likeVecIt(a) { _.hasNext } } }
|
||||
"calling length" in { check { a: ByteString ⇒ likeVecIt(a) { _.length } } }
|
||||
"calling duplicate" in { check { a: ByteString ⇒ likeVecIt(a)({ _.duplicate match { case (a, b) ⇒ (a.toSeq, b.toSeq) } }, strict = false) } }
|
||||
"calling head" in { check { a: ByteString => a.isEmpty || likeVecIt(a) { _.head } } }
|
||||
"calling next" in { check { a: ByteString => a.isEmpty || likeVecIt(a) { _.next() } } }
|
||||
"calling hasNext" in { check { a: ByteString => likeVecIt(a) { _.hasNext } } }
|
||||
"calling length" in { check { a: ByteString => likeVecIt(a) { _.length } } }
|
||||
"calling duplicate" in { check { a: ByteString => likeVecIt(a)({ _.duplicate match { case (a, b) => (a.toSeq, b.toSeq) } }, strict = false) } }
|
||||
|
||||
// Have to used toList instead of toSeq here, iterator.span (new in
|
||||
// Scala-2.9) seems to be broken in combination with toSeq for the
|
||||
// scala.collection default Iterator (see Scala issue SI-5838).
|
||||
"calling span" in { check { (a: ByteString, b: Byte) ⇒ likeVecIt(a)({ _.span(_ != b) match { case (a, b) ⇒ (a.toList, b.toList) } }, strict = false) } }
|
||||
"calling span" in { check { (a: ByteString, b: Byte) => likeVecIt(a)({ _.span(_ != b) match { case (a, b) => (a.toList, b.toList) } }, strict = false) } }
|
||||
|
||||
"calling takeWhile" in { check { (a: ByteString, b: Byte) ⇒ likeVecIt(a)({ _.takeWhile(_ != b).toSeq }, strict = false) } }
|
||||
"calling dropWhile" in { check { (a: ByteString, b: Byte) ⇒ likeVecIt(a) { _.dropWhile(_ != b).toSeq } } }
|
||||
"calling indexWhere" in { check { (a: ByteString, b: Byte) ⇒ likeVecIt(a) { _.indexWhere(_ == b) } } }
|
||||
"calling indexOf" in { check { (a: ByteString, b: Byte) ⇒ likeVecIt(a) { _.indexOf(b) } } }
|
||||
"calling toSeq" in { check { a: ByteString ⇒ likeVecIt(a) { _.toSeq } } }
|
||||
"calling foreach" in { check { a: ByteString ⇒ likeVecIt(a) { it ⇒ var acc = 0; it foreach { acc += _ }; acc } } }
|
||||
"calling foldLeft" in { check { a: ByteString ⇒ likeVecIt(a) { _.foldLeft(0) { _ + _ } } } }
|
||||
"calling toArray" in { check { a: ByteString ⇒ likeVecIt(a) { _.toArray.toSeq } } }
|
||||
"calling takeWhile" in { check { (a: ByteString, b: Byte) => likeVecIt(a)({ _.takeWhile(_ != b).toSeq }, strict = false) } }
|
||||
"calling dropWhile" in { check { (a: ByteString, b: Byte) => likeVecIt(a) { _.dropWhile(_ != b).toSeq } } }
|
||||
"calling indexWhere" in { check { (a: ByteString, b: Byte) => likeVecIt(a) { _.indexWhere(_ == b) } } }
|
||||
"calling indexOf" in { check { (a: ByteString, b: Byte) => likeVecIt(a) { _.indexOf(b) } } }
|
||||
"calling toSeq" in { check { a: ByteString => likeVecIt(a) { _.toSeq } } }
|
||||
"calling foreach" in { check { a: ByteString => likeVecIt(a) { it => var acc = 0; it foreach { acc += _ }; acc } } }
|
||||
"calling foldLeft" in { check { a: ByteString => likeVecIt(a) { _.foldLeft(0) { _ + _ } } } }
|
||||
"calling toArray" in { check { a: ByteString => likeVecIt(a) { _.toArray.toSeq } } }
|
||||
|
||||
"calling slice" in {
|
||||
check { slice: ByteStringSlice ⇒
|
||||
check { slice: ByteStringSlice =>
|
||||
slice match {
|
||||
case (xs, from, until) ⇒ likeVecIt(xs)({
|
||||
case (xs, from, until) => likeVecIt(xs)({
|
||||
_.slice(from, until).toSeq
|
||||
}, strict = false)
|
||||
}
|
||||
|
|
@ -824,9 +824,9 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
}
|
||||
|
||||
"calling take and drop" in {
|
||||
check { slice: ByteStringSlice ⇒
|
||||
check { slice: ByteStringSlice =>
|
||||
slice match {
|
||||
case (xs, from, until) ⇒ likeVecIt(xs)({
|
||||
case (xs, from, until) => likeVecIt(xs)({
|
||||
_.drop(from).take(until - from).toSeq
|
||||
}, strict = false)
|
||||
}
|
||||
|
|
@ -834,9 +834,9 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
}
|
||||
|
||||
"calling copyToArray" in {
|
||||
check { slice: ByteStringSlice ⇒
|
||||
check { slice: ByteStringSlice =>
|
||||
slice match {
|
||||
case (xs, from, until) ⇒ likeVecIt(xs)({ it ⇒
|
||||
case (xs, from, until) => likeVecIt(xs)({ it =>
|
||||
val array = new Array[Byte](xs.length)
|
||||
it.slice(from, until).copyToArray(array, from, until)
|
||||
array.toSeq
|
||||
|
|
@ -849,20 +849,20 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
"function as expected" when {
|
||||
"getting Bytes, using getByte and getBytes" in {
|
||||
// mixing getByte and getBytes here for more rigorous testing
|
||||
check { slice: ByteStringSlice ⇒
|
||||
check { slice: ByteStringSlice =>
|
||||
val (bytes, from, to) = slice
|
||||
val input = bytes.iterator
|
||||
val output = new Array[Byte](bytes.length)
|
||||
for (i ← 0 until from) output(i) = input.getByte
|
||||
for (i <- 0 until from) output(i) = input.getByte
|
||||
input.getBytes(output, from, to - from)
|
||||
for (i ← to until bytes.length) output(i) = input.getByte
|
||||
for (i <- to until bytes.length) output(i) = input.getByte
|
||||
(output.toSeq == bytes) && (input.isEmpty)
|
||||
}
|
||||
}
|
||||
|
||||
"getting Bytes with a given length" in {
|
||||
check {
|
||||
slice: ByteStringSlice ⇒
|
||||
slice: ByteStringSlice =>
|
||||
val (bytes, _, _) = slice
|
||||
val input = bytes.iterator
|
||||
(input.getBytes(bytes.length).toSeq == bytes) && input.isEmpty
|
||||
|
|
@ -871,7 +871,7 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
|
||||
"getting ByteString with a given length" in {
|
||||
check {
|
||||
slice: ByteStringSlice ⇒
|
||||
slice: ByteStringSlice =>
|
||||
val (bytes, _, _) = slice
|
||||
val input = bytes.iterator
|
||||
(input.getByteString(bytes.length) == bytes) && input.isEmpty
|
||||
|
|
@ -880,7 +880,7 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
|
||||
"getting Bytes, using the InputStream wrapper" in {
|
||||
// combining skip and both read methods here for more rigorous testing
|
||||
check { slice: ByteStringSlice ⇒
|
||||
check { slice: ByteStringSlice =>
|
||||
val (bytes, from, to) = slice
|
||||
val a = (0 max from) min bytes.length
|
||||
val b = (a max to) min bytes.length
|
||||
|
|
@ -898,7 +898,7 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
}
|
||||
if (eof) throw new RuntimeException("Unexpected EOF")
|
||||
|
||||
for (i ← b until bytes.length) output(i) = input.asInputStream.read().toByte
|
||||
for (i <- b until bytes.length) output(i) = input.asInputStream.read().toByte
|
||||
|
||||
(output.toSeq.drop(a) == bytes.drop(a)) &&
|
||||
(input.asInputStream.read() == -1) &&
|
||||
|
|
@ -907,7 +907,7 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
}
|
||||
|
||||
"calling copyToBuffer" in {
|
||||
check { bytes: ByteString ⇒
|
||||
check { bytes: ByteString =>
|
||||
import java.nio.ByteBuffer
|
||||
val buffer = ByteBuffer.allocate(bytes.size)
|
||||
bytes.copyToBuffer(buffer)
|
||||
|
|
@ -929,28 +929,28 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
}
|
||||
|
||||
"decode data correctly" when {
|
||||
"decoding Short in big-endian" in { check { slice: ByteStringSlice ⇒ testShortDecoding(slice, BIG_ENDIAN) } }
|
||||
"decoding Short in little-endian" in { check { slice: ByteStringSlice ⇒ testShortDecoding(slice, LITTLE_ENDIAN) } }
|
||||
"decoding Int in big-endian" in { check { slice: ByteStringSlice ⇒ testIntDecoding(slice, BIG_ENDIAN) } }
|
||||
"decoding Int in little-endian" in { check { slice: ByteStringSlice ⇒ testIntDecoding(slice, LITTLE_ENDIAN) } }
|
||||
"decoding Long in big-endian" in { check { slice: ByteStringSlice ⇒ testLongDecoding(slice, BIG_ENDIAN) } }
|
||||
"decoding Long in little-endian" in { check { slice: ByteStringSlice ⇒ testLongDecoding(slice, LITTLE_ENDIAN) } }
|
||||
"decoding Float in big-endian" in { check { slice: ByteStringSlice ⇒ testFloatDecoding(slice, BIG_ENDIAN) } }
|
||||
"decoding Float in little-endian" in { check { slice: ByteStringSlice ⇒ testFloatDecoding(slice, LITTLE_ENDIAN) } }
|
||||
"decoding Double in big-endian" in { check { slice: ByteStringSlice ⇒ testDoubleDecoding(slice, BIG_ENDIAN) } }
|
||||
"decoding Double in little-endian" in { check { slice: ByteStringSlice ⇒ testDoubleDecoding(slice, LITTLE_ENDIAN) } }
|
||||
"decoding Short in big-endian" in { check { slice: ByteStringSlice => testShortDecoding(slice, BIG_ENDIAN) } }
|
||||
"decoding Short in little-endian" in { check { slice: ByteStringSlice => testShortDecoding(slice, LITTLE_ENDIAN) } }
|
||||
"decoding Int in big-endian" in { check { slice: ByteStringSlice => testIntDecoding(slice, BIG_ENDIAN) } }
|
||||
"decoding Int in little-endian" in { check { slice: ByteStringSlice => testIntDecoding(slice, LITTLE_ENDIAN) } }
|
||||
"decoding Long in big-endian" in { check { slice: ByteStringSlice => testLongDecoding(slice, BIG_ENDIAN) } }
|
||||
"decoding Long in little-endian" in { check { slice: ByteStringSlice => testLongDecoding(slice, LITTLE_ENDIAN) } }
|
||||
"decoding Float in big-endian" in { check { slice: ByteStringSlice => testFloatDecoding(slice, BIG_ENDIAN) } }
|
||||
"decoding Float in little-endian" in { check { slice: ByteStringSlice => testFloatDecoding(slice, LITTLE_ENDIAN) } }
|
||||
"decoding Double in big-endian" in { check { slice: ByteStringSlice => testDoubleDecoding(slice, BIG_ENDIAN) } }
|
||||
"decoding Double in little-endian" in { check { slice: ByteStringSlice => testDoubleDecoding(slice, LITTLE_ENDIAN) } }
|
||||
}
|
||||
}
|
||||
|
||||
"A ByteStringBuilder" must {
|
||||
"function like a VectorBuilder" when {
|
||||
"adding various contents using ++= and +=" in {
|
||||
check { (array1: Array[Byte], array2: Array[Byte], bs1: ByteString, bs2: ByteString, bs3: ByteString) ⇒
|
||||
likeVecBld { builder ⇒
|
||||
check { (array1: Array[Byte], array2: Array[Byte], bs1: ByteString, bs2: ByteString, bs3: ByteString) =>
|
||||
likeVecBld { builder =>
|
||||
builder ++= array1
|
||||
bs1 foreach { b ⇒ builder += b }
|
||||
bs1 foreach { b => builder += b }
|
||||
builder ++= bs2
|
||||
bs3 foreach { b ⇒ builder += b }
|
||||
bs3 foreach { b => builder += b }
|
||||
builder ++= Vector(array2: _*)
|
||||
}
|
||||
}
|
||||
|
|
@ -959,50 +959,50 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
|
|||
"function as expected" when {
|
||||
"putting Bytes, using putByte and putBytes" in {
|
||||
// mixing putByte and putBytes here for more rigorous testing
|
||||
check { slice: ArraySlice[Byte] ⇒
|
||||
check { slice: ArraySlice[Byte] =>
|
||||
val (data, from, to) = slice
|
||||
val builder = ByteString.newBuilder
|
||||
for (i ← 0 until from) builder.putByte(data(i))
|
||||
for (i <- 0 until from) builder.putByte(data(i))
|
||||
builder.putBytes(data, from, to - from)
|
||||
for (i ← to until data.length) builder.putByte(data(i))
|
||||
for (i <- to until data.length) builder.putByte(data(i))
|
||||
data.toSeq == builder.result
|
||||
}
|
||||
}
|
||||
|
||||
"putting Bytes, using the OutputStream wrapper" in {
|
||||
// mixing the write methods here for more rigorous testing
|
||||
check { slice: ArraySlice[Byte] ⇒
|
||||
check { slice: ArraySlice[Byte] =>
|
||||
val (data, from, to) = slice
|
||||
val builder = ByteString.newBuilder
|
||||
for (i ← 0 until from) builder.asOutputStream.write(data(i).toInt)
|
||||
for (i <- 0 until from) builder.asOutputStream.write(data(i).toInt)
|
||||
builder.asOutputStream.write(data, from, to - from)
|
||||
for (i ← to until data.length) builder.asOutputStream.write(data(i).toInt)
|
||||
for (i <- to until data.length) builder.asOutputStream.write(data(i).toInt)
|
||||
data.toSeq == builder.result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"encode data correctly" when {
|
||||
"encoding Short in big-endian" in { check { slice: ArraySlice[Short] ⇒ testShortEncoding(slice, BIG_ENDIAN) } }
|
||||
"encoding Short in little-endian" in { check { slice: ArraySlice[Short] ⇒ testShortEncoding(slice, LITTLE_ENDIAN) } }
|
||||
"encoding Int in big-endian" in { check { slice: ArraySlice[Int] ⇒ testIntEncoding(slice, BIG_ENDIAN) } }
|
||||
"encoding Int in little-endian" in { check { slice: ArraySlice[Int] ⇒ testIntEncoding(slice, LITTLE_ENDIAN) } }
|
||||
"encoding Long in big-endian" in { check { slice: ArraySlice[Long] ⇒ testLongEncoding(slice, BIG_ENDIAN) } }
|
||||
"encoding Long in little-endian" in { check { slice: ArraySlice[Long] ⇒ testLongEncoding(slice, LITTLE_ENDIAN) } }
|
||||
"encoding LongPart in big-endian" in { check { slice: ArrayNumBytes[Long] ⇒ testLongPartEncoding(slice, BIG_ENDIAN) } }
|
||||
"encoding LongPart in little-endian" in { check { slice: ArrayNumBytes[Long] ⇒ testLongPartEncoding(slice, LITTLE_ENDIAN) } }
|
||||
"encoding Float in big-endian" in { check { slice: ArraySlice[Float] ⇒ testFloatEncoding(slice, BIG_ENDIAN) } }
|
||||
"encoding Float in little-endian" in { check { slice: ArraySlice[Float] ⇒ testFloatEncoding(slice, LITTLE_ENDIAN) } }
|
||||
"encoding Double in big-endian" in { check { slice: ArraySlice[Double] ⇒ testDoubleEncoding(slice, BIG_ENDIAN) } }
|
||||
"encoding Double in little-endian" in { check { slice: ArraySlice[Double] ⇒ testDoubleEncoding(slice, LITTLE_ENDIAN) } }
|
||||
"encoding Short in big-endian" in { check { slice: ArraySlice[Short] => testShortEncoding(slice, BIG_ENDIAN) } }
|
||||
"encoding Short in little-endian" in { check { slice: ArraySlice[Short] => testShortEncoding(slice, LITTLE_ENDIAN) } }
|
||||
"encoding Int in big-endian" in { check { slice: ArraySlice[Int] => testIntEncoding(slice, BIG_ENDIAN) } }
|
||||
"encoding Int in little-endian" in { check { slice: ArraySlice[Int] => testIntEncoding(slice, LITTLE_ENDIAN) } }
|
||||
"encoding Long in big-endian" in { check { slice: ArraySlice[Long] => testLongEncoding(slice, BIG_ENDIAN) } }
|
||||
"encoding Long in little-endian" in { check { slice: ArraySlice[Long] => testLongEncoding(slice, LITTLE_ENDIAN) } }
|
||||
"encoding LongPart in big-endian" in { check { slice: ArrayNumBytes[Long] => testLongPartEncoding(slice, BIG_ENDIAN) } }
|
||||
"encoding LongPart in little-endian" in { check { slice: ArrayNumBytes[Long] => testLongPartEncoding(slice, LITTLE_ENDIAN) } }
|
||||
"encoding Float in big-endian" in { check { slice: ArraySlice[Float] => testFloatEncoding(slice, BIG_ENDIAN) } }
|
||||
"encoding Float in little-endian" in { check { slice: ArraySlice[Float] => testFloatEncoding(slice, LITTLE_ENDIAN) } }
|
||||
"encoding Double in big-endian" in { check { slice: ArraySlice[Double] => testDoubleEncoding(slice, BIG_ENDIAN) } }
|
||||
"encoding Double in little-endian" in { check { slice: ArraySlice[Double] => testDoubleEncoding(slice, LITTLE_ENDIAN) } }
|
||||
}
|
||||
|
||||
"have correct empty info" when {
|
||||
"is empty" in {
|
||||
check { a: ByteStringBuilder ⇒ a.isEmpty }
|
||||
check { a: ByteStringBuilder => a.isEmpty }
|
||||
}
|
||||
"is nonEmpty" in {
|
||||
check { a: ByteStringBuilder ⇒
|
||||
check { a: ByteStringBuilder =>
|
||||
a.putByte(1.toByte)
|
||||
a.nonEmpty
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue