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