fn eval_with_cfg(src: &'static [u8], expected: &'static [u8], cfg: &super::Cfg) { let mut code = src.to_vec(); let min = super::minify(&mut code, cfg); assert_eq!( std::str::from_utf8(&min).unwrap(), std::str::from_utf8(expected).unwrap(), ); } fn eval(src: &'static [u8], expected: &'static [u8]) { eval_with_cfg(src, expected, &super::Cfg::new()); } fn eval_with_keep_html_head(src: &'static [u8], expected: &'static [u8]) -> () { let mut cfg = super::Cfg::new(); cfg.keep_html_and_head_opening_tags = true; eval_with_cfg(src, expected, &cfg); } #[cfg(feature = "js-esbuild")] fn eval_with_js_min(src: &'static [u8], expected: &'static [u8]) -> () { let mut cfg = super::Cfg::new(); cfg.minify_js = true; eval_with_cfg(src, expected, &cfg); } #[cfg(feature = "js-esbuild")] fn eval_with_css_min(src: &'static [u8], expected: &'static [u8]) -> () { let mut cfg = super::Cfg::new(); cfg.minify_css = true; eval_with_cfg(src, expected, &cfg); } #[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"", ); // Tag names should be case insensitive. eval(b"", b""); } #[test] fn test_no_whitespace_minification() { eval(b"
   \n  \t   
", b"
   \n  \t   
"); eval( b"", b"", ); // Tag names should be case insensitive. eval(b"
   \n  \t   
", b"
   \n  \t   
"); eval( b"
    1    2     
", b"
    1    2     
", ); eval( b"
    1 
\n
2
", b"
    1 
\n
2
", ); eval( b"
    1 
\n
2
", b"
    1 
\n
2
", ); eval( br#"
fn main() {
  println!("Hello, world!");
  loop {
    println!("Hello, world!");
  }
}
"#, br#"
fn main() {
  println!("Hello, world!");
  loop {
    println!("Hello, world!");
  }
}
"#, ); } #[test] fn test_parsing_extra_head_tag() { // Extra `` in `