use std::collections::HashMap;
pub fn create_common_test_data() -> HashMap<&'static [u8], &'static [u8]> {
let mut t = HashMap::<&'static [u8], &'static [u8]>::new();
t.insert(b"<a> \n  </a>", b"<a> </a>");
t.insert(b"<A> \n  </a>", b"<a> </a>");
t.insert(b"<a> \n  </A>", b"<a> </a>");
t.insert(b"<label> \n  </label>", b"<label></label>");
t.insert(b"<label> \n a </label>", b"<label>a</label>");
t.insert(b"<label> \n a b </label>", b"<label>a b</label>");
t.insert(b"<lAbEL> \n a b </LABel>", b"<label>a b</label>");
t.insert(b"<ul> \n  </ul>", b"<ul></ul>");
t.insert(b"<ul> \n a </ul>", b"<ul>a</ul>");
t.insert(b"<ul> \n a b </ul>", b"<ul>a b</ul>");
t.insert(
b"<ul> \n a<pre></pre> <pre></pre>b </ul>",
b"<ul>a<pre></pre><pre></pre>b</ul>",
);
t.insert(
b"<svg> <path> </path> <path> </path> </svg>",
b"<svg><path></path><path></path></svg>",
);
t.insert(b"<uL> \n a b </UL>", b"<ul>a b</ul>");
t.insert(b"<pre> \n  \t </pre>", b"<pre> \n \t </pre>");
t.insert(
b"<textarea> \n  \t </textarea>",
b"<textarea> \n \t </textarea>",
);
t.insert(b"<pRe> \n  \t </PRE>", b"<pre> \n \t </pre>");
t.insert(
b"<pre> <span> 1 2 </span> </pre>",
b"<pre> <span> 1 2 </span> </pre>",
);
t.insert(
b"<pre> <span> 1 <pre>\n</pre> 2 </span> </pre>",
b"<pre> <span> 1 <pre>\n</pre> 2 </span> </pre>",
);
t.insert(
b"<div> <pre> <span> 1 <pre>\n</pre> 2 </span> </pre> </div>",
b"<div><pre> <span> 1 <pre>\n</pre> 2 </span> </pre></div>",
);
t.insert(
br#"<pre><code>fn main() {
println!("Hello, world!");
<span>loop {
println!("Hello, world!");
}</span>
</code></pre>"#,
br#"<pre><code>fn main() {
println!("Hello, world!");
<span>loop {
println!("Hello, world!");
}</span>
</code></pre>"#,
);
t.insert(b"<html>", b"<html>");
t.insert(b" <html>\n", b"<html>");
t.insert(
b"<html><div> <p>Foo</div></html>",
b"<html><div><p>Foo</div>",
);
t.insert(b"<svg><path d=a /></svg>", b"<svg><path d=a /></svg>");
t.insert(b"<svg><path d=a/ /></svg>", b"<svg><path d=a/ /></svg>");
t.insert(b"<svg><path d=\"a/\" /></svg>", b"<svg><path d=a/ /></svg>");
t.insert(b"<svg><path d=\"a/\"/></svg>", b"<svg><path d=a/ /></svg>");
t.insert(b"<svg><path d='a/' /></svg>", b"<svg><path d=a/ /></svg>");
t.insert(b"<svg><path d='a/'/></svg>", b"<svg><path d=a/ /></svg>");
t.insert(b"<ul><li>1<li>2<li>3</ul>", b"<ul><li>1<li>2<li>3</ul>");
t.insert(b"<rt>", b"<rt>");
t.insert(b"<rt><rp>1</rp><div></div>", b"<rt><rp>1</rp><div></div>");
t.insert(b"<div><rt></div>", b"<div><rt></div>");
t.insert(b"<html><head><body>", b"<html><head><body>");
t.insert(b"<html><head><body>", b"<html><head><body>");
t.insert(b"<rt>", b"<rt>");
t.insert(
b"<ul><li>1</li><li>2</li><li>3</li></ul>",
b"<ul><li>1<li>2<li>3</ul>",
);
t.insert(b"<rt></rt>", b"<rt>");
t.insert(
b"<rt></rt><rp>1</rp><div></div>",
b"<rt><rp>1</rp><div></div>",
);
t.insert(b"<div><rt></rt></div>", b"<div><rt></div>");
t.insert(
br#"
<html>
<head>
</head>
<body>
</body>
</html>
"#,
b"<html><head><body>",
);
t.insert(b"<RT></rt>", b"<rt>");
t.insert(b"<p></p><address></address>", b"<p><address></address>");
t.insert(b"<p></p>", b"<p>");
t.insert(b"<map><p></p></map>", b"<map><p></p></map>");
t.insert(
b"<map><p></p><address></address></map>",
b"<map><p><address></address></map>",
);
t.insert(b"<a b=\" hello \"></a>", b"<a b=\" hello \"></a>");
t.insert(b"<a b=' hello '></a>", b"<a b=\" hello \"></a>");
t.insert(br#"<a b="/>aaaa"></a>"#, br#"<a b="/>aaaa"></a>"#);
t.insert(br#"<a b="</a>a"></a>"#, br#"<a b="</a>a"></a>"#);
t.insert(b"<a b= hello ></a>", b"<a b=\" hello \"></a>");
t.insert(b"<a b= hello ></a>", b"<a b=\" hello \"></a>");
t.insert(b"<a b=\""hello\"></a>", b"<a b='\"hello'></a>");
t.insert(b"<a b='\"hello'></a>", b"<a b='\"hello'></a>");
t.insert(b"<a b='/>a'></a>", b"<a b=\"/>a\"></a>");
t.insert(
b"<a b= he"llo ></a>",
b"<a b=' he\"llo '></a>",
);
t.insert(b"<a b=\"hello\"></a>", b"<a b=hello></a>");
t.insert(b"<a b='hello'></a>", b"<a b=hello></a>");
t.insert(b"<a b=/>></a>", br#"<a b="/>"></a>"#);
t.insert(b"<a b=/><a></a>", br#"<a b="/><a"></a>"#);
t.insert(b"<a b=hello></a>", b"<a b=hello></a>");
t.insert(b"<a class= c></a>", b"<a class=c></a>");
t.insert(
b"<a class= c  d ></a>",
b"<a class=\"c d\"></a>",
);
t.insert(b"<a class=    ></a>", b"<a></a>");
t.insert(b"<a class=\" c\n \n \"></a>", b"<a class=c></a>");
t.insert(b"<a class=\" c\n \nd \"></a>", b"<a class=\"c d\"></a>");
t.insert(b"<a class=\" \n \n \"></a>", b"<a></a>");
t.insert(b"<a class=' c\n \n '></a>", b"<a class=c></a>");
t.insert(b"<a class=' c\n \nd '></a>", b"<a class=\"c d\"></a>");
t.insert(b"<a class=' \n \n '></a>", b"<a></a>");
t.insert(b"<a CLasS=' \n \n '></a>", b"<a></a>");
t.insert(b"<svg><path d= c /></svg>", b"<svg><path d=c /></svg>");
t.insert(
b"<svg><path d= c  d  /></svg>",
b"<svg><path d=\"c d\"/></svg>",
);
t.insert(
b"<svg><path d=     /></svg>",
b"<svg><path/></svg>",
);
t.insert(
b"<svg><path d=\" c\n \n \" /></svg>",
b"<svg><path d=c /></svg>",
);
t.insert(
b"<svg><path d=\" c\n \nd \" /></svg>",
b"<svg><path d=\"c d\"/></svg>",
);
t.insert(
b"<svg><path d=\" \n \n \" /></svg>",
b"<svg><path/></svg>",
);
t.insert(
b"<svg><path d=' c\n \n ' /></svg>",
b"<svg><path d=c /></svg>",
);
t.insert(
b"<svg><path d=' c\n \nd ' /></svg>",
b"<svg><path d=\"c d\"/></svg>",
);
t.insert(b"<svg><path d=' \n \n ' /></svg>", b"<svg><path/></svg>");
t.insert(b"<svg><path D=' \n \n ' /></svg>", b"<svg><path/></svg>");
t.insert(b"<div hidden=\"true\"></div>", b"<div hidden></div>");
t.insert(b"<div hidden=\"false\"></div>", b"<div hidden></div>");
t.insert(b"<div hidden=\"1\"></div>", b"<div hidden></div>");
t.insert(b"<div hidden=\"0\"></div>", b"<div hidden></div>");
t.insert(b"<div hidden=\"abc\"></div>", b"<div hidden></div>");
t.insert(b"<div hidden=\"\"></div>", b"<div hidden></div>");
t.insert(b"<div hidden></div>", b"<div hidden></div>");
t.insert(b"<div HIDden=\"true\"></div>", b"<div hidden></div>");
t.insert(b"<div lang=\" \"></div>", b"<div lang=\" \"></div>");
t.insert(b"<div lang=\"\"></div>", b"<div></div>");
t.insert(b"<div lang=''></div>", b"<div></div>");
t.insert(b"<div lang=></div>", b"<div></div>");
t.insert(b"<div lang></div>", b"<div></div>");
t.insert(b"<a target=\"_self\"></a>", b"<a></a>");
t.insert(b"<a target='_self'></a>", b"<a></a>");
t.insert(b"<a target=_self></a>", b"<a></a>");
t.insert(b"<a taRGET='_self'></a>", b"<a></a>");
t.insert(
b"<script type=\"application/ecmascript\"></script>",
b"<script></script>",
);
t.insert(
b"<script type=\"application/javascript\"></script>",
b"<script></script>",
);
t.insert(
b"<script type=\"text/jscript\"></script>",
b"<script></script>",
);
t.insert(
b"<script type=\"text/plain\"></script>",
b"<script type=text/plain></script>",
);
t.insert(
b"<SCRipt TYPE=\"application/ecmascript\"></SCrIPT>",
b"<script></script>",
);
t.insert(b"<div a=\" \"></div>", b"<div a=\" \"></div>");
t.insert(b"<div a=\"\"></div>", b"<div a></div>");
t.insert(b"<div a=''></div>", b"<div a></div>");
t.insert(b"<div a=></div>", b"<div a></div>");
t.insert(b"<div a></div>", b"<div a></div>");
t.insert(b".", b".");
t.insert(b"/", b"/");
t.insert(b"/", b"/");
t.insert(b"�", b"\0");
t.insert(b"0", b"0");
t.insert(b"0", b"0");
t.insert(b"0", b"0");
t.insert(b"0", b"0");
t.insert(b"0", b"0");
t.insert(b"0", b"0");
t.insert(b"ᅑ", b"\xe1\x85\x91");
t.insert(b"�", b"\xef\xbf\xbd");
t.insert(
b"�",
b"\xef\xbf\xbd",
);
t.insert(b"0", b"0");
t.insert(b"0", b"0");
t.insert(b"0", b"0");
t.insert(b"0", b"0");
t.insert(b"0", b"0");
t.insert(b"0", b"0");
t.insert(b"ᅑ", b"\xe1\x85\x91");
t.insert(b"�", b"\xef\xbf\xbd");
t.insert(
b"�",
b"\xef\xbf\xbd",
);
t.insert(b">", b">");
t.insert(b">", b">");
t.insert(b"&", b"&");
t.insert(b"&", b"&");
t.insert(b"&xxxyyyzzz", b"&xxxyyyzzz");
t.insert(b"&ere", b"&ere");
t.insert(b"They & Co.", b"They & Co.");
t.insert(b"if (this && that)", b"if (this && that)");
t.insert(b"≪⃒", b"≪⃒");
t.insert(b"≪⃒abc", b"≪⃒abc");
t.insert(b"≫⃒", b"≫⃒");
t.insert(
br#"<a href="exam ple?>a=5"></a>"#,
br#"<a href="exam ple?>a=5"></a>"#,
);
t.insert(
br#"<a href="exam ple?>=5"></a>"#,
br#"<a href="exam ple?>=5"></a>"#,
);
t.insert(
br#"<a href="exam ple?>~5"></a>"#,
br#"<a href="exam ple?>~5"></a>"#,
);
#[cfg(feature = "js")]
{
t.insert(
b"<pre>a <!-- akd--sj\n <!-- \t\0f--ajk--df->lafj --> b</pre>",
b"<pre>a b</pre>",
);
t.insert(b"&a<!-- akd--sj\n <!-- \t\0f--ajk--df->lafj -->mp", b"&");
t.insert(
b"<script><!-- akd--sj\n <!-- \t\0f--ajk--df->lafj --></script>",
b"<script></script>",
);
}
t.insert(b"<?php hello??? >> ?>", b"<?php hello??? >> ?>");
t.insert(b"av<?xml 1.0 ?>g", b"av<?xml 1.0 ?>g");
t.insert(
b"<a><svg viewBox=\"0 0 700 100\" /></a><footer></footer>",
b"<a><svg viewbox=\"0 0 700 100\"/></a><footer></footer>",
);
t.insert(
b"<a><svg viewBox=\"0 0 700 100\"></svg></a><footer></footer>",
b"<a><svg viewbox=\"0 0 700 100\"></svg></a><footer></footer>",
);
t
}
#[cfg(feature = "css")]
pub fn create_common_css_test_data() -> HashMap<&'static [u8], &'static [u8]> {
let mut t = HashMap::<&'static [u8], &'static [u8]>::new();
t.insert(
b"<style>div { color: yellow }</style>",
b"<style>div{color:#ff0}</style>",
);
t
}
#[cfg(feature = "js")]
pub fn create_common_js_test_data() -> HashMap<&'static [u8], &'static [u8]> {
let mut t = HashMap::<&'static [u8], &'static [u8]>::new();
t.insert(b"<script></script>", b"<script></script>");
t.insert(b"<script> </script>", b"<script></script>");
t.insert(b"<script>let a = 1;</script>", b"<script>let a=1;</script>");
t.insert(
b"<script type=text/javascript>let a = 1;</script>",
b"<script>let a=1;</script>",
);
t.insert(
br#"
<script>let a = 1;</script>
<script>let b = 2;</script>
"#,
b"<script>let a=1;</script><script>let b=2;</script>",
);
t.insert(
b"<scRIPt type=text/plain> alert(1.00000); </scripT>",
b"<script type=text/plain> alert(1.00000); </script>",
);
t.insert(
br#"
<script>
// This is a comment.
let a = 1;
</script>
"#,
b"<script>let a=1;</script>",
);
t
}