diff --git a/src/ast.rs b/src/ast.rs index 81ba4b76..897bc956 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -2323,43 +2323,3 @@ impl Expr { true } } - -#[cfg(test)] -mod tests { - /// This test is to make sure no code changes increase the sizes of critical data structures. - #[test] - fn check_struct_sizes() { - use crate::*; - use std::mem::size_of; - - let packed = cfg!(all( - target_pointer_width = "32", - feature = "only_i32", - feature = "no_float" - )); - - assert_eq!(size_of::(), if packed { 8 } else { 16 }); - assert_eq!(size_of::>(), if packed { 8 } else { 16 }); - #[cfg(not(feature = "no_position"))] - assert_eq!(size_of::(), 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::(), - if cfg!(feature = "no_smartstring") { - 80 - } else { - 96 - } - ); - 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); - } -} diff --git a/src/lib.rs b/src/lib.rs index 1466bbb7..e7853cda 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -93,6 +93,7 @@ pub mod packages; mod parse; pub mod plugin; mod scope; +mod tests; mod token; mod r#unsafe; diff --git a/src/tests.rs b/src/tests.rs new file mode 100644 index 00000000..3331b50f --- /dev/null +++ b/src/tests.rs @@ -0,0 +1,39 @@ +//! Module containing unit tests. +#![cfg(test)] + +/// This test is to make sure no code changes increase the sizes of critical data structures. +#[test] +fn check_struct_sizes() { + use crate::*; + use std::mem::size_of; + + const PACKED: bool = cfg!(all( + target_pointer_width = "32", + feature = "only_i32", + feature = "no_float" + )); + + assert_eq!(size_of::(), if PACKED { 8 } else { 16 }); + assert_eq!(size_of::>(), if PACKED { 8 } else { 16 }); + #[cfg(not(feature = "no_position"))] + assert_eq!(size_of::(), 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::(), + if cfg!(feature = "no_smartstring") { + 80 + } else { + 96 + } + ); + 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); +}