]> git.lizzy.rs Git - rust.git/commitdiff
Use byte literals in libcollections tests
authornham <hamann.nick@gmail.com>
Wed, 6 Aug 2014 04:57:49 +0000 (00:57 -0400)
committernham <hamann.nick@gmail.com>
Wed, 6 Aug 2014 04:57:49 +0000 (00:57 -0400)
src/libcollections/str.rs
src/libcollections/string.rs

index f5a274b76770ec68b30e2d1317d8c93274de5da2..270b76fd57fc95cd5949349be4d7c52e6fbaa1de 100644 (file)
@@ -1457,7 +1457,7 @@ fn test_as_bytes() {
             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 @@ fn test_as_bytes_fail() {
     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');
         }
     }
 
index 684a15f9aae50028cdb0add0fcd3dc66f393bc81..9465fea6dcbee1180669fb8bfd4775e522aebe6f 100644 (file)
@@ -1040,7 +1040,7 @@ fn test_from_buf() {
     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");
     }