1 //! 需要测试的时候可以在这里写测试代码, 2 //! 然后在当前目录执行 `cargo expand --bin unified-init-expand` 3 //! 就可以看到把proc macro展开后的代码了 4 #![no_std] 5 6 fn main() { 7 todo!() 8 } 9 10 #[cfg(test)] 11 mod tests { 12 use system_error::SystemError; 13 use unified_init::define_unified_initializer_slice; 14 use unified_init_macros::unified_init; 15 16 use super::*; 17 18 #[test] 19 fn no_element() { 20 define_unified_initializer_slice!(TEST_0); 21 22 assert_eq!(TEST_0.len(), 0); 23 } 24 25 #[test] 26 fn no_element_ne() { 27 define_unified_initializer_slice!(TEST_0_NE); 28 29 #[unified_init(TEST_0_NE)] 30 fn x() -> Result<(), SystemError> { 31 todo!() 32 } 33 34 assert_ne!(TEST_0_NE.len(), 0); 35 } 36 37 #[test] 38 fn one_element() { 39 define_unified_initializer_slice!(TEST_1); 40 41 #[unified_init(TEST_1)] 42 fn x() -> Result<(), SystemError> { 43 todo!() 44 } 45 assert_eq!(TEST_1.len(), 1); 46 } 47 48 #[test] 49 fn two_elements() { 50 define_unified_initializer_slice!(TEST_2); 51 52 #[unified_init(TEST_2)] 53 fn x() -> Result<(), SystemError> { 54 todo!() 55 } 56 57 #[unified_init(TEST_2)] 58 fn y() -> Result<(), SystemError> { 59 todo!() 60 } 61 assert_eq!(TEST_2.len(), 2); 62 } 63 } 64