#[cfg(test)]
use {
crate::ErrorType
};
#[cfg(test)]
fn _eval(src: &'static [u8], expected: &'static [u8], cfg: &super::Cfg) -> () {
let mut code = src.to_vec();
match super::with_friendly_error(&mut code, cfg) {
Ok(len) => {
assert_eq!(std::str::from_utf8(&code[..len]).unwrap(), std::str::from_utf8(expected).unwrap());
}
Err(super::FriendlyError { code_context, message, .. }) => {
println!("{}", message);
println!("{}", code_context);
assert!(false);
}
};
}
#[cfg(test)]
fn _eval_error(src: &'static [u8], expected: ErrorType, cfg: &super::Cfg) -> () {
let mut code = src.to_vec();
assert_eq!(super::in_place(&mut code, cfg).unwrap_err().error_type, expected);
}
#[cfg(test)]
fn eval(src: &'static [u8], expected: &'static [u8]) -> () {
_eval(src, expected, &super::Cfg {
minify_js: false,
});
}
#[cfg(test)]
fn eval_error(src: &'static [u8], expected: ErrorType) -> () {
_eval_error(src, expected, &super::Cfg {
minify_js: false,
});
}
#[cfg(test)]
#[cfg(feature = "js-esbuild")]
fn eval_with_js_min(src: &'static [u8], expected: &'static [u8]) -> () {
_eval(src, expected, &super::Cfg {
minify_js: true,
});
}
#[test]
fn test_collapse_whitespace() {
eval(b" \n ", b" ");
// Tag names should be case insensitive.
eval(b" \n ", b" ");
eval(b" \n ", b" ");
}
#[test]
fn test_collapse_and_trim_whitespace() {
eval(b"", b"");
eval(b"", b"");
eval(b"", b"");
// Tag names should be case insensitive.
eval(b"", b"");
}
#[test]
fn test_collapse_destroy_whole_and_trim_whitespace() {
eval(b"
", b"");
eval(b"", b"");
eval(b"", b"");
eval(b" b ", b"b");
// Tag names should be case insensitive.
eval(b"", b"");
}
#[test]
fn test_no_whitespace_minification() {
eval(b" \n \t
", b" \n \t
");
// Tag names should be case insensitive.
eval(b" \n \t
", b" \n \t
");
}
#[test]
fn test_self_closing_svg_tag_whitespace_removal() {
eval(b"", b"");
eval(b"", b"");
eval(b"", b"");
eval(b"", b"");
eval(b"", b"");
eval(b"", b"");
}
#[test]
fn test_parsing_with_omitted_tags() {
eval(b"", b"");
eval(b"