Skip to content

Commit

Permalink
Add tests for from_vec.
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioBenitez committed Mar 29, 2017
1 parent bd892e8 commit 0bf0141
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1388,4 +1388,37 @@ pub mod tests {
let vec = SmallVec::<[u8; 2]>::from_iter(0..3);
assert_eq!(vec.into_vec(), vec![0, 1, 2]);
}

#[test]
fn test_from_vec() {
let vec = vec![];
let small_vec: SmallVec<[u8; 3]> = SmallVec::from_vec(vec);
assert_eq!(&*small_vec, &[]);
drop(small_vec);

let vec = vec![];
let small_vec: SmallVec<[u8; 1]> = SmallVec::from_vec(vec);
assert_eq!(&*small_vec, &[]);
drop(small_vec);

let vec = vec![1];
let small_vec: SmallVec<[u8; 3]> = SmallVec::from_vec(vec);
assert_eq!(&*small_vec, &[1]);
drop(small_vec);

let vec = vec![1, 2, 3];
let small_vec: SmallVec<[u8; 3]> = SmallVec::from_vec(vec);
assert_eq!(&*small_vec, &[1, 2, 3]);
drop(small_vec);

let vec = vec![1, 2, 3, 4, 5];
let small_vec: SmallVec<[u8; 3]> = SmallVec::from_vec(vec);
assert_eq!(&*small_vec, &[1, 2, 3, 4, 5]);
drop(small_vec);

let vec = vec![1, 2, 3, 4, 5];
let small_vec: SmallVec<[u8; 1]> = SmallVec::from_vec(vec);
assert_eq!(&*small_vec, &[1, 2, 3, 4, 5]);
drop(small_vec);
}
}

0 comments on commit 0bf0141

Please sign in to comment.