all repos — grayfriday @ be0fb4602b8113ab16b70ab34fe48c0573bd65ef

blackfriday fork with a few changes

upskirtref_test.go (view raw)

 1//
 2// Black Friday Markdown Processor
 3// Originally based on http://github.com/tanoku/upskirt
 4// by Russ Ross <russ@russross.com>
 5//
 6
 7//
 8// Markdown 1.0.3 reference tests
 9//
10
11package blackfriday
12
13import (
14	"io/ioutil"
15	"path/filepath"
16	"strings"
17	"testing"
18)
19
20func runReferenceMarkdown(input string) string {
21	renderer := HtmlRenderer(0)
22	return string(Markdown([]byte(input), renderer, 0))
23}
24
25// disregard dos vs. unix line endings differences
26func normalizeEol(s string) string {
27	return strings.Replace(s, "\r\n", "\n", -1)
28}
29
30func doFileTests(t *testing.T, files []string) {
31	for _, basename := range files {
32		fn := filepath.Join("upskirtref", basename+".text")
33		actualdata, err := ioutil.ReadFile(fn)
34		if err != nil {
35			t.Errorf("Couldn't open '%s', error: %v\n", fn, err)
36			continue
37		}
38		fn = filepath.Join("upskirtref", basename+".html")
39		expecteddata, err := ioutil.ReadFile(fn)
40		if err != nil {
41			t.Errorf("Couldn't open '%s', error: %v\n", fn, err)
42			continue
43		}
44
45		actual := string(actualdata)
46		actual = normalizeEol(string(runReferenceMarkdown(actual)))
47		expected := normalizeEol(string(expecteddata))
48		if actual != expected {
49			t.Errorf("\n    [%#v]\nExpected[%#v]\nActual  [%#v]",
50				basename+".text", expected, actual)
51		}
52	}
53}
54
55func TestReference(t *testing.T) {
56	files := []string{
57		"Amps and angle encoding",
58		"Auto links",
59		"Backslash escapes",
60		"Blockquotes with code blocks",
61		"Code Blocks",
62		"Code Spans",
63		"Hard-wrapped paragraphs with list-like lines",
64		"Horizontal rules",
65		"Inline HTML (Advanced)",
66		"Inline HTML (Simple)",
67		"Inline HTML comments",
68		"Links, inline style",
69		"Links, reference style",
70		"Links, shortcut references",
71		"Literal quotes in titles",
72		"Markdown Documentation - Basics",
73		"Markdown Documentation - Syntax",
74		"Nested blockquotes",
75		"Ordered and unordered lists",
76		"Strong and em together",
77		"Tabs",
78		"Tidyness",
79	}
80	doFileTests(t, files)
81}