grass/tests/macros.rs

34 lines
1.0 KiB
Rust
Raw Normal View History

2020-02-01 23:09:22 -05:00
#![cfg(test)]
2020-03-01 14:53:52 -05:00
#[macro_export]
2020-02-01 23:09:22 -05:00
macro_rules! test {
($func:ident, $input:literal) => {
#[test]
fn $func() {
let mut buf = Vec::new();
grass::StyleSheet::new($input)
2020-02-02 10:27:08 -05:00
.expect(concat!("failed to parse on ", $input))
.print_as_css(&mut buf)
.expect(concat!("failed to pretty print on ", $input));
2020-02-01 23:09:22 -05:00
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();
grass::StyleSheet::new($input)
.expect(concat!("failed to parse on ", $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")
);
}
};
2020-02-02 10:27:08 -05:00
}