From 4b4a6c944d9b22982619415345b4571aaf0c6d9b Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Wed, 12 Jan 2022 11:01:03 +0800 Subject: [PATCH] Fix test. --- src/tests.rs | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/tests.rs b/src/tests.rs index ce0a89b3..322e6cdb 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -10,7 +10,7 @@ fn check_struct_sizes() { const PACKED: bool = cfg!(all( target_pointer_width = "32", feature = "only_i32", - feature = "no_float" + any(feature = "no_float", feature = "f32_float") )); assert_eq!(size_of::(), if PACKED { 8 } else { 16 }); @@ -19,24 +19,28 @@ fn check_struct_sizes() { size_of::(), if cfg!(feature = "no_position") { 0 } else { 4 } ); - assert_eq!(size_of::(), 16); - assert_eq!(size_of::>(), 16); - assert_eq!(size_of::(), 32); - assert_eq!(size_of::>(), 32); - assert_eq!(size_of::(), 80); - assert_eq!(size_of::(), 464); - assert_eq!(size_of::(), 56); - assert_eq!( - size_of::(), - if cfg!(feature = "no_position") { 8 } else { 16 } - ); - assert_eq!(size_of::(), 72); - assert_eq!( - size_of::(), - if cfg!(feature = "no_position") { - 64 - } else { - 72 - } - ); + assert_eq!(size_of::(), if PACKED { 12 } else { 16 }); + assert_eq!(size_of::>(), if PACKED { 12 } else { 16 }); + assert_eq!(size_of::(), if PACKED { 24 } else { 32 }); + assert_eq!(size_of::>(), if PACKED { 24 } else { 32 }); + assert_eq!(size_of::(), if PACKED { 40 } else { 80 }); + assert_eq!(size_of::(), if PACKED { 232 } else { 464 }); + + #[cfg(target_pointer_width = "64")] + { + assert_eq!(size_of::(), 56); + assert_eq!( + size_of::(), + if cfg!(feature = "no_position") { 8 } else { 16 } + ); + assert_eq!(size_of::(), 72); + assert_eq!( + size_of::(), + if cfg!(feature = "no_position") { + 64 + } else { + 72 + } + ); + } }