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 "testing"
17)
18
19func runMarkdownReference(input string) string {
20 renderer := HtmlRenderer(0)
21 return string(Markdown([]byte(input), renderer, 0))
22}
23
24func doTestsReference(t *testing.T, files []string) {
25 for _, basename := range files {
26 fn := filepath.Join("upskirtref", basename+".text")
27 actualdata, err := ioutil.ReadFile(fn)
28 if err != nil {
29 t.Errorf("Couldn't open '%s', error: %v\n", fn, err)
30 continue
31 }
32 fn = filepath.Join("upskirtref", basename+".html")
33 expecteddata, err := ioutil.ReadFile(fn)
34 if err != nil {
35 t.Errorf("Couldn't open '%s', error: %v\n", fn, err)
36 continue
37 }
38
39 actual := string(actualdata)
40 actual = string(runMarkdownReference(actual))
41 expected := string(expecteddata)
42 if actual != expected {
43 t.Errorf("\n [%#v]\nExpected[%#v]\nActual [%#v]",
44 basename+".text", expected, actual)
45 }
46 }
47}
48
49func TestReference(t *testing.T) {
50 files := []string{
51 "Amps and angle encoding",
52 "Auto links",
53 "Backslash escapes",
54 "Blockquotes with code blocks",
55 "Code Blocks",
56 "Code Spans",
57 "Hard-wrapped paragraphs with list-like lines",
58 "Horizontal rules",
59 "Inline HTML (Advanced)",
60 "Inline HTML (Simple)",
61 "Inline HTML comments",
62 "Links, inline style",
63 "Links, reference style",
64 "Links, shortcut references",
65 "Literal quotes in titles",
66 "Markdown Documentation - Basics",
67 "Markdown Documentation - Syntax",
68 "Nested blockquotes",
69 "Ordered and unordered lists",
70 "Strong and em together",
71 "Tabs",
72 "Tidyness",
73 }
74 doTestsReference(t, files)
75}