Skip to content

Commit

Permalink
Make test_size test aware of target pointer width and "union" feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
zachs18 authored and mbrubeck committed May 10, 2024
1 parent 0089d0a commit 03d9069
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,23 @@ fn test_clone_from() {
#[test]
fn test_size() {
use core::mem::size_of;
assert_eq!(24, size_of::<SmallVec<[u8; 8]>>());
const PTR_SIZE: usize = size_of::<usize>();
#[cfg(feature = "union")]
{
assert_eq!(3 * PTR_SIZE, size_of::<SmallVec<[u8; 0]>>());
assert_eq!(3 * PTR_SIZE, size_of::<SmallVec<[u8; 1]>>());
assert_eq!(3 * PTR_SIZE, size_of::<SmallVec<[u8; PTR_SIZE]>>());
assert_eq!(3 * PTR_SIZE, size_of::<SmallVec<[u8; PTR_SIZE + 1]>>());
assert_eq!(3 * PTR_SIZE, size_of::<SmallVec<[u8; 2 * PTR_SIZE]>>());
assert_eq!(4 * PTR_SIZE, size_of::<SmallVec<[u8; 2 * PTR_SIZE + 1]>>());
}
#[cfg(not(feature = "union"))]
{
assert_eq!(3 * PTR_SIZE, size_of::<SmallVec<[u8; 0]>>());
assert_eq!(3 * PTR_SIZE, size_of::<SmallVec<[u8; 1]>>());
assert_eq!(3 * PTR_SIZE, size_of::<SmallVec<[u8; PTR_SIZE]>>());
assert_eq!(4 * PTR_SIZE, size_of::<SmallVec<[u8; PTR_SIZE + 1]>>());
}
}

#[cfg(feature = "drain_filter")]
Expand Down

0 comments on commit 03d9069

Please sign in to comment.