Use byte literals in libcollections tests

This commit is contained in:
nham 2014-08-06 00:57:49 -04:00
parent f5ac41185a
commit f36ddf1d0e
2 changed files with 7 additions and 7 deletions

View file

@ -1457,7 +1457,7 @@ mod tests {
109
];
assert_eq!("".as_bytes(), &[]);
assert_eq!("abc".as_bytes(), &['a' as u8, 'b' as u8, 'c' as u8]);
assert_eq!("abc".as_bytes(), b"abc");
assert_eq!("ศไทย中华Việt Nam".as_bytes(), v.as_slice());
}
@ -1475,11 +1475,11 @@ mod tests {
fn test_as_ptr() {
let buf = "hello".as_ptr();
unsafe {
assert_eq!(*buf.offset(0), 'h' as u8);
assert_eq!(*buf.offset(1), 'e' as u8);
assert_eq!(*buf.offset(2), 'l' as u8);
assert_eq!(*buf.offset(3), 'l' as u8);
assert_eq!(*buf.offset(4), 'o' as u8);
assert_eq!(*buf.offset(0), b'h');
assert_eq!(*buf.offset(1), b'e');
assert_eq!(*buf.offset(2), b'l');
assert_eq!(*buf.offset(3), b'l');
assert_eq!(*buf.offset(4), b'o');
}
}

View file

@ -1040,7 +1040,7 @@ mod tests {
fn test_push_bytes() {
let mut s = String::from_str("ABC");
unsafe {
s.push_bytes([ 'D' as u8 ]);
s.push_bytes([b'D']);
}
assert_eq!(s.as_slice(), "ABCD");
}