markitzero_test.go (view raw)
1package main
2
3import (
4 "testing"
5)
6
7func onetest(t *testing.T, input, output string) {
8 result := markitzero(input)
9 if result != output {
10 t.Errorf("\nexpected:\n%s\noutput:\n%s", output, result)
11 }
12}
13
14func basictest(t *testing.T) {
15 input := `link to https://example.com/ with **bold** text`
16 output := `link to <a class="mention u-url" href="https://example.com/">https://example.com/</a> with <b>bold</b> text`
17 onetest(t, input, output)
18}
19
20func linebreak1(t *testing.T) {
21 input := "hello\n> a quote\na comment"
22 output := "hello<blockquote>a quote</blockquote><p>a comment"
23 onetest(t, input, output)
24}
25
26func linebreak2(t *testing.T) {
27 input := "hello\n\n> a quote\n\na comment"
28 output := "hello<br><blockquote>a quote</blockquote><p>a comment"
29 onetest(t, input, output)
30}
31
32func linebreak3(t *testing.T) {
33 input := "hello\n\n```\nfunc(s string)\n```\n\ndoes it go?"
34 output := "hello<br><pre><code>func(s string)</code></pre><p>does it go?"
35 onetest(t, input, output)
36}
37
38func TestMarkitzero(t *testing.T) {
39 basictest(t)
40 linebreak1(t)
41 linebreak2(t)
42 linebreak3(t)
43}