diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-08-10 07:38:34 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-08-10 09:27:33 +0200 |
commit | 1e0ee705a8e295ebddd31a472990133d34ad3465 (patch) | |
tree | 203bc040015dee5a69592c531de4741ac6a03f91 /testing/tests | |
parent | ffc74a1775f6e4bbd8cd161fd68d814ec981f3c2 (diff) | |
download | askama-1e0ee705a8e295ebddd31a472990133d34ad3465.tar.gz askama-1e0ee705a8e295ebddd31a472990133d34ad3465.tar.bz2 askama-1e0ee705a8e295ebddd31a472990133d34ad3465.zip |
Propagate format errors and rename `render_to()` to `render_into()`
Diffstat (limited to '')
-rw-r--r-- | testing/tests/filters.rs | 4 | ||||
-rw-r--r-- | testing/tests/include.rs | 2 | ||||
-rw-r--r-- | testing/tests/inheritance.rs | 4 | ||||
-rw-r--r-- | testing/tests/loops.rs | 4 | ||||
-rw-r--r-- | testing/tests/operators.rs | 4 | ||||
-rw-r--r-- | testing/tests/simple.rs | 28 |
6 files changed, 23 insertions, 23 deletions
diff --git a/testing/tests/filters.rs b/testing/tests/filters.rs index 0b1b7c9..665e50d 100644 --- a/testing/tests/filters.rs +++ b/testing/tests/filters.rs @@ -14,7 +14,7 @@ fn filter_escape() { let s = TestTemplate { strvar: "my <html> is unsafe & should be escaped".to_string(), }; - assert_eq!(s.render(), + assert_eq!(s.render().unwrap(), "my <html> is unsafe & should be escaped"); } @@ -28,5 +28,5 @@ struct FormatTemplate<'a> { #[test] fn filter_format() { let t = FormatTemplate { var: "formatted" }; - assert_eq!(t.render(), "\"formatted\""); + assert_eq!(t.render().unwrap(), "\"formatted\""); } diff --git a/testing/tests/include.rs b/testing/tests/include.rs index 7ddccd2..d2998a1 100644 --- a/testing/tests/include.rs +++ b/testing/tests/include.rs @@ -15,5 +15,5 @@ fn test_include() { let s = IncludeTemplate { strs: &strs, }; - assert_eq!(s.render(), "INCLUDED: fooINCLUDED: bar") + assert_eq!(s.render().unwrap(), "INCLUDED: fooINCLUDED: bar") } diff --git a/testing/tests/inheritance.rs b/testing/tests/inheritance.rs index 5993cd6..ca267e1 100644 --- a/testing/tests/inheritance.rs +++ b/testing/tests/inheritance.rs @@ -18,11 +18,11 @@ struct ChildTemplate<'a> { #[test] fn test_use_base_directly() { let t = BaseTemplate { title: "Foo" }; - assert_eq!(t.render(), "Foo\n\nCopyright 2017"); + assert_eq!(t.render().unwrap(), "Foo\n\nCopyright 2017"); } #[test] fn test_simple_extends() { let t = ChildTemplate { _parent: BaseTemplate { title: "Bar" } }; - assert_eq!(t.render(), "Bar\n(Bar) Content goes here\nCopyright 2017"); + assert_eq!(t.render().unwrap(), "Bar\n(Bar) Content goes here\nCopyright 2017"); } diff --git a/testing/tests/loops.rs b/testing/tests/loops.rs index eedbfa0..3125598 100644 --- a/testing/tests/loops.rs +++ b/testing/tests/loops.rs @@ -14,7 +14,7 @@ fn test_for() { let s = ForTemplate { strings: vec!["A", "alfa", "1"], }; - assert_eq!(s.render(), "0. A\n1. alfa\n2. 1\n"); + assert_eq!(s.render().unwrap(), "0. A\n1. alfa\n2. 1\n"); } @@ -31,5 +31,5 @@ fn test_nested_for() { let s = NestedForTemplate { seqs: vec![&alpha, &numbers], }; - assert_eq!(s.render(), "1\n 0a1b2c2\n 0one1two"); + assert_eq!(s.render().unwrap(), "1\n 0a1b2c2\n 0one1two"); } diff --git a/testing/tests/operators.rs b/testing/tests/operators.rs index 73b30b1..c58f650 100644 --- a/testing/tests/operators.rs +++ b/testing/tests/operators.rs @@ -14,7 +14,7 @@ struct CompareTemplate { #[test] fn test_compare() { let t = CompareTemplate { a: 1, b: 1, c: 2 }; - assert_eq!(t.render(), "tf\ntf\ntf\ntf\ntf\ntf"); + assert_eq!(t.render().unwrap(), "tf\ntf\ntf\ntf\ntf\ntf"); } @@ -29,5 +29,5 @@ struct OperatorsTemplate { #[test] fn test_operators() { let t = OperatorsTemplate { a: 1, b: 1, c: 2 }; - assert_eq!(t.render(), "muldivmodaddrshlshbandbxorborandor"); + assert_eq!(t.render().unwrap(), "muldivmodaddrshlshbandbxorborandor"); } diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index c924e85..b9b7a7c 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -18,10 +18,10 @@ fn test_variables() { num: 42, i18n: "Iñtërnâtiônàlizætiøn".to_string(), }; - assert_eq!(s.render(), "\nhello world, foo\n\ - with number: 42\n\ - Iñtërnâtiônàlizætiøn is important\n\ - in vars too: Iñtërnâtiônàlizætiøn"); + assert_eq!(s.render().unwrap(), "\nhello world, foo\n\ + with number: 42\n\ + Iñtërnâtiônàlizætiøn is important\n\ + in vars too: Iñtërnâtiônàlizætiøn"); } @@ -34,7 +34,7 @@ struct IfTemplate { #[test] fn test_if() { let s = IfTemplate { cond: true }; - assert_eq!(s.render(), "true"); + assert_eq!(s.render().unwrap(), "true"); } @@ -47,7 +47,7 @@ struct ElseTemplate { #[test] fn test_else() { let s = ElseTemplate { cond: false }; - assert_eq!(s.render(), "false"); + assert_eq!(s.render().unwrap(), "false"); } @@ -61,7 +61,7 @@ struct ElseIfTemplate { #[test] fn test_else_if() { let s = ElseIfTemplate { cond: false, check: true }; - assert_eq!(s.render(), "checked"); + assert_eq!(s.render().unwrap(), "checked"); } @@ -72,7 +72,7 @@ struct LiteralsTemplate {} #[test] fn test_literals() { let s = LiteralsTemplate {}; - assert_eq!(s.render(), "a"); + assert_eq!(s.render().unwrap(), "a"); } @@ -89,7 +89,7 @@ struct AttrTemplate { #[test] fn test_attr() { let t = AttrTemplate { inner: Holder { a: 5 } }; - assert_eq!(t.render(), "5"); + assert_eq!(t.render().unwrap(), "5"); } @@ -108,7 +108,7 @@ fn test_nested_attr() { let t = NestedAttrTemplate { inner: NestedHolder { holder: Holder { a: 5 } } }; - assert_eq!(t.render(), "5"); + assert_eq!(t.render().unwrap(), "5"); } @@ -121,9 +121,9 @@ struct OptionTemplate<'a> { #[test] fn test_option() { let some = OptionTemplate { var: Some("foo") }; - assert_eq!(some.render(), "some: foo"); + assert_eq!(some.render().unwrap(), "some: foo"); let none = OptionTemplate { var: None }; - assert_eq!(none.render(), "none"); + assert_eq!(none.render().unwrap(), "none"); } @@ -138,7 +138,7 @@ struct GenericsTemplate<T: std::fmt::Display, U = u8> #[test] fn test_generics() { let t = GenericsTemplate { t: "a", u: 42 }; - assert_eq!(t.render(), "a42"); + assert_eq!(t.render().unwrap(), "a42"); } @@ -152,5 +152,5 @@ struct JsonTemplate<'a> { #[test] fn test_json() { let t = JsonTemplate { foo: "a", bar: "b" }; - assert_eq!(t.render(), "{\"foo\": \"a\", \"bar\": \"b\"}"); + assert_eq!(t.render().unwrap(), "{\"foo\": \"a\", \"bar\": \"b\"}"); } |