aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorLibravatar Vicente Ramirez Perea <vicente.ramirez.perea@gmail.com>2019-03-05 23:46:07 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2019-03-18 10:19:48 +0100
commitd59f5d7c1a2b46b01df43b6fc45080a1ab0ec024 (patch)
tree71e66870aa98e0a89e11793c30e54b23baf4162f /testing
parent5b2e9cf99274827079f70f10966f6284d075e624 (diff)
downloadaskama-d59f5d7c1a2b46b01df43b6fc45080a1ab0ec024.tar.gz
askama-d59f5d7c1a2b46b01df43b6fc45080a1ab0ec024.tar.bz2
askama-d59f5d7c1a2b46b01df43b6fc45080a1ab0ec024.zip
Fmt and complete test avoiding warning unused variant.
Diffstat (limited to 'testing')
-rw-r--r--testing/tests/render_with_enums.rs44
1 files changed, 29 insertions, 15 deletions
diff --git a/testing/tests/render_with_enums.rs b/testing/tests/render_with_enums.rs
index fb97e54..541252e 100644
--- a/testing/tests/render_with_enums.rs
+++ b/testing/tests/render_with_enums.rs
@@ -1,12 +1,12 @@
use askama::Template;
-enum SectionOneType<'a>{
+enum SectionOneType<'a> {
Empty(TEmpty),
Simple(TSecOneSimple<'a>),
- Full(TSecOneFull<'a>)
+ Full(TSecOneFull<'a>),
}
impl<'a> SectionOneType<'a> {
- pub fn render(&self) -> askama::Result<String>{
+ pub fn render(&self) -> askama::Result<String> {
match self {
SectionOneType::Empty(v) => v.render(),
SectionOneType::Simple(v) => v.render(),
@@ -14,12 +14,12 @@ impl<'a> SectionOneType<'a> {
}
}
}
-enum SectionTwoFormat<'a>{
+enum SectionTwoFormat<'a> {
Html(TSecTwoHtml<'a>),
Text(TSecTwoText<'a>),
}
impl<'a> SectionTwoFormat<'a> {
- pub fn render(&self) -> askama::Result<String>{
+ pub fn render(&self) -> askama::Result<String> {
match self {
SectionTwoFormat::Html(v) => v.render(),
SectionTwoFormat::Text(v) => v.render(),
@@ -31,23 +31,22 @@ impl<'a> SectionTwoFormat<'a> {
struct RenderInPlace<'a> {
s1: SectionOneType<'a>,
s2: SectionTwoFormat<'a>,
- s3: &'a Vec<SectionOneType<'a>>
+ s3: &'a Vec<SectionOneType<'a>>,
}
#[derive(Template)]
#[template(source = "", ext = "txt")]
-struct TEmpty {
-}
+struct TEmpty {}
#[derive(Template)]
#[template(source = "{{ a }}", ext = "txt")]
struct TSecOneSimple<'a> {
- a: &'a str
+ a: &'a str,
}
#[derive(Template)]
#[template(source = "{{ a }}, {{ b }}", ext = "txt")]
struct TSecOneFull<'a> {
a: &'a str,
- b: &'a str
+ b: &'a str,
}
#[derive(Template)]
@@ -68,13 +67,28 @@ fn test_render_with_enums() {
let t = RenderInPlace {
s1: SectionOneType::Empty(TEmpty {}),
s2: SectionTwoFormat::Html(TSecTwoHtml { c: "C", d: "D" }),
- s3: &vec![SectionOneType::Empty(TEmpty {}),
- SectionOneType::Simple(TSecOneSimple { a: "A" }),
- SectionOneType::Full(TSecOneFull { a: "A", b: "B" }),
- ]
+ s3: &vec![
+ SectionOneType::Empty(TEmpty {}),
+ SectionOneType::Simple(TSecOneSimple { a: "A" }),
+ SectionOneType::Full(TSecOneFull { a: "A", b: "B" }),
+ ],
};
assert_eq!(
t.render().unwrap(),
- "Section 1: \nSection 2: <span>C</span><p>D</p>\nSection 3 for:\n* \n* A\n* A, B\n"
+ "Section 1: \nSection 2: <span>C</span><p>D</p>\nSection 3 for:\n* \n* A\n* A, B\n"
);
+ let t = RenderInPlace {
+ s1: SectionOneType::Empty(TEmpty {}),
+ s2: SectionTwoFormat::Text(TSecTwoText { c: "C", d: "D" }),
+ s3: &vec![
+ SectionOneType::Empty(TEmpty {}),
+ SectionOneType::Simple(TSecOneSimple { a: "A" }),
+ SectionOneType::Full(TSecOneFull { a: "A", b: "B" }),
+ ],
+ };
+ assert_eq!(
+ t.render().unwrap(),
+ "Section 1: \nSection 2: C, D\nSection 3 for:\n* \n* A\n* A, B\n"
+ );
+
}