]> git.lizzy.rs Git - rust.git/blobdiff - library/alloc/tests/string.rs
Rollup merge of #75146 - tmiasko:range-overflow, r=Mark-Simulacrum
[rust.git] / library / alloc / tests / string.rs
index e2eb042f791723e860a265860c4f6135f395802f..7ba1c2c611686c8a128f66a448fdc29266e6e7cf 100644 (file)
@@ -279,17 +279,21 @@ fn test_split_off_mid_char() {
 #[test]
 fn test_split_off_ascii() {
     let mut ab = String::from("ABCD");
+    let orig_capacity = ab.capacity();
     let cd = ab.split_off(2);
     assert_eq!(ab, "AB");
     assert_eq!(cd, "CD");
+    assert_eq!(ab.capacity(), orig_capacity);
 }
 
 #[test]
 fn test_split_off_unicode() {
     let mut nihon = String::from("日本語");
+    let orig_capacity = nihon.capacity();
     let go = nihon.split_off("日本".len());
     assert_eq!(nihon, "日本");
     assert_eq!(go, "語");
+    assert_eq!(nihon.capacity(), orig_capacity);
 }
 
 #[test]
@@ -750,3 +754,11 @@ fn test_from_char() {
     let s: String = 'x'.into();
     assert_eq!(s, 'x'.to_string());
 }
+
+#[test]
+fn test_str_concat() {
+    let a: String = "hello".to_string();
+    let b: String = "world".to_string();
+    let s: String = format!("{}{}", a, b);
+    assert_eq!(s.as_bytes()[9], 'd' as u8);
+}