From 442f8677ccc1fce18f91055c6948bc30a98486bc Mon Sep 17 00:00:00 2001 From: Yun-Jhong Wu Date: Mon, 1 Jan 2024 22:17:48 -0600 Subject: [PATCH] Unit test for size --- strong-type-tests/tests/strong_type.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/strong-type-tests/tests/strong_type.rs b/strong-type-tests/tests/strong_type.rs index 483a1fd..6664d1d 100644 --- a/strong-type-tests/tests/strong_type.rs +++ b/strong-type-tests/tests/strong_type.rs @@ -2,6 +2,7 @@ mod tests { use std::any::Any; use std::collections::HashSet; + use std::mem; use strong_type::StrongType; fn test_type() {} @@ -11,70 +12,87 @@ mod tests { #[derive(StrongType)] struct NamedI8(i8); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); #[derive(StrongType)] struct NamedI16(i16); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); #[derive(StrongType)] struct NamedI32(i32); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); #[derive(StrongType)] struct NamedI64(i64); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); #[derive(StrongType)] struct NamedI128(i128); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); #[derive(StrongType)] struct NamedISize(isize); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); #[derive(StrongType)] struct NamedU8(u8); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); #[derive(StrongType)] struct NamedU16(u16); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); #[derive(StrongType)] struct NamedU32(u32); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); #[derive(StrongType)] struct NamedU64(u64); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); #[derive(StrongType)] struct NamedU128(u128); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); #[derive(StrongType)] struct NamedUSize(usize); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); #[derive(StrongType)] struct NamedF32(f32); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); #[derive(StrongType)] struct NamedF64(f64); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); #[derive(StrongType)] struct NamedBool(bool); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); #[derive(StrongType)] struct NamedChar(char); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); #[derive(StrongType)] struct NamedString(String); test_type::(); + assert_eq!(mem::size_of::(), mem::size_of::()); } #[test]