This repository has been archived by the owner on Jan 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarkovic_test.go
69 lines (56 loc) · 1.57 KB
/
markovic_test.go
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
package markovic_test
import (
"strings"
"testing"
"github.com/miekg/mmark"
"github.com/russross/blackfriday"
"github.com/stretchr/testify/assert"
"github.com/subosito/markovic"
"github.com/subosito/markovic/cmark"
)
func TestHTML(t *testing.T) {
r := strings.NewReader("# Hello")
s := markovic.HTML(r)
assert.Equal(t, "<h1>Hello</h1>\n", s)
}
func TestXML(t *testing.T) {
r := strings.NewReader("# Hello")
s := markovic.XML(r)
assert.Equal(t, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE document SYSTEM \"CommonMark.dtd\">\n<document xmlns=\"http://commonmark.org/xml/1.0\">\n <heading level=\"1\">\n <text>Hello</text>\n </heading>\n</document>\n", s)
}
func TestMan(t *testing.T) {
r := strings.NewReader("# Hello")
s := markovic.Man(r, 10)
assert.Equal(t, ".SH\nHello\n", s)
}
func TestCommonMark(t *testing.T) {
r := strings.NewReader("# Hello")
s := markovic.CommonMark(r, 10)
assert.Equal(t, "# Hello\n", s)
}
func TestLaTeX(t *testing.T) {
r := strings.NewReader("# Hello")
s := markovic.LaTeX(r, 10)
assert.Equal(t, "\\section{Hello}\n", s)
}
func TestVersion(t *testing.T) {
v := cmark.Version()
assert.Equal(t, "0.26.1", v)
}
func BenchmarkHTML_Marković(b *testing.B) {
r := strings.NewReader("# Hello")
for n := 0; n < b.N; n++ {
markovic.HTML(r)
}
}
func BenchmarkHTML_BlackFriday(b *testing.B) {
for n := 0; n < b.N; n++ {
blackfriday.MarkdownBasic([]byte("# Hello"))
}
}
func BenchmarkHTML_MMark(b *testing.B) {
renderer := mmark.HtmlRenderer(0, "", "")
for n := 0; n < b.N; n++ {
mmark.Parse([]byte("# Hello"), renderer, 0)
}
}