Files
web-macro/tests/tests.rs
2026-03-02 22:45:57 +01:00

55 lines
1.2 KiB
Rust

#[cfg(test)]
mod tests {
use web_macro::*;
#[test]
fn test_function() {
assert_eq!("<h1>test</h1>", heading1!(String::from("test")));
}
#[test]
fn test_literal() {
assert_eq!("<h1>test</h1>", heading1!("test"));
}
#[test]
fn test_recursive() {
assert_eq!("<h1><h1>test</h1></h1>", heading1!(heading1!("test")));
}
#[test]
fn test_options_literal() {
assert_eq!(
"<h1 id=\"oui\" class=\"test\">test</h1>",
heading1!("test", id = "oui", class = "test")
);
}
#[test]
fn test_options_functional() {
assert_eq!(
"<h1 id=\"oui\" class=\"test\" pseudo=\"adolf\">test</h1>",
heading1!(
"test",
id = String::from("oui"),
class = String::from("test"),
pseudo = {
let mut s = String::new();
s.push_str("adolf");
s
}
)
);
}
#[test]
fn test_level() {
assert_eq!("<h2>test</h2>", heading2!("test"))
}
#[test]
fn test_level_options() {
assert_eq!("<h3 id=\"oui\">test</h3>", heading3!("test", id = "oui"))
}
}