diff --git a/markup/img_test.go b/markup/img_test.go deleted file mode 100644 index f2e2044..0000000 --- a/markup/img_test.go +++ /dev/null @@ -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]) - } - } -} diff --git a/markup/lexer_test.go b/markup/lexer_test.go deleted file mode 100644 index b19bec2..0000000 --- a/markup/lexer_test.go +++ /dev/null @@ -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, "
quote"}, - {5, `
text
"}, - {7, "more text
"}, - {8, ``}, - {9, `=> preformatted text
-where markup is not lexed
`},
- {11, ``},
- {12, "text
"}, - {13, `()
-/\
`},
- {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"},
- },
- }},
- })
-}
diff --git a/markup/paragraph_test.go b/markup/paragraph_test.go
deleted file mode 100644
index 71bd5fc..0000000
--- a/markup/paragraph_test.go
+++ /dev/null
@@ -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//", "italic"},
- {"Embedded //italic//", "Embedded italic"},
- {"double //italian// //text//", "double italian text"},
- {"it has `mono`", "it has mono
"},
- {"it has ~~strike~~", "it has