mirror of
https://github.com/russross/blackfriday.git
synced 2024-03-22 13:40:34 +08:00
fix test name conflicts
This commit is contained in:
parent
cd5e4957ce
commit
a4339270a5
|
@ -1,81 +1,81 @@
|
||||||
//
|
//
|
||||||
// Black Friday Markdown Processor
|
// Black Friday Markdown Processor
|
||||||
// Originally based on http://github.com/tanoku/upskirt
|
// Originally based on http://github.com/tanoku/upskirt
|
||||||
// by Russ Ross <russ@russross.com>
|
// by Russ Ross <russ@russross.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// Unit tests for inline parsing
|
// Markdown 1.0.3 reference tests
|
||||||
//
|
//
|
||||||
|
|
||||||
package blackfriday
|
package blackfriday
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func runMarkdown(input string) string {
|
func runReferenceMarkdown(input string) string {
|
||||||
renderer := HtmlRenderer(0)
|
renderer := HtmlRenderer(0)
|
||||||
return string(Markdown([]byte(input), renderer, 0))
|
return string(Markdown([]byte(input), renderer, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
// disregard dos vs. unix line endings differences
|
// disregard dos vs. unix line endings differences
|
||||||
func normalizeEol(s string) string {
|
func normalizeEol(s string) string {
|
||||||
return strings.Replace(s, "\r\n", "\n", -1)
|
return strings.Replace(s, "\r\n", "\n", -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func doTests(t *testing.T, files []string) {
|
func doFileTests(t *testing.T, files []string) {
|
||||||
for _, basename := range files {
|
for _, basename := range files {
|
||||||
fn := filepath.Join("upskirtref", basename+".text")
|
fn := filepath.Join("upskirtref", basename+".text")
|
||||||
actualdata, err := ioutil.ReadFile(fn)
|
actualdata, err := ioutil.ReadFile(fn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Couldn't open '%s', error: %v\n", fn, err)
|
t.Errorf("Couldn't open '%s', error: %v\n", fn, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fn = filepath.Join("upskirtref", basename+"_upskirt_ref.html")
|
fn = filepath.Join("upskirtref", basename+"_upskirt_ref.html")
|
||||||
expecteddata, err := ioutil.ReadFile(fn)
|
expecteddata, err := ioutil.ReadFile(fn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Couldn't open '%s', error: %v\n", fn, err)
|
t.Errorf("Couldn't open '%s', error: %v\n", fn, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
actual := string(actualdata)
|
actual := string(actualdata)
|
||||||
actual = normalizeEol(string(runMarkdown(actual)))
|
actual = normalizeEol(string(runReferenceMarkdown(actual)))
|
||||||
expected := normalizeEol(string(expecteddata))
|
expected := normalizeEol(string(expecteddata))
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Errorf("\nFile [%#v]\nExpected[%#v]\nActual [%#v]",
|
t.Errorf("\n [%#v]\nExpected[%#v]\nActual [%#v]",
|
||||||
basename+".text", expected, actual)
|
basename+".text", expected, actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCodeSpan(t *testing.T) {
|
func TestReference(t *testing.T) {
|
||||||
files := []string{
|
files := []string{
|
||||||
"Amps and angle encoding",
|
"Amps and angle encoding",
|
||||||
"Auto links",
|
"Auto links",
|
||||||
"Backslash escapes",
|
"Backslash escapes",
|
||||||
"Blockquotes with code blocks",
|
"Blockquotes with code blocks",
|
||||||
"Code Blocks",
|
"Code Blocks",
|
||||||
"Code Spans",
|
"Code Spans",
|
||||||
"Hard-wrapped paragraphs with list-like lines",
|
"Hard-wrapped paragraphs with list-like lines",
|
||||||
"Horizontal rules",
|
"Horizontal rules",
|
||||||
"Inline HTML (Advanced)",
|
"Inline HTML (Advanced)",
|
||||||
"Inline HTML (Simple)",
|
"Inline HTML (Simple)",
|
||||||
"Inline HTML comments",
|
"Inline HTML comments",
|
||||||
"Links, inline style",
|
"Links, inline style",
|
||||||
"Links, reference style",
|
"Links, reference style",
|
||||||
"Links, shortcut references",
|
"Links, shortcut references",
|
||||||
"Literal quotes in titles",
|
"Literal quotes in titles",
|
||||||
"Markdown Documentation - Basics",
|
"Markdown Documentation - Basics",
|
||||||
"Markdown Documentation - Syntax",
|
"Markdown Documentation - Syntax",
|
||||||
"Nested blockquotes",
|
"Nested blockquotes",
|
||||||
"Ordered and unordered lists",
|
"Ordered and unordered lists",
|
||||||
"Strong and em together",
|
"Strong and em together",
|
||||||
"Tabs",
|
"Tabs",
|
||||||
"Tidyness",
|
"Tidyness",
|
||||||
}
|
}
|
||||||
doTests(t, files)
|
doFileTests(t, files)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user