#[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(src: &'static [u8], expected: &'static [u8]) -> () { _eval(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" \n ", b""); eval(b" \n a ", b"a"); eval(b" \n a b ", b"a b"); // Tag names should be case insensitive. eval(b" \n a b ", b"a b"); } #[test] fn test_collapse_destroy_whole_and_trim_whitespace() { eval(b"
\n \t
"); eval(b"", b""); eval(b"", b""); } #[test] fn test_attr_double_quoted_value_minification() { eval(b"", b""); eval(b"", b""); eval(b"", b""); eval(b"", b""); } #[test] fn test_attr_single_quoted_value_minification() { eval(b"", b""); eval(b"", b""); eval(b"", b""); } #[test] fn test_attr_unquoted_value_minification() { eval(b"", b""); eval(b"", b""); eval(b"", b""); } #[test] fn test_class_attr_value_minification() { eval(b"", b""); eval(b"", b""); eval(b"", b""); eval(b"", b""); eval(b"", b""); eval(b"", b""); eval(b"", b""); eval(b"", b""); eval(b"", b""); // Attribute names should be case insensitive. eval(b"", b""); } #[test] fn test_d_attr_value_minification() { eval(b"", b""); eval(b"", b""); eval(b"", b""); eval(b"", b""); eval(b"", b""); eval(b"", b""); eval(b"", b""); eval(b"", b""); eval(b"", b""); // Attribute names should be case insensitive. eval(b"", b""); } #[test] fn test_boolean_attr_value_removal() { eval(b"
a b