MCPcopy Index your code
hub / github.com/tdewolff/minify / TestHTML

Function TestHTML

html/html_test.go:22–197  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20)
21
22func TestHTML(t *testing.T) {
23 htmlTests := []struct {
24 html string
25 expected string
26 }{
27 {`html`, `html`},
28 //{"<title>title</title> <body>", `<title>title</title>`},
29 {`<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">`, `<!doctype html>`},
30 {`<!-- comment -->`, ``},
31 {`<!--# SSI Tag -->`, ``},
32 {`<style><!--\ncss\n--></style>`, `<style><!--\ncss\n--></style>`},
33 {`<style>&</style>`, `<style>&</style>`},
34 {`<html><head></head><body>x</body></html>`, `x`},
35 {"<html><head><title> a </title>\n<link></head></html>", `<title>a</title><link>`},
36 {`<meta http-equiv="content-type" content="text/html; charset=utf-8">`, `<meta charset=utf-8>`},
37 {`<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />`, `<meta charset=utf-8>`},
38 {`<meta http-equiv=" content-type " content=" text/html; charset=utf-8 ">`, `<meta charset=utf-8>`},
39 {`<meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src https://*; child-src 'none';">`, `<meta http-equiv=Content-Security-Policy content="default-src 'self'; img-src https://*; child-src 'none';">`},
40 {`<meta name="keywords" content="a, b">`, `<meta name=keywords content="a,b">`},
41 //{`<meta name="keywords" content=" a, b ">`, `<meta name=keywords content="a,b">`}, // TODO
42 {`<meta name="viewport" content="width = 996" />`, `<meta name=viewport content="width=996">`},
43 {`<span attr="test"></span>`, `<span attr=test></span>`},
44 {`<span attr='test&apos;test'></span>`, `<span attr="test'test"></span>`},
45 {`<span attr="test&quot;test"></span>`, `<span attr='test"test'></span>`},
46 {`<span attr='test""&apos;&amp;test'></span>`, `<span attr='test""&#39;&amp;test'></span>`},
47 {`<span attr="test/test"></span>`, `<span attr=test/test></span>`},
48 {`<span attr="test/"></span>`, `<span attr=test/></span>`},
49 {`<span>&amp;</span>`, `<span>&</span>`},
50 {`<span>&lt;</span>`, `<span>&lt;</span>`},
51 {`<span>&gt;</span>`, `<span>></span>`},
52 {`<code>&quot;&rsquor;</code>`, `<code>"&#8217;</code>`},
53 {`<small>&#160;</small>`, `<small>&#160;</small>`},
54 {`<span name="&lt;&apos;">a</span>`, `<span name="<'">a</span>`},
55 {`<span method=GET></span>`, `<span></span>`},
56 {`<span onload="javascript:x;"></span>`, `<span onload=x;></span>`},
57 {`<span selected="selected"></span>`, `<span selected></span>`},
58 {`<noscript><html><img id="x"></noscript>`, `<noscript><img id=x></noscript>`},
59 {`<body id="main"></body>`, `<body id=main>`},
60 {`<link href="data:text/plain, data">`, `<link href=data:,%20data>`},
61 {`<svg width="100" height="100"><circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" /></svg>`, `<svg width="100" height="100"><circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" /></svg>`},
62 {`<span ></span>`, `<span></span>`},
63 {`</span >`, `</span>`},
64 {`<meta name=viewport content="width=0.1, initial-scale=1.0 , maximum-scale=1000">`, `<meta name=viewport content="width=.1,initial-scale=1,maximum-scale=1e3">`},
65 {`<br/>`, `<br>`},
66 {`<input type="radio" value="">`, `<input type=radio value>`},
67 {`<input type="radio" value="on">`, `<input type=radio>`},
68 {`<input type="text" value="">`, `<input>`},
69 {`<a rel="noopener">`, `<a rel=noopener>`},
70 {`<a rel=" noopener external ">`, `<a rel="noopener external">`},
71 {`<input accept="image/png, image/jpeg">`, `<input accept=image/png,image/jpeg>`},
72 {`<p></p></label>`, `<p></p></label>`}, // experimentally found
73
74 // increase coverage
75 {`<script style="css">js</script>`, `<script style=css>js</script>`},
76 {`<script type="text/javascript">js</script>`, `<script>js</script>`},
77 {`<script type="application/javascript">js</script>`, `<script>js</script>`},
78 {`<meta http-equiv="content-type" content="text/plain, text/html">`, `<meta http-equiv=content-type content="text/plain,text/html">`},
79 {`<meta property="rdfa" content="data">`, `<meta property="rdfa" content="data">`},

Callers

nothing calls this directly

Calls 5

AddFuncMethod · 0.80
RunMethod · 0.80
MinifyFunction · 0.70
MinifyMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…