Move zero-sized-vec-push test

This commit is contained in:
Alexis Bourget 2020-09-14 23:35:46 +02:00
parent dda2b5e3e2
commit 4af560ecef
2 changed files with 17 additions and 20 deletions

View File

@ -1912,3 +1912,20 @@ fn new() -> C<'a> {
c3.refs.v[0].set(Some(&c1)); c3.refs.v[0].set(Some(&c1));
c3.refs.v[1].set(Some(&c2)); c3.refs.v[1].set(Some(&c2));
} }
#[test]
fn test_zero_sized_vec_push() {
const N: usize = 8;
for len in 0..N {
let mut tester = Vec::with_capacity(len);
assert_eq!(tester.len(), 0);
assert!(tester.capacity() >= len);
for _ in 0..len {
tester.push(());
}
assert_eq!(tester.len(), len);
assert_eq!(tester.iter().count(), len);
tester.clear();
}
}

View File

@ -1,20 +0,0 @@
// run-pass
#![allow(unused_variables)]
use std::iter::Iterator;
use std::vec::Vec;
fn main() {
const N: usize = 8;
for len in 0..N {
let mut tester = Vec::with_capacity(len);
assert_eq!(tester.len(), 0);
assert!(tester.capacity() >= len);
for bit in 0..len {
tester.push(());
}
assert_eq!(tester.len(), len);
assert_eq!(tester.iter().count(), len);
tester.clear();
}
}