1 use maud::{self, html};
2 
3 #[test]
issue_13()4 fn issue_13() {
5     let owned = String::from("yay");
6     let _ = html! { (owned) };
7     // Make sure the `html!` call didn't move it
8     let _owned = owned;
9 }
10 
11 #[test]
issue_21()12 fn issue_21() {
13     macro_rules! greet {
14         () => {{
15             let name = "Pinkie Pie";
16             html! {
17                 p { "Hello, " (name) "!" }
18             }
19         }};
20     }
21 
22     assert_eq!(greet!().into_string(), "<p>Hello, Pinkie Pie!</p>");
23 }
24 
25 #[test]
issue_21_2()26 fn issue_21_2() {
27     macro_rules! greet {
28         ($name:expr) => {{
29             html! {
30                 p { "Hello, " ($name) "!" }
31             }
32         }};
33     }
34 
35     assert_eq!(
36         greet!("Pinkie Pie").into_string(),
37         "<p>Hello, Pinkie Pie!</p>"
38     );
39 }
40 
41 #[test]
issue_23()42 fn issue_23() {
43     macro_rules! wrapper {
44         ($($x:tt)*) => {{
45             html! { $($x)* }
46         }}
47     }
48 
49     let name = "Lyra";
50     let result = wrapper!(p { "Hi, " (name) "!" });
51     assert_eq!(result.into_string(), "<p>Hi, Lyra!</p>");
52 }
53 
54 #[test]
render_impl()55 fn render_impl() {
56     struct R(&'static str);
57     impl maud::Render for R {
58         fn render_to(&self, w: &mut String) {
59             w.push_str(self.0);
60         }
61     }
62 
63     let r = R("pinkie");
64     // Since `R` is not `Copy`, this shows that Maud will auto-ref splice
65     // arguments to find a `Render` impl
66     let result_a = html! { (r) };
67     let result_b = html! { (r) };
68     assert_eq!(result_a.into_string(), "pinkie");
69     assert_eq!(result_b.into_string(), "pinkie");
70 }
71 
72 #[test]
issue_97()73 fn issue_97() {
74     use maud::Render;
75 
76     struct Pinkie;
77     impl Render for Pinkie {
78         fn render(&self) -> maud::Markup {
79             let x = 42;
80             html! { (x) }
81         }
82     }
83 
84     assert_eq!(html! { (Pinkie) }.into_string(), "42");
85 }
86