use skaldpress::macro_processor::MacroProcessor; fn run_macro_processor(input: &str) -> String { let mut macro_processor = MacroProcessor::new(); macro_processor.process_input(&input) } #[test] fn test_smn_empty_string() { assert_eq!( run_macro_processor(""), "" ); } #[test] fn test_smp_non_macro_html() { assert_eq!( run_macro_processor( "
This is a test
"), "This is a test
", ); } #[test] fn test_smp_define_1() { assert_eq!( run_macro_processor( "define(TEMP, testvalue) TEMP"), " testvalue", ); } #[test] fn test_smp_define_2() { assert_eq!( run_macro_processor( "define(TEMP, TEMP2)define(TEMP)ifdef(TEMP2, TEMP2_ISDEF)"), "TEMP2_ISDEF", ); } #[test] fn test_smp_dnl_1() { assert_eq!( run_macro_processor( "SNNL test"), "test", ); } #[test] fn test_smp_dnl_2() { assert_eq!( run_macro_processor( "SNNL test"), "test", ); } #[test] fn test_smp_dnl_3() { assert_eq!( run_macro_processor( "define(MAC1, test)SNNL MAC1 SNNL test"), "test test", ); } #[test] fn test_smp_ifdef_0() { assert_eq!( run_macro_processor( "define(MAC1, test)ifdef(MAC1, MAC1_ISDEF)"), "MAC1_ISDEF", ); } #[test] fn test_smp_ifdef_1() { assert_eq!( run_macro_processor( "define(MAC1, test)SNNL ifdef(MAC1, MAC1_ISDEF) ifdef(MAC2, MAC2_ISDEF, MAC2_ISNDEF)"), "MAC1_ISDEF MAC2_ISNDEF", ); } #[test] fn test_smp_ifdef_2() { assert_eq!( run_macro_processor( "ifdef(MAC, MAC_ISDEF)"), "", ); } #[test] fn test_smp_ifdef_3() { assert_eq!( run_macro_processor( "ifdef(MAC, MAC_ISDEF, MAC_ISNDEF)"), "MAC_ISNDEF", ); } #[test] fn test_smp_ifndef_1() { assert_eq!( run_macro_processor( "ifndef(MAC, MAC_ISNDEF)"), "MAC_ISNDEF", ); } #[test] fn test_smp_ifndef_2() { assert_eq!( run_macro_processor( "define(MAC, test)SNNL ifndef(MAC, MAC_ISNDEF, MAC_ISDEF)"), "MAC_ISDEF", ); } #[test] fn test_smp_ifndef_3() { assert_eq!( run_macro_processor( "define(MAC, test)SNNL ifndef(MAC, MAC_ISNDEF)"), "", ); } #[test] fn test_smp_include_1() { assert_eq!( run_macro_processor( "include(tests/example_include.smp)"), "", ); } #[test] fn test_smp_include_2() { assert_eq!( run_macro_processor( "include(tests/example_include.smp)SNNL ifdef(SMP, SMP_ISDEF, SMP_ISNDEF)"), "SMP_ISDEF", ); } #[test] fn test_smp_ifeq_1() { assert_eq!( run_macro_processor("ifeq(a, a, true, false)"), "true", ); } #[test] fn test_smp_ifeq_2() { assert_eq!( run_macro_processor("ifeq(a, b, true, false)"), "false", ); } #[test] fn test_smp_ifeq_3() { assert_eq!( run_macro_processor("ifeq(a, a, true)"), "true", ); } #[test] fn test_smp_ifeq_4() { assert_eq!( run_macro_processor("ifeq(a, b, true)"), "", ); } #[test] fn test_smp_ifneq_1() { assert_eq!( run_macro_processor("ifneq(a, a, true, false)"), "false", ); } #[test] fn test_smp_ifneq_2() { assert_eq!( run_macro_processor("ifneq(a, b, true, false)"), "true", ); } #[test] fn test_smp_ifneq_3() { assert_eq!( run_macro_processor("ifneq(a, a, true)"), "", ); } #[test] fn test_smp_ifneq_4() { assert_eq!( run_macro_processor("ifneq(a, b, true)"), "true", ); } #[test] fn test_smp_shell_1() { assert_eq!( run_macro_processor("shell(printf test)"), "test", ); } #[test] fn test_smp_expr_1() { assert_eq!( run_macro_processor("expr(1, +, 1)"), "2 ", ); }