Skip to content

Commit 56c4e97

Browse files
author
bluss
committed
string: Add test for FromIterator<char> and Extend<char>
1 parent 5ba7c5d commit 56c4e97

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/libcollections/string.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,20 @@ mod tests {
13301330
"[[], [1], [1, 1]]".to_string());
13311331
}
13321332

1333+
#[test]
1334+
fn test_from_iterator() {
1335+
let s = "ศไทย中华Việt Nam".to_string();
1336+
let t = "ศไทย中华";
1337+
let u = "Việt Nam";
1338+
1339+
let a: String = s.chars().collect();
1340+
assert_eq!(s, a.as_slice());
1341+
1342+
let mut b = t.to_string();
1343+
b.extend(u.chars());
1344+
assert_eq!(s, b.as_slice());
1345+
}
1346+
13331347
#[bench]
13341348
fn bench_with_capacity(b: &mut Bencher) {
13351349
b.iter(|| {

0 commit comments

Comments
 (0)