Uh oh!
There was an error while loading. Please reload this page.
forked from gomarkdown/markdown
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathref_test.go
More file actions
Latest commit
174 lines (149 loc) · 4.43 KB
/
Copy pathref_test.go
File metadata and controls
174 lines (149 loc) · 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
package markdown
import (
"io/ioutil"
"path/filepath"
"testing"
"github.com/verloop/markdown/parser"
)
// Markdown 1.0.3 reference tests
var (
refFiles= []string{
"Amps and angle encoding",
"Auto links",
"Backslash escapes",
"Blockquotes with code blocks",
"Code Blocks",
"Code Spans",
"Horizontal rules",
"Inline HTML (Advanced)",
"Inline HTML (Simple)",
"Inline HTML comments",
"Links, inline style",
"Links, reference style",
"Links, shortcut references",
"Literal quotes in titles",
"Markdown Documentation - Basics",
"Markdown Documentation - Syntax",
"Nested blockquotes",
"Ordered and unordered lists",
"Strong and em together",
"Tabs",
"Tidyness",
// New tests added for verloop
"Entities",
}
)
funcTestReference(t*testing.T) {
files:=append(refFiles, "Hard-wrapped paragraphs with list-like lines")
doTestsReference(t, files, 0)
}
funcTestReference_EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK(t*testing.T) {
files:=append(refFiles, "Hard-wrapped paragraphs with list-like lines no empty line before block")
doTestsReference(t, files, parser.NoEmptyLineBeforeBlock)
}
// benchResultAnchor is an anchor variable to store the result of a benchmarked
// code so that compiler could never optimize away the call to runMarkdown()
varbenchResultAnchorstring
funcbenchFile(b*testing.B, basenamestring) {
params:=TestParams{extensions: parser.CommonExtensions}
filename:=filepath.Join("testdata", basename+".text")
inputBytes, err:=ioutil.ReadFile(filename)
iferr!=nil {
b.Errorf("Couldn't open '%s', error: %v\n", filename, err)
return
}
test:=string(inputBytes)
b.ResetTimer()
forn:=0; n<b.N; n++ {
benchResultAnchor=runMarkdown(test, params)
}
}
funcBenchmarkReferenceAmps(b*testing.B) {
benchFile(b, "Amps and angle encoding")
}
funcBenchmarkReferenceAutoLinks(b*testing.B) {
benchFile(b, "Auto links")
}
funcBenchmarkReferenceBackslashEscapes(b*testing.B) {
benchFile(b, "Backslash escapes")
}
funcBenchmarkReferenceBlockquotesWithCodeBlocks(b*testing.B) {
benchFile(b, "Blockquotes with code blocks")
}
funcBenchmarkReferenceCodeBlocks(b*testing.B) {
benchFile(b, "Code Blocks")
}
funcBenchmarkReferenceCodeSpans(b*testing.B) {
benchFile(b, "Code Spans")
}
funcBenchmarkIssue265(b*testing.B) {
benchFile(b, "issue265-slow-binary")
}
funcBenchmarkReferenceHardWrappedPara(b*testing.B) {
benchFile(b, "Hard-wrapped paragraphs with list-like lines")
}
funcBenchmarkReferenceHorizontalRules(b*testing.B) {
benchFile(b, "Horizontal rules")
}
funcBenchmarkReferenceInlineHTMLAdvances(b*testing.B) {
benchFile(b, "Inline HTML (Advanced)")
}
funcBenchmarkReferenceInlineHTMLSimple(b*testing.B) {
benchFile(b, "Inline HTML (Simple)")
}
funcBenchmarkReferenceInlineHTMLComments(b*testing.B) {
benchFile(b, "Inline HTML comments")
}
funcBenchmarkReferenceLinksInline(b*testing.B) {
benchFile(b, "Links, inline style")
}
funcBenchmarkReferenceLinksReference(b*testing.B) {
benchFile(b, "Links, reference style")
}
funcBenchmarkReferenceLinksShortcut(b*testing.B) {
benchFile(b, "Links, shortcut references")
}
funcBenchmarkReferenceLiterQuotesInTitles(b*testing.B) {
benchFile(b, "Literal quotes in titles")
}
funcBenchmarkReferenceMarkdownBasics(b*testing.B) {
benchFile(b, "Markdown Documentation - Basics")
}
funcBenchmarkReferenceMarkdownSyntax(b*testing.B) {
benchFile(b, "Markdown Documentation - Syntax")
}
funcBenchmarkReferenceNestedBlockquotes(b*testing.B) {
benchFile(b, "Nested blockquotes")
}
funcBenchmarkReferenceOrderedAndUnorderedLists(b*testing.B) {
benchFile(b, "Ordered and unordered lists")
}
funcBenchmarkReferenceStrongAndEm(b*testing.B) {
benchFile(b, "Strong and em together")
}
funcBenchmarkReferenceTabs(b*testing.B) {
benchFile(b, "Tabs")
}
funcBenchmarkReferenceTidyness(b*testing.B) {
benchFile(b, "Tidyness")
}
funcBenchmarkReference(b*testing.B) {
params:=TestParams{extensions: parser.CommonExtensions}
files:=append(refFiles, "Hard-wrapped paragraphs with list-like lines")
vartests []string
for_, basename:=rangefiles {
filename:=filepath.Join("testdata", basename+".text")
inputBytes, err:=ioutil.ReadFile(filename)
iferr!=nil {
b.Errorf("Couldn't open '%s', error: %v\n", filename, err)
continue
}
tests=append(tests, string(inputBytes))
}
b.ResetTimer()
forn:=0; n<b.N; n++ {
for_, test:=rangetests {
benchResultAnchor=runMarkdown(test, params)
}
}
}