about summary refs log tree commit diff
path: root/library/alloc
diff options
context:
space:
mode:
authorAlexis Bourget <alexis.bourget@gmail.com>2020-10-03 18:49:23 +0200
committerAlexis Bourget <alexis.bourget@gmail.com>2020-10-17 18:48:20 +0200
commit4fd06b9bb566aa444fb293bbe7ef1eef71bc1e08 (patch)
tree632af95145835016c4762d10befd0f0715ad0391 /library/alloc
parent85afbd8a15a7e37b35a0653693bd6acf3138f301 (diff)
downloadrust-4fd06b9bb566aa444fb293bbe7ef1eef71bc1e08.tar.gz
rust-4fd06b9bb566aa444fb293bbe7ef1eef71bc1e08.zip
Move vec-macro-repeat test
Diffstat (limited to 'library/alloc')
-rw-r--r--library/alloc/tests/vec.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs
index 34995d7e40f..ae7518bcad0 100644
--- a/library/alloc/tests/vec.rs
+++ b/library/alloc/tests/vec.rs
@@ -1929,3 +1929,16 @@ fn test_zero_sized_vec_push() {
         tester.clear();
     }
 }
+
+#[test]
+fn test_vec_macro_repeat() {
+    assert_eq!(vec![1; 3], vec![1, 1, 1]);
+    assert_eq!(vec![1; 2], vec![1, 1]);
+    assert_eq!(vec![1; 1], vec![1]);
+    assert_eq!(vec![1; 0], vec![]);
+
+    // from_elem syntax (see RFC 832)
+    let el = Box::new(1);
+    let n = 3;
+    assert_eq!(vec![el; n], vec![Box::new(1), Box::new(1), Box::new(1)]);
+}