Add css tests
This commit is contained in:
parent
e3aae97767
commit
aa4cacec78
38
src/main.rs
38
src/main.rs
@ -429,3 +429,41 @@ fn main() -> io::Result<()> {
|
|||||||
// drop(input);
|
// drop(input);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test_css {
|
||||||
|
use super::StyleSheet;
|
||||||
|
macro_rules! test {
|
||||||
|
($func:ident, $input:literal) => {
|
||||||
|
#[test]
|
||||||
|
fn $func() {
|
||||||
|
let mut buf = Vec::new();
|
||||||
|
StyleSheet::new($input)
|
||||||
|
.print_as_css(&mut buf)
|
||||||
|
.expect(concat!("failed to pretty print on ", $input));
|
||||||
|
assert_eq!(
|
||||||
|
String::from($input),
|
||||||
|
String::from_utf8(buf).expect("produced invalid utf8")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
($func:ident, $input:literal, $output:literal) => {
|
||||||
|
#[test]
|
||||||
|
fn $func() {
|
||||||
|
let mut buf = Vec::new();
|
||||||
|
StyleSheet::new($input)
|
||||||
|
.print_as_css(&mut buf)
|
||||||
|
.expect(concat!("failed to pretty print on ", $input));
|
||||||
|
assert_eq!(
|
||||||
|
String::from($output),
|
||||||
|
String::from_utf8(buf).expect("produced invalid utf8")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
test!(nesting_el_mul_el, "a, b {\n a, b {\n color: red\n}\n}\n", "a a, b a, a b, b b {\n color: red;\n}\n");
|
||||||
|
test!(basic_style, "a {\n color: red;\n}\n");
|
||||||
|
test!(two_styles, "a {\n color: red;\n color: blue;\n}\n");
|
||||||
|
test!(selector_mul, "a, b {\n color: red;\n}\n");
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user