summaryrefslogtreecommitdiff
path: root/src/test.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test.rs')
-rw-r--r--src/test.rs28
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);
+ }
+}