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
|
// +build 1.6,codegen
package api
import (
"testing"
)
func TestNonHTMLDocGen(t *testing.T) {
doc := "Testing 1 2 3"
expected := "// Testing 1 2 3\n"
doc = docstring(doc)
if expected != doc {
t.Errorf("Expected %s, but received %s", expected, doc)
}
}
func TestListsHTMLDocGen(t *testing.T) {
doc := "<ul><li>Testing 1 2 3</li> <li>FooBar</li></ul>"
expected := "// * Testing 1 2 3\n// * FooBar\n"
doc = docstring(doc)
if expected != doc {
t.Errorf("Expected %s, but received %s", expected, doc)
}
doc = "<ul> <li>Testing 1 2 3</li> <li>FooBar</li> </ul>"
expected = "// * Testing 1 2 3\n// * FooBar\n"
doc = docstring(doc)
if expected != doc {
t.Errorf("Expected %s, but received %s", expected, doc)
}
// Test leading spaces
doc = " <ul> <li>Testing 1 2 3</li> <li>FooBar</li> </ul>"
doc = docstring(doc)
if expected != doc {
t.Errorf("Expected %s, but received %s", expected, doc)
}
// Paragraph check
doc = "<ul> <li> <p>Testing 1 2 3</p> </li><li> <p>FooBar</p></li></ul>"
expected = "// * Testing 1 2 3\n// \n// * FooBar\n"
doc = docstring(doc)
if expected != doc {
t.Errorf("Expected %s, but received %s", expected, doc)
}
}
func TestInlineCodeHTMLDocGen(t *testing.T) {
doc := "<ul> <li><code>Testing</code>: 1 2 3</li> <li>FooBar</li> </ul>"
expected := "// * Testing: 1 2 3\n// * FooBar\n"
doc = docstring(doc)
if expected != doc {
t.Errorf("Expected %s, but received %s", expected, doc)
}
}
func TestInlineCodeInParagraphHTMLDocGen(t *testing.T) {
doc := "<p><code>Testing</code>: 1 2 3</p>"
expected := "// Testing: 1 2 3\n"
doc = docstring(doc)
if expected != doc {
t.Errorf("Expected %s, but received %s", expected, doc)
}
}
func TestEmptyPREInlineCodeHTMLDocGen(t *testing.T) {
doc := "<pre><code>Testing</code></pre>"
expected := "// Testing\n"
doc = docstring(doc)
if expected != doc {
t.Errorf("Expected %s, but received %s", expected, doc)
}
}
func TestParagraph(t *testing.T) {
doc := "<p>Testing 1 2 3</p>"
expected := "// Testing 1 2 3\n"
doc = docstring(doc)
if expected != doc {
t.Errorf("Expected %s, but received %s", expected, doc)
}
}
func TestComplexListParagraphCode(t *testing.T) {
doc := "<ul> <li><p><code>FOO</code> Bar</p></li><li><p><code>Xyz</code> ABC</p></li></ul>"
expected := "// * FOO Bar\n// \n// * Xyz ABC\n"
doc = docstring(doc)
if expected != doc {
t.Errorf("Expected %s, but received %s", expected, doc)
}
}
|