transform: Complete test statement coverage
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 6 Feb 2016 19:50:26 +0000 (20:50 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 6 Feb 2016 19:50:26 +0000 (20:50 +0100)
"coverage: 100.0% of statements"

transform/absurlreplacer.go
transform/chain_test.go

index b834bcdccbf74c1b86a3f6bbb59b325144708703..8e8269a05834a9e970b4a57801868431d23b0528 100644 (file)
@@ -85,9 +85,9 @@ func (l *absurllexer) match(r rune) {
                        if r == p.r[l.idx] {
                                l.matches[j] = true
                                found = true
-                               if l.checkMatchState(r, j) {
-                                       return
-                               }
+                               // checkMatchState will only return true when r=='=', so
+                               // we can safely ignore the return value here.
+                               l.checkMatchState(r, j)
                        }
                }
 
@@ -249,9 +249,6 @@ func (l *absurllexer) replace() {
                                                l.matches[i] = false
                                        }
                                }
-                               if p == nil {
-                                       panic("illegal state: curr is nil when state is full")
-                               }
                                l.ms = matchStateNone
                                p.f(l)
                        }
index 8ac3b6bc12c6954308c60140e2e52ae40d763855..9a133a8576403e2cf6b0e72f25339af2555b9416 100644 (file)
@@ -36,6 +36,9 @@ const H5_XML_CONTENT_GUARDED = "<?xml version=\"1.0\" encoding=\"utf-8\" standal
 // additional sanity tests for replacements testing
 const REPLACE_1 = "No replacements."
 const REPLACE_2 = "ᚠᛇᚻ ᛒᛦᚦ ᚠᚱᚩᚠᚢᚱ\nᚠᛁᚱᚪ ᚷᛖᚻᚹᛦᛚᚳᚢᛗ"
+const REPLACE_3 = `End of file: src="/`
+const REPLACE_4 = `End of file: srcset="/`
+const REPLACE_5 = `Srcsett with no closing quote: srcset="/img/small.jpg do be do be do.`
 
 // Issue: 816, schemaless links combined with others
 const REPLACE_SCHEMALESS_HTML = `Pre. src='//schemaless' src='/normal'  <a href="//schemaless">Schemaless</a>. <a href="/normal">normal</a>. Post.`
@@ -94,7 +97,7 @@ var xml_abs_url_bench_tests = []test{
        {H5_XML_CONTENT_GUARDED, H5_XML_CONTENT_GUARDED},
 }
 
-var sanity_tests = []test{{REPLACE_1, REPLACE_1}, {REPLACE_2, REPLACE_2}}
+var sanity_tests = []test{{REPLACE_1, REPLACE_1}, {REPLACE_2, REPLACE_2}, {REPLACE_3, REPLACE_3}, {REPLACE_4, REPLACE_4}, {REPLACE_5, REPLACE_5}}
 var extra_tests_html = []test{{REPLACE_SCHEMALESS_HTML, REPLACE_SCHEMALESS_HTML_CORRECT}}
 var abs_url_tests = append(abs_url_bench_tests, append(sanity_tests, extra_tests_html...)...)
 var extra_tests_xml = []test{{REPLACE_SCHEMALESS_XML, REPLACE_SCHEMALESS_XML_CORRECT}}