mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Added tests to drain an empty vec
Discovered this kind of issue in an unrelated library. The author copied the tests from here and AFAIK, there are no tests for this particular case. Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>
This commit is contained in:
parent
a118ee2c13
commit
fa9af6a9be
@ -609,6 +609,17 @@ fn test_move_items_zero_sized() {
|
||||
assert_eq!(vec2, [(), (), ()]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_drain_empty_vec() {
|
||||
let mut vec: Vec<i32> = vec![];
|
||||
let mut vec2: Vec<i32> = vec![];
|
||||
for i in vec.drain(..) {
|
||||
vec2.push(i);
|
||||
}
|
||||
assert!(vec.is_empty());
|
||||
assert!(vec2.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_drain_items() {
|
||||
let mut vec = vec![1, 2, 3];
|
||||
|
Loading…
Reference in New Issue
Block a user