Skip to content

Commit 03d9069

Browse files
zachs18mbrubeck
authored andcommitted
Make test_size test aware of target pointer width and "union" feature.
1 parent 0089d0a commit 03d9069

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/tests.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,23 @@ fn test_clone_from() {
996996
#[test]
997997
fn test_size() {
998998
use core::mem::size_of;
999-
assert_eq!(24, size_of::<SmallVec<[u8; 8]>>());
999+
const PTR_SIZE: usize = size_of::<usize>();
1000+
#[cfg(feature = "union")]
1001+
{
1002+
assert_eq!(3 * PTR_SIZE, size_of::<SmallVec<[u8; 0]>>());
1003+
assert_eq!(3 * PTR_SIZE, size_of::<SmallVec<[u8; 1]>>());
1004+
assert_eq!(3 * PTR_SIZE, size_of::<SmallVec<[u8; PTR_SIZE]>>());
1005+
assert_eq!(3 * PTR_SIZE, size_of::<SmallVec<[u8; PTR_SIZE + 1]>>());
1006+
assert_eq!(3 * PTR_SIZE, size_of::<SmallVec<[u8; 2 * PTR_SIZE]>>());
1007+
assert_eq!(4 * PTR_SIZE, size_of::<SmallVec<[u8; 2 * PTR_SIZE + 1]>>());
1008+
}
1009+
#[cfg(not(feature = "union"))]
1010+
{
1011+
assert_eq!(3 * PTR_SIZE, size_of::<SmallVec<[u8; 0]>>());
1012+
assert_eq!(3 * PTR_SIZE, size_of::<SmallVec<[u8; 1]>>());
1013+
assert_eq!(3 * PTR_SIZE, size_of::<SmallVec<[u8; PTR_SIZE]>>());
1014+
assert_eq!(4 * PTR_SIZE, size_of::<SmallVec<[u8; PTR_SIZE + 1]>>());
1015+
}
10001016
}
10011017

10021018
#[cfg(feature = "drain_filter")]

0 commit comments

Comments
 (0)