Flesh out ToBytes, ByteStr::concat, and ByteStr eq

This commit is contained in:
Carl Lerche
2015-03-23 23:22:21 -07:00
parent a87dea0bd4
commit bd2c643e17
5 changed files with 131 additions and 20 deletions
+15 -1
View File
@@ -69,7 +69,7 @@ pub fn test_rope_concat_two_byte_str() {
let left = Rope::from_slice(TEST_BYTES_1);
let right = Rope::from_slice(TEST_BYTES_2);
let both = left.concat(right);
let both = left.concat(&right);
assert_eq!(both.len(), TEST_BYTES_1.len() + TEST_BYTES_2.len());
@@ -88,3 +88,17 @@ pub fn test_slice_parity() {
// stuff
}
#[test]
pub fn test_rope_equality() {
let a = &b"Mary had a little lamb, its fleece was white as snow; ".to_bytes()
.concat(&b"And everywhere that Mary went, the lamb was sure to go.".to_bytes());
let b = &b"Mary had a little lamb, ".to_bytes()
.concat(&b"its fleece was white as snow; ".to_bytes())
.concat(
&b"And everywhere that Mary went, ".to_bytes()
.concat(&b"the lamb was sure to go.".to_bytes()));
assert_eq!(a, b);
}