Completed ByteIterator tests in ByteStringSpec

This commit is contained in:
Oliver Schulz 2012-05-31 10:15:44 +02:00
parent 7231b48c05
commit f01d5c619e

View file

@ -266,6 +266,16 @@ class ByteStringSpec extends WordSpec with MustMatchers with Checkers {
}
}
"calling take and drop" in {
check { slice: ByteStringSlice
slice match {
case (xs, from, until) likeVecIt(xs)({
_.drop(from).take(until - from).toSeq
}, strict = false)
}
}
}
"calling copyToArray" in {
check { slice: ByteStringSlice
slice match {
@ -320,6 +330,18 @@ class ByteStringSpec extends WordSpec with MustMatchers with Checkers {
((output.length < 1) || (input.asInputStream.read(output, 0, 1) == -1))
}
}
"calling copyToBuffer" in {
check { bytes: ByteString
import java.nio.ByteBuffer
val buffer = ByteBuffer.allocate(bytes.size)
bytes.copyToBuffer(buffer)
buffer.flip()
val array = Array.ofDim[Byte](bytes.size)
buffer.get(array)
bytes == array.toSeq
}
}
}
"decode data correctly" when {