From bcb33f7048e911189eadf1ecf977bf429ddf83a6 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Sun, 14 Mar 2021 20:24:46 +0500 Subject: [PATCH] Delete the markup tests --- markup/img_test.go | 47 ---------------------------- markup/lexer_test.go | 67 ---------------------------------------- markup/paragraph_test.go | 50 ------------------------------ markup/xclusion_test.go | 22 ------------- 4 files changed, 186 deletions(-) delete mode 100644 markup/img_test.go delete mode 100644 markup/lexer_test.go delete mode 100644 markup/paragraph_test.go delete mode 100644 markup/xclusion_test.go 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, "

1

"}, - {2, "

2

"}, - {3, "

3

"}, - {4, "
quote
"}, - {5, ``}, - {6, "

text

"}, - {7, "

more text

"}, - {8, `

some link

`}, - {9, ``}, - {10, `
=> preformatted text
-where markup is not lexed
`}, - {11, `

linking

`}, - {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 strike"}, - {"this is a left **bold", "this is a left bold"}, - {"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 simple 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 } -} diff --git a/markup/xclusion_test.go b/markup/xclusion_test.go deleted file mode 100644 index d61a2ad..0000000 --- a/markup/xclusion_test.go +++ /dev/null @@ -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}) -}