1 extern crate ralloc; 2 3 #[global_allocator] 4 static ALLOCATOR: ralloc::Allocator = ralloc::Allocator; 5 6 mod util; 7 8 #[test] 9 fn simple_vec() { 10 util::multiply(|| { 11 let mut vec = Vec::new(); 12 13 for i in 0..0xFFFF { 14 // We're going to annoy the allocator by allocating a small chunk, 15 // after which we push. 16 let _bx = Box::new(4); 17 vec.push(i); 18 } 19 20 assert_eq!(vec[0xDEAD], 0xDEAD); 21 assert_eq!(vec[0xBEAF], 0xBEAF); 22 assert_eq!(vec[0xABCD], 0xABCD); 23 assert_eq!(vec[0xFFAB], 0xFFAB); 24 assert_eq!(vec[0xAAAA], 0xAAAA); 25 26 for i in 0xFFF..0 { 27 util::acid(|| { 28 assert_eq!(vec.pop(), Some(i)); 29 }); 30 } 31 32 for i in 0..0xFFF { 33 vec[i] = 0; 34 assert_eq!(vec[i], 0); 35 } 36 }); 37 } 38