]> git.proxmox.com Git - rustc.git/blobdiff - src/libcollectionstest/str.rs
New upstream version 1.15.0+dfsg1
[rustc.git] / src / libcollectionstest / str.rs
index cc56bbf4890aa46de435ab3048d1952aeaaa7e18..384579ce6b8b46af7ef6feb7bc2aba6f42ee8f47 100644 (file)
@@ -530,7 +530,7 @@ fn from_utf8_mostly_ascii() {
 
 #[test]
 fn test_is_utf16() {
-    use rustc_unicode::str::is_utf16;
+    use std_unicode::str::is_utf16;
 
     macro_rules! pos {
         ($($e:expr),*) => { { $(assert!(is_utf16($e));)* } }
@@ -767,6 +767,7 @@ fn test_iterator() {
         pos += 1;
     }
     assert_eq!(pos, v.len());
+    assert_eq!(s.chars().count(), v.len());
 }
 
 #[test]
@@ -814,6 +815,14 @@ fn test_iterator_clone() {
     assert!(it.clone().zip(it).all(|(x,y)| x == y));
 }
 
+#[test]
+fn test_iterator_last() {
+    let s = "ศไทย中华Việt Nam";
+    let mut it = s.chars();
+    it.next();
+    assert_eq!(it.last(), Some('m'));
+}
+
 #[test]
 fn test_bytesator() {
     let s = "ศไทย中华Việt Nam";
@@ -911,6 +920,14 @@ fn test_char_indices_revator() {
     assert_eq!(pos, p.len());
 }
 
+#[test]
+fn test_char_indices_last() {
+    let s = "ศไทย中华Việt Nam";
+    let mut it = s.char_indices();
+    it.next();
+    assert_eq!(it.last(), Some((27, 'm')));
+}
+
 #[test]
 fn test_splitn_char_iterator() {
     let data = "\nMäry häd ä little lämb\nLittle lämb\n";
@@ -1169,7 +1186,7 @@ fn test_rev_split_char_iterator_no_trailing() {
 
 #[test]
 fn test_utf16_code_units() {
-    use rustc_unicode::str::Utf16Encoder;
+    use std_unicode::str::Utf16Encoder;
     assert_eq!(Utf16Encoder::new(vec!['é', '\u{1F4A9}'].into_iter()).collect::<Vec<u16>>(),
                [0xE9, 0xD83D, 0xDCA9])
 }