#2913 - Adding asByteBuffers to ByteString
This commit is contained in:
parent
f12e11df46
commit
2f86107b10
2 changed files with 44 additions and 6 deletions
|
|
@ -269,9 +269,19 @@ class ByteStringSpec extends WordSpec with MustMatchers with Checkers {
|
|||
(b.compact eq b)
|
||||
}
|
||||
}
|
||||
|
||||
"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) ⇒
|
||||
import scala.collection.JavaConverters.iterableAsScalaIterableConverter;
|
||||
a.asByteBuffers.zip(a.getByteBuffers().asScala).forall(x ⇒ x._1 == x._2)
|
||||
}
|
||||
}
|
||||
}
|
||||
"behave like a Vector" when {
|
||||
"concatenating" in { check { (a: ByteString, b: ByteString) ⇒ likeVectors(a, b) { (a, b) ⇒ (a ++ b) } } }
|
||||
"concatenating" in { check { (a: ByteString, b: ByteString) ⇒ likeVectors(a, b) { _ ++ _ } } }
|
||||
|
||||
"calling apply" in {
|
||||
check { slice: ByteStringSlice ⇒
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue