From 03d90694561cb4843727b1beef025283667efebb Mon Sep 17 00:00:00 2001 From: Zachary S Date: Thu, 9 May 2024 21:21:22 -0500 Subject: [PATCH] Make test_size test aware of target pointer width and "union" feature. --- src/tests.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/tests.rs b/src/tests.rs index f53100c..d04771e 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -996,7 +996,23 @@ fn test_clone_from() { #[test] fn test_size() { use core::mem::size_of; - assert_eq!(24, size_of::>()); + const PTR_SIZE: usize = size_of::(); + #[cfg(feature = "union")] + { + assert_eq!(3 * PTR_SIZE, size_of::>()); + assert_eq!(3 * PTR_SIZE, size_of::>()); + assert_eq!(3 * PTR_SIZE, size_of::>()); + assert_eq!(3 * PTR_SIZE, size_of::>()); + assert_eq!(3 * PTR_SIZE, size_of::>()); + assert_eq!(4 * PTR_SIZE, size_of::>()); + } + #[cfg(not(feature = "union"))] + { + assert_eq!(3 * PTR_SIZE, size_of::>()); + assert_eq!(3 * PTR_SIZE, size_of::>()); + assert_eq!(3 * PTR_SIZE, size_of::>()); + assert_eq!(4 * PTR_SIZE, size_of::>()); + } } #[cfg(feature = "drain_filter")]