mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-01-05 17:40:26 +00:00
Delete the markup tests
This commit is contained in:
parent
016aa83016
commit
bcb33f7048
@ -1,47 +0,0 @@
|
||||
package markup
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseStartOfEntry(t *testing.T) {
|
||||
img := ImgFromFirstLine("img {", "h")
|
||||
tests := []struct {
|
||||
line string
|
||||
entry imgEntry
|
||||
followedByDesc bool
|
||||
}{
|
||||
{"apple", imgEntry{"/binary/apple", "", "", ""}, false},
|
||||
{"pear|", imgEntry{"/binary/pear", "", "", ""}, false},
|
||||
{"яблоко| 30*60", imgEntry{"/binary/яблоко", "30", "60", ""}, false},
|
||||
{"груша | 65 ", imgEntry{"/binary/груша", "65", "", ""}, false},
|
||||
{"жеронимо | 30 { full desc }", imgEntry{"/binary/жеронимо", "30", "", " full desc "}, false},
|
||||
{"жорно жованна | *5555 {partial description", imgEntry{"/binary/жорно_жованна", "", "5555", "partial description"}, true},
|
||||
{"иноске | {full}", imgEntry{"/binary/иноске", "", "", "full"}, false},
|
||||
{"j|{partial", imgEntry{"/binary/j", "", "", "partial"}, true},
|
||||
}
|
||||
for _, triplet := range tests {
|
||||
entry, followedByDesc := img.parseStartOfEntry(triplet.line)
|
||||
if entry != triplet.entry || followedByDesc != triplet.followedByDesc {
|
||||
t.Error(fmt.Sprintf("%q:%q != %q; %v != %v", triplet.line, entry, triplet.entry, followedByDesc, triplet.followedByDesc))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseDimensions(t *testing.T) {
|
||||
tests := [][]string{
|
||||
{"500", "500", ""},
|
||||
{"3em", "3em", ""},
|
||||
{"500*", "500", ""},
|
||||
{"*500", "", "500"},
|
||||
{"800*520", "800", "520"},
|
||||
{"17%*5rem", "17%", "5rem"},
|
||||
}
|
||||
for _, triplet := range tests {
|
||||
sizeH, sizeV := parseDimensions(triplet[0])
|
||||
if sizeH != triplet[1] || sizeV != triplet[2] {
|
||||
t.Error(sizeH, "*", sizeV, " != ", triplet[1], "*", triplet[2])
|
||||
}
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
package markup
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TODO: move test markup docs to files, perhaps? These strings sure are ugly
|
||||
func TestLex(t *testing.T) {
|
||||
check := func(name, content string, expectedAst []Line) {
|
||||
if ast := lex(name, content); !reflect.DeepEqual(ast, expectedAst) {
|
||||
if len(ast) != len(expectedAst) {
|
||||
t.Error("Expected and generated AST length of", name, "do not match. Printed generated AST.")
|
||||
for _, l := range ast {
|
||||
fmt.Printf("%d: %s\n", l.id, l.contents)
|
||||
}
|
||||
return
|
||||
}
|
||||
for i, e := range ast {
|
||||
if !reflect.DeepEqual(e, expectedAst[i]) {
|
||||
t.Error(fmt.Sprintf("Expected: %q\nGot:%q", expectedAst[i], e))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
contentsB, err := ioutil.ReadFile("testdata/test.myco")
|
||||
if err != nil {
|
||||
t.Error("Could not read test markup file!")
|
||||
}
|
||||
contents := string(contentsB)
|
||||
check("Apple", contents, []Line{
|
||||
{1, "<h1 id='1'>1</h1>"},
|
||||
{2, "<h2 id='2'>2</h2>"},
|
||||
{3, "<h3 id='3'>3</h3>"},
|
||||
{4, "<blockquote id='4'>quote</blockquote>"},
|
||||
{5, `<ul id='5'>
|
||||
<li>li 1</li>
|
||||
<li>li 2</li>
|
||||
</ul>`},
|
||||
{6, "<p id='6'>text</p>"},
|
||||
{7, "<p id='7'>more text</p>"},
|
||||
{8, `<p><a id='8' class='rocketlink wikilink_internal' href="/page/pear">some link</a></p>`},
|
||||
{9, `<ul id='9'>
|
||||
<li>lin"+</li>
|
||||
</ul>`},
|
||||
{10, `<pre id='10' alt='alt text goes here' class='codeblock'><code>=> preformatted text
|
||||
where markup is not lexed</code></pre>`},
|
||||
{11, `<p><a id='11' class='rocketlink wikilink_internal' href="/page/linking">linking</a></p>`},
|
||||
{12, "<p id='12'>text</p>"},
|
||||
{13, `<pre id='13' alt='' class='codeblock'><code>()
|
||||
/\</code></pre>`},
|
||||
{14, Transclusion{"apple", 1, 3}},
|
||||
{15, Img{
|
||||
hyphaName: "Apple",
|
||||
inDesc: false,
|
||||
entries: []imgEntry{
|
||||
{"/binary/hypha1", "", "", ""},
|
||||
{"/binary/hypha2", "", "", ""},
|
||||
{"/binary/hypha3", "60", "", ""},
|
||||
{"/binary/hypha4", "", "", " line1\nline2\n"},
|
||||
{"/binary/hypha5", "", "", "\nstate of minnesota\n"},
|
||||
},
|
||||
}},
|
||||
})
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package markup
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
/*
|
||||
func TestGetTextNode(t *testing.T) {
|
||||
tests := [][]string{
|
||||
// input textNode rest
|
||||
{"barab", "barab", ""},
|
||||
{"test, ", "test", ", "},
|
||||
{"/test/", "", "/test/"},
|
||||
{"\\/test/", "/test", "/"},
|
||||
{"test \\/ar", "test /ar", ""},
|
||||
{"test //italian// test", "test ", "//italian// test"},
|
||||
}
|
||||
for _, triplet := range tests {
|
||||
a, b := getTextNode([]byte(triplet[0]))
|
||||
if a != triplet[1] || string(b) != triplet[2] {
|
||||
t.Error(fmt.Sprintf("Wanted: %q\nGot: %q %q", triplet, a, b))
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
func TestParagraphToHtml(t *testing.T) {
|
||||
tests := [][]string{
|
||||
{"a simple paragraph", "a simple paragraph"},
|
||||
{"//italic//", "<em>italic</em>"},
|
||||
{"Embedded //italic//", "Embedded <em>italic</em>"},
|
||||
{"double //italian// //text//", "double <em>italian</em> <em>text</em>"},
|
||||
{"it has `mono`", "it has <code>mono</code>"},
|
||||
{"it has ~~strike~~", "it has <s>strike</s>"},
|
||||
{"this is a left **bold", "this is a left <strong>bold</strong>"},
|
||||
{"this line has a ,comma, two of them", "this line has a ,comma, two of them"},
|
||||
{"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."},
|
||||
{"A [[simple]] link", `A <a href="/page/simple" class="wikilink_internal">simple</a> link`},
|
||||
}
|
||||
for _, test := range tests {
|
||||
if ParagraphToHtml("Apple", test[0]) != test[1] {
|
||||
t.Error(fmt.Sprintf("%q: Wanted %q, got %q", test[0], test[1], ParagraphToHtml("Apple", test[0])))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
HyphaExists = func(_ string) bool { return true }
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package markup
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseTransclusion(t *testing.T) {
|
||||
check := func(line string, expectedXclusion Transclusion) {
|
||||
if xcl := parseTransclusion(line, "t"); xcl != expectedXclusion {
|
||||
t.Error(line, "; got:", xcl, "wanted:", expectedXclusion)
|
||||
}
|
||||
}
|
||||
check("<= ", Transclusion{"", -9, -9})
|
||||
check("<=hypha", Transclusion{"hypha", 0, 0})
|
||||
check("<= hypha\t", Transclusion{"hypha", 0, 0})
|
||||
check("<= hypha :", Transclusion{"hypha", 0, 0})
|
||||
check("<= hypha : ..", Transclusion{"hypha", 0, 0})
|
||||
check("<= hypha : 3", Transclusion{"hypha", 3, 3})
|
||||
check("<= hypha : 3..", Transclusion{"hypha", 3, 0})
|
||||
check("<= hypha : ..3", Transclusion{"hypha", 0, 3})
|
||||
check("<= hypha : 3..4", Transclusion{"hypha", 3, 4})
|
||||
}
|
Loading…
Reference in New Issue
Block a user