diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-02-27 20:25:05 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-02-27 22:31:21 +0800 |
| commit | 932050d82212ee7db6bd4cb746fb79f40aa7cbf9 (patch) | |
| tree | c4c868ead7191510d5a23c998658ba319dc3cdb7 /src/test.rs | |
Initialize project with Cargo.toml and basic structure
Diffstat (limited to 'src/test.rs')
| -rw-r--r-- | src/test.rs | 28 |
1 files changed, 28 insertions, 0 deletions
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); + } +} |
