mirror of
https://github.com/status-im/markdown.git
synced 2025-02-23 16:48:14 +00:00
Do away with doTestsInlineParam
What used to be doTestsBlockWithRunner is now renamed to doTestsWithRunner and is good for both block and inline tests.
This commit is contained in:
parent
0c7120d6dc
commit
f1fd3a6412
@ -43,6 +43,10 @@ func doTestsBlock(t *testing.T, tests []string, extensions Extensions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func doTestsBlockWithRunner(t *testing.T, tests []string, params TestParams, runner func(string, TestParams) string) {
|
func doTestsBlockWithRunner(t *testing.T, tests []string, params TestParams, runner func(string, TestParams) string) {
|
||||||
|
doTestsWithRunner(t, tests, params, runner)
|
||||||
|
}
|
||||||
|
|
||||||
|
func doTestsWithRunner(t *testing.T, tests []string, params TestParams, runner func(string, TestParams) string) {
|
||||||
// catch and report panics
|
// catch and report panics
|
||||||
var candidate string
|
var candidate string
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -118,34 +122,7 @@ func doSafeTestsInline(t *testing.T, tests []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func doTestsInlineParam(t *testing.T, tests []string, params TestParams) {
|
func doTestsInlineParam(t *testing.T, tests []string, params TestParams) {
|
||||||
// catch and report panics
|
doTestsWithRunner(t, tests, params, runMarkdownInline)
|
||||||
var candidate string
|
|
||||||
defer func() {
|
|
||||||
if err := recover(); err != nil {
|
|
||||||
t.Errorf("\npanic while processing [%#v] (%v)\n", candidate, err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
for i := 0; i+1 < len(tests); i += 2 {
|
|
||||||
input := tests[i]
|
|
||||||
candidate = input
|
|
||||||
expected := tests[i+1]
|
|
||||||
actual := runMarkdownInline(candidate, params)
|
|
||||||
if actual != expected {
|
|
||||||
t.Errorf("\nInput [%#v]\nExpected[%#v]\nActual [%#v]",
|
|
||||||
candidate, expected, actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
// now test every substring to stress test bounds checking
|
|
||||||
if !testing.Short() {
|
|
||||||
for start := 0; start < len(input); start++ {
|
|
||||||
for end := start + 1; end <= len(input); end++ {
|
|
||||||
candidate = input[start:end]
|
|
||||||
runMarkdownInline(candidate, params)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func transformLinks(tests []string, prefix string) []string {
|
func transformLinks(tests []string, prefix string) []string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user