-#15825 add isEmpty and nonEmpty to ByteStringBuilder

This commit is contained in:
hepin 2015-03-28 13:34:47 +08:00
parent 213a5a4300
commit 954a86bf80
2 changed files with 24 additions and 0 deletions

View file

@ -80,6 +80,8 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
} yield (xs.slice(from, until), bytes)
}
implicit val arbitraryByteStringBuilder: Arbitrary[ByteStringBuilder] = Arbitrary(ByteString.newBuilder)
def likeVector(bs: ByteString)(body: IndexedSeq[Byte] Any): Boolean = {
val vec = Vector(bs: _*)
body(bs) == body(vec)
@ -552,5 +554,17 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
"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 }
}
"is nonEmpty" in {
check { a: ByteStringBuilder
a.putByte(1.toByte)
a.nonEmpty
}
}
}
}
}