]> git.lizzy.rs Git - rust.git/blob - tests/run-pass/vecs.rs
various testing improvements
[rust.git] / tests / run-pass / vecs.rs
1 #![feature(custom_attribute)]
2 #![allow(dead_code, unused_attributes)]
3
4 #[miri_run]
5 fn make_vec() -> Vec<u8> {
6     let mut v = Vec::with_capacity(4);
7     v.push(1);
8     v.push(2);
9     v
10 }
11
12 #[miri_run]
13 fn make_vec_macro() -> Vec<u8> {
14     vec![1, 2]
15 }
16
17 #[miri_run]
18 fn make_vec_macro_repeat() -> Vec<u8> {
19     vec![42; 5]
20 }
21
22 #[miri_run]
23 fn vec_into_iter() -> u8 {
24     vec![1, 2, 3, 4]
25         .into_iter()
26         .map(|x| x * x)
27         .fold(0, |x, y| x + y)
28 }
29
30 #[miri_run]
31 fn vec_reallocate() -> Vec<u8> {
32     let mut v = vec![1, 2];
33     v.push(3);
34     v.push(4);
35     v.push(5);
36     v
37 }
38
39 #[miri_run]
40 fn main() {
41     assert_eq!(vec_reallocate().len(), 5);
42     assert_eq!(vec_into_iter(), 30);
43     assert_eq!(make_vec().capacity(), 4);
44 }