use std::str::from_utf8; use crate::cfg::Cfg; use crate::minify; pub fn eval_with_cfg(src: &'static [u8], expected: &'static [u8], cfg: &Cfg) { let min = minify(&src, cfg); assert_eq!(from_utf8(&min).unwrap(), from_utf8(expected).unwrap(),); } #[cfg(feature = "js-esbuild")] pub fn eval_with_js_min(src: &'static [u8], expected: &'static [u8]) -> () { let mut cfg = Cfg::new(); cfg.minify_js = true; eval_with_cfg(src, expected, &cfg); } #[cfg(feature = "js-esbuild")] pub fn eval_with_css_min(src: &'static [u8], expected: &'static [u8]) -> () { let mut cfg = Cfg::new(); cfg.minify_css = true; eval_with_cfg(src, expected, &cfg); } pub fn eval(src: &'static [u8], expected: &'static [u8]) { let mut cfg = Cfg::new(); // Most common tests assume the following minifications aren't done. cfg.keep_html_and_head_opening_tags = true; eval_with_cfg(src, expected, &cfg); } fn eval_without_keep_html_head(src: &'static [u8], expected: &'static [u8]) -> () { eval_with_cfg(src, expected, &Cfg::new()); } #[test] fn test_minification_of_doctype() { eval(b"", b""); eval( b"", b"", ); } #[test] fn test_parsing_extra_head_tag() { // Extra `` in `