all repos — grayfriday @ 70c92fefd4330506d553d7a1a173a9ee51bc4df3

blackfriday fork with a few changes

upskirtref_test.go (view raw)

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