summaryrefslogtreecommitdiff
path: root/src/test.rs
blob: a5ef8016553f0706f5bf9102a0c74cd2f071e772 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#[cfg(test)]
mod tests {
    use crate::{template::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);
    }
}