From 932050d82212ee7db6bd4cb746fb79f40aa7cbf9 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 27 Feb 2026 20:25:05 +0800 Subject: Initialize project with Cargo.toml and basic structure --- src/test.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/test.rs (limited to 'src/test.rs') diff --git a/src/test.rs b/src/test.rs new file mode 100644 index 0000000..f824b1b --- /dev/null +++ b/src/test.rs @@ -0,0 +1,28 @@ +#[cfg(test)] +mod tests { + use crate::{Template, tmpl, tmpl_param}; + + #[test] + fn expand() { + let input = std::fs::read_to_string("./src/test_input.txt") + .unwrap() + .trim() + .to_string(); + let expect = std::fs::read_to_string("./src/test_expect.txt") + .unwrap() + .trim() + .to_string(); + + let mut tmpl = Template::from(input); + tmpl_param!(tmpl, func_name = "my_func"); + tmpl!(tmpl += { + arms { + (crate_name = "my"), + (crate_name = "you") + } + }); + + let expanded = tmpl.expand().unwrap(); + assert_eq!(expanded, expect); + } +} -- cgit