1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
13 var headingTests = []struct {
18 {"A typical usage", true},
19 {"ΔΛΞ is Greek", true},
23 {"A typical usage:", false},
24 {"This code:", false},
25 {"δ is Greek", false},
27 {"Fermat's Last Sentence", true},
30 {"Ted 'Too' Bar", false},
36 func TestIsHeading(t *testing.T) {
37 for _, tt := range headingTests {
38 if h := heading(tt.line); (len(h) > 0) != tt.ok {
39 t.Errorf("isHeading(%q) = %v, want %v", tt.line, h, tt.ok)
44 var blocksTests = []struct {
66 {opPara, []string{"Para 1.\n", "Para 1 line 2.\n"}},
67 {opPara, []string{"Para 2.\n"}},
68 {opHead, []string{"Section"}},
69 {opPara, []string{"Para 3.\n"}},
70 {opPre, []string{"pre\n", "pre1\n"}},
71 {opPara, []string{"Para 4.\n"}},
72 {opPre, []string{"pre\n", "pre2\n"}},
77 func TestBlocks(t *testing.T) {
78 for i, tt := range blocksTests {
80 if !reflect.DeepEqual(b, tt.out) {
81 t.Errorf("#%d: mismatch\nhave: %v\nwant: %v", i, b, tt.out)
86 var emphasizeTests = []struct {
90 {"http://www.google.com/", `<a href="http://www.google.com/">http://www.google.com/</a>`},
91 {"https://www.google.com/", `<a href="https://www.google.com/">https://www.google.com/</a>`},
92 {"http://www.google.com/path.", `<a href="http://www.google.com/path">http://www.google.com/path</a>.`},
93 {"(http://www.google.com/)", `(<a href="http://www.google.com/">http://www.google.com/</a>)`},
94 {"Foo bar http://example.com/ quux!", `Foo bar <a href="http://example.com/">http://example.com/</a> quux!`},
95 {"Hello http://example.com/%2f/ /world.", `Hello <a href="http://example.com/%2f/">http://example.com/%2f/</a> /world.`},
96 {"Lorem http: ipsum //host/path", "Lorem http: ipsum //host/path"},
97 {"javascript://is/not/linked", "javascript://is/not/linked"},
100 func TestEmphasize(t *testing.T) {
101 for i, tt := range emphasizeTests {
103 emphasize(&buf, tt.in, nil, true)
106 t.Errorf("#%d: mismatch\nhave: %v\nwant: %v", i, out, tt.out)