]> git.lizzy.rs Git - rust.git/commitdiff
string: Add test for FromIterator<char> and Extend<char>
authorbluss <bluss>
Sun, 7 Dec 2014 20:43:11 +0000 (21:43 +0100)
committerbluss <bluss>
Sun, 7 Dec 2014 22:12:45 +0000 (23:12 +0100)
src/libcollections/string.rs

index ed578f3f515b65603c1e46f2b0832ad159fbfb19..1af6d27953db1fa8dd6bab66d3812df0f731c752 100644 (file)
@@ -1330,6 +1330,20 @@ fn test_vectors() {
                "[[], [1], [1, 1]]".to_string());
     }
 
+    #[test]
+    fn test_from_iterator() {
+        let s = "ศไทย中华Việt Nam".to_string();
+        let t = "ศไทย中华";
+        let u = "Việt Nam";
+
+        let a: String = s.chars().collect();
+        assert_eq!(s, a.as_slice());
+
+        let mut b = t.to_string();
+        b.extend(u.chars());
+        assert_eq!(s, b.as_slice());
+    }
+
     #[bench]
     fn bench_with_capacity(b: &mut Bencher) {
         b.iter(|| {