grass/tests/macros.rs
2020-03-18 10:08:40 -04:00

36 lines
1.1 KiB
Rust

#![cfg(test)]
#[macro_export]
macro_rules! test {
($func:ident, $input:expr) => {
#[test]
#[allow(non_snake_case)]
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($input),
String::from_utf8(buf).expect("produced invalid utf8")
);
}
};
($func:ident, $input:expr, $output:expr) => {
#[test]
#[allow(non_snake_case)]
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")
);
}
};
}