]> git.lizzy.rs Git - rust.git/commitdiff
Add test for string AddAssign
authorKnight <knight42@mail.ustc.edu.cn>
Tue, 26 Jul 2016 18:30:50 +0000 (02:30 +0800)
committerKnight <knight42@mail.ustc.edu.cn>
Wed, 27 Jul 2016 22:08:56 +0000 (06:08 +0800)
src/libcollectionstest/string.rs

index 7f0fd282ae5e943f32b7f281a7c2f9137f2f50d7..1652fb5a88d80dc46d1089adbb277cf9fa330ba7 100644 (file)
@@ -192,6 +192,17 @@ fn test_push_str() {
     assert_eq!(&s[0..], "abcประเทศไทย中华Việt Nam");
 }
 
+#[test]
+fn test_add_assign() {
+    let mut s = String::new();
+    s += "";
+    assert_eq!(s.as_str(), "");
+    s += "abc";
+    assert_eq!(s.as_str(), "abc");
+    s += "ประเทศไทย中华Việt Nam";
+    assert_eq!(s.as_str(), "abcประเทศไทย中华Việt Nam");
+}
+
 #[test]
 fn test_push() {
     let mut data = String::from("ประเทศไทย中");