use crate::test::types::{ CompoundOnWideSeven, CompoundSeven, CompoundWideOnSeven, Seventeen, Sixteen, StructOne, StructThree, Three, ThreeHundred, WideThree, }; use enumoid::EnumArrayHelper; use enumoid::EnumMap; use enumoid::EnumOptionMap; use enumoid::EnumSet; use enumoid::EnumSetHelper; use enumoid::EnumSize; use enumoid::EnumVec; fn align_word(x: usize, align: usize) -> usize { ((x + align - 1) / align) * align } fn test_type< T: EnumArrayHelper + EnumSetHelper + EnumSetHelper, >( variants: usize, value_bytes: usize, word_bytes: usize, set_bytes: usize, ) { assert_eq!(T::SIZE, variants); assert_eq!(std::mem::size_of::(), value_bytes); assert_eq!(std::mem::size_of::>(), word_bytes); assert_eq!(std::mem::size_of::>(), set_bytes); assert_eq!( std::mem::size_of::>(), align_word(set_bytes, std::mem::size_of::()) ); assert_eq!(std::mem::size_of::>(), variants); assert_eq!( std::mem::size_of::>(), set_bytes + variants ); assert_eq!( std::mem::size_of::>(), word_bytes + align_word(variants, word_bytes) ); } #[test] fn test_three() { test_type::(3, 1, 1, 1); test_type::(3, 1, 4, 1); } #[test] fn test_struct() { test_type::(1, 0, 1, 1); test_type::(3, 1, 1, 1); } #[test] fn test_compound_seven() { test_type::(7, 2, 1, 1); test_type::(7, 2, 1, 1); test_type::(7, 2, 4, 1); } #[test] fn test_sixteen() { test_type::(16, 1, 1, 2); } #[test] fn test_seventeen() { test_type::(17, 1, 1, 3); } #[test] fn test_three_hundred() { test_type::(300, 2, 2, 38); }