mirror of
https://github.com/russross/blackfriday.git
synced 2024-03-22 13:40:34 +08:00
Make a way to parameterize inline tests
Expose extensions and html flags parameters so that tests could specify what code paths they want to exercise.
This commit is contained in:
parent
3c0965e698
commit
90509d39d4
|
@ -17,12 +17,10 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func runMarkdownInline(input string) string {
|
func runMarkdownInline(input string, extensions, htmlFlags int) string {
|
||||||
extensions := 0
|
|
||||||
extensions |= EXTENSION_AUTOLINK
|
extensions |= EXTENSION_AUTOLINK
|
||||||
extensions |= EXTENSION_STRIKETHROUGH
|
extensions |= EXTENSION_STRIKETHROUGH
|
||||||
|
|
||||||
htmlFlags := 0
|
|
||||||
htmlFlags |= HTML_USE_XHTML
|
htmlFlags |= HTML_USE_XHTML
|
||||||
|
|
||||||
renderer := HtmlRenderer(htmlFlags, "", "")
|
renderer := HtmlRenderer(htmlFlags, "", "")
|
||||||
|
@ -31,6 +29,10 @@ func runMarkdownInline(input string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func doTestsInline(t *testing.T, tests []string) {
|
func doTestsInline(t *testing.T, tests []string) {
|
||||||
|
doTestsInlineParam(t, tests, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func doTestsInlineParam(t *testing.T, tests []string, extensions, htmlFlags int) {
|
||||||
// catch and report panics
|
// catch and report panics
|
||||||
var candidate string
|
var candidate string
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -43,7 +45,7 @@ func doTestsInline(t *testing.T, tests []string) {
|
||||||
input := tests[i]
|
input := tests[i]
|
||||||
candidate = input
|
candidate = input
|
||||||
expected := tests[i+1]
|
expected := tests[i+1]
|
||||||
actual := runMarkdownInline(candidate)
|
actual := runMarkdownInline(candidate, extensions, htmlFlags)
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Errorf("\nInput [%#v]\nExpected[%#v]\nActual [%#v]",
|
t.Errorf("\nInput [%#v]\nExpected[%#v]\nActual [%#v]",
|
||||||
candidate, expected, actual)
|
candidate, expected, actual)
|
||||||
|
@ -54,7 +56,7 @@ func doTestsInline(t *testing.T, tests []string) {
|
||||||
for start := 0; start < len(input); start++ {
|
for start := 0; start < len(input); start++ {
|
||||||
for end := start + 1; end <= len(input); end++ {
|
for end := start + 1; end <= len(input); end++ {
|
||||||
candidate = input[start:end]
|
candidate = input[start:end]
|
||||||
_ = runMarkdownInline(candidate)
|
_ = runMarkdownInline(candidate, extensions, htmlFlags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user