Skip to content

Commit

Permalink
Added constants test
Browse files Browse the repository at this point in the history
  • Loading branch information
vallentin committed Jan 11, 2021
1 parent 9de5799 commit 06e0702
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions testing/tests/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,36 @@ fn test_variables_no_escape() {
);
}

const FOO: &str = "FOO";
const FOO_BAR: &str = "FOO BAR";

#[derive(Template)]
#[template(
source = "{{ foo }} {{ foo_bar }} {{ FOO }} {{ FOO_BAR }} {{ self::FOO }} {{ self::FOO_BAR }} {{ Self::BAR }} {{ Self::BAR_BAZ }}",
ext = "txt"
)]
struct ConstTemplate {
foo: &'static str,
foo_bar: &'static str,
}

impl ConstTemplate {
const BAR: &'static str = "BAR";
const BAR_BAZ: &'static str = "BAR BAZ";
}

#[test]
fn test_constants() {
let t = ConstTemplate {
foo: "foo",
foo_bar: "foo bar",
};
assert_eq!(
t.render().unwrap(),
"foo foo bar FOO FOO BAR FOO FOO BAR BAR BAR BAZ"
);
}

#[derive(Template)]
#[template(path = "if.html")]
struct IfTemplate {
Expand Down

0 comments on commit 06e0702

Please sign in to comment.