diff --git a/comp/src/gb.markdown/.src/TMarkdown.test b/comp/src/gb.markdown/.src/TMarkdown.test new file mode 100644 index 000000000..3838cf405 --- /dev/null +++ b/comp/src/gb.markdown/.src/TMarkdown.test @@ -0,0 +1,424 @@ +' Gambas test file + +Public Sub TestParagraph() + + Dim md, expect, got As String + + md = "blah" & gb.lf & gb.lf & "blub" & gb.lf & gb.lf & "dingdong" + expect = "

blah

" & gb.lf & "

blub

" & gb.lf & "

dingdong

" + got = Markdown.ToHTML(md) + Assert.Equals(got, expect, "Markdown paragraph") + +End + +Public Sub TestParagraphTwo() + + Dim md, expect, got As String + + md = "blah" & gb.lf & gb.lf & "blub" & gb.lf & "dingdong" + expect = "

blah

" & gb.lf & "

blub" & gb.lf & "dingdong

" + got = Markdown.ToHTML(md) + Assert.Equals(got, expect, "Markdown paragraph Two") + +End + +Public Sub TestParagraphThree() + + Dim md, expect, got As String + + md = "blah" & gb.lf & gb.lf & "blub" + expect = "

blah

" & gb.lf & "

blub

" + got = Markdown.ToHTML(md) + Assert.Equals(got, expect, "Markdown paragraph Three") + 'Assert.Note("I got:" & gb.lf & got) + +End + +Public Sub TestHeadline() + + Dim md, expect, got As String + + md = "# dingdong midhl endhl" + expect = "

dingdong midhl endhl

" + got = Markdown.ToHTML(md) + Assert.Equals(got, expect, "Markdown headline 1-1") + 'Assert.Note("I got:" & gb.lf & got) + + md = "# dingdong midhl endhl #" + expect = "

dingdong midhl endhl

" + got = Markdown.ToHTML(md) + Assert.Equals(got, expect, "Markdown headline 1-2 alternative") + 'Assert.Note("I got:" & gb.lf & got) + + md = "## dingdong midhl endhl" + expect = "

dingdong midhl endhl

" + got = Markdown.ToHTML(md) + Assert.Equals(got, expect, "Markdown headline 2") + 'Assert.Note("I got:" & gb.lf & got) + + md = "### dingdong midhl endhl" + expect = "

dingdong midhl endhl

" + got = Markdown.ToHTML(md) + Assert.Equals(got, expect, "Markdown headline 3") + 'Assert.Note("I got:" & gb.lf & got) + + md = "#### dingdong midhl endhl" + expect = "

dingdong midhl endhl

" + got = Markdown.ToHTML(md) + Assert.Equals(got, expect, "Markdown headline 4") + 'Assert.Note("I got:" & gb.lf & got) + + md = "##### dingdong midhl endhl" + expect = "
dingdong midhl endhl
" + got = Markdown.ToHTML(md) + Assert.Equals(got, expect, "Markdown headline 5") + 'Assert.Note("I got:" & gb.lf & got) + + md = "###### dingdong midhl endhl" + expect = "
dingdong midhl endhl
" + got = Markdown.ToHTML(md) + Assert.Equals(got, expect, "Markdown headline 6") + 'Assert.Note("I got:" & gb.lf & got) + +End + +Public Sub TestHeadlineThree() + + Dim md, got As String + + md = "#dingdong" + Try got = Markdown.ToHTML(md) + Assert.Todo() + Assert.Error("Markdown headline error") + 'Assert.Note("I got:" & gb.lf & got) + +End + +Public Sub TestHlAndParagraph() + + Dim md, expect, got As String + + md = "# headline" & gb.lf & gb.lf & "blub" + expect = "

headline

" & gb.lf & "

blub

" + got = Markdown.ToHTML(md) + Assert.Equals(got, expect, "Markdown headline and paragraph") + +End + +Public Sub TestHlAndLineAndParagraph() + + Dim md, expect, got As String + + md = "# headline" & gb.lf & "---" & gb.lf & "blub" + expect = "

headline

" & gb.lf & "
" & gb.lf & "

blub

" + got = Markdown.ToHTML(md) + Assert.Todo() + Assert.Equals(got, expect, "Markdown headline and paragraph") + ' Assert.Note("I got:" & gb.lf & got) + +End + +Public Sub TestHtmlTagIntegrity() + + Dim md, expect, got As String + + md = "# headline" & gb.lf & gb.lf & "blub" & gb.lf & gb.lf & + "" + + expect = "

headline

" & gb.lf & + "

blub

" & gb.lf & + "" + + got = Markdown.ToHTML(md) + Assert.Todo() + Assert.Equals(got, expect, "Markdown TestHtmlTagIntegrity") + 'Assert.Note("I got:" & gb.lf & got) + +End + +Public Sub TestHtmlTagIntegrityTwo() + + Dim md, expect, got As String + + md = "
" & gb.lf & + "test" & gb.lf & + "anothersth" & gb.lf & + "anothersth and so on." & gb.lf & + "
" + + expect = "
" & gb.lf & + "

test" & gb.lf & + "anothersth" & gb.lf & + "anothersth and so on.

" & gb.lf & + "
" + + got = Markdown.ToHTML(md) + Assert.Todo() + Assert.Equals(got, expect, "Markdown headline and paragraph") + 'Assert.Note("I got:" & gb.lf & got) + +End + +Public Sub TestUL() + + Dim md, expect, got As String + + md = "* One" & gb.lf & + "* Two" & gb.Lf & + "* Three" + + expect = "" + + got = Markdown.ToHTML(md) + Assert.Todo() + Assert.Equals(got, expect, "Markdown UL") + ' Assert.Note("I got:" & gb.lf & got) + +End + +Public Sub TestOL() + + Dim md, expect, got As String + + md = "1. One" & gb.lf & + "1. Two" & gb.Lf & + "1. Three" + + expect = "
    " & gb.Lf & + "
  1. " & gb.Lf & + " One" & gb.Lf & + "
  2. " & gb.Lf & + "
  3. " & gb.Lf & + " Two" & gb.Lf & + "
  4. " & gb.Lf & + "
  5. " & gb.Lf & + " Three" & gb.Lf & + "
  6. " & gb.Lf & + "
" + + got = Markdown.ToHTML(md) + Assert.Todo() + Assert.Equals(got, expect, "Markdown OL") + +End + +Public Sub TestOLWithImage() + + Dim md, expect, got As String + + md = "1. One" & gb.lf & + "1. " & gb.Lf & + "1. Three" + + expect = "
    " & gb.Lf & + "
  1. " & gb.Lf & + " One" & gb.Lf & + "
  2. " & gb.Lf & + "
  3. " & gb.Lf & + " " & gb.Lf & + "
  4. " & gb.Lf & + "
  5. " & gb.Lf & + " Three" & gb.Lf & + "
  6. " & gb.Lf & + "
" + + got = Markdown.ToHTML(md) + Assert.Todo() + Assert.Equals(got, expect, "Markdown OL with image") + ' Assert.Note("I expected:" & gb.lf & expect) + 'Assert.Note("I got:" & gb.lf & got) + +End + +Public Sub TestHtmlTags() + + Dim md, expect, got As String + + md = "" + + expect = "" + + got = Markdown.ToHTML(md) + Assert.Todo() + Assert.Equals(got, expect, "Markdown image") + + ' Assert.Note("I expected:" & gb.lf & expect) + 'Assert.Note("I got:" & gb.lf & got) + +End + +Public Sub TestTable() + + Dim md, expect, got As String + + md = "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "
" & gb.Lf & + "Bis kg" & + "" & gb.Lf & + "Versandpreis" & + "
" & gb.Lf & + "1,6 kg" & + "" & gb.Lf & + "4,50 €" & + "
" + + expect = "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "
" & gb.Lf & + "Bis kg" & + "" & gb.Lf & + "Versandpreis" & + "
" & gb.Lf & + "1,6 kg" & + "" & gb.Lf & + "4,50 €" & + "
" + + got = Markdown.ToHTML(md) + Assert.Todo() + Assert.Equals(got, expect, "Markdown preserve table") + 'Assert.Note(got) + +End + +Public Sub TestParInTable() + + Dim md, expect, got As String + + md = "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "
" & gb.Lf & + "

Bis kg

" & + "
" & gb.Lf & + "Versandpreis" & + "
" & gb.Lf & + "1,6 kg" & + "" & gb.Lf & + "4,50 €" & + "
" + + expect = "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "" & gb.Lf & + "
" & gb.Lf & + "

Bis kg

" & + "
" & gb.Lf & + "Versandpreis" & + "
" & gb.Lf & + "1,6 kg" & + "" & gb.Lf & + "4,50 €" & + "
" + + got = Markdown.ToHTML(md) + Assert.Todo() + Assert.Equals(got, expect, "Markdown preserve p in table") + 'Assert.Note(got) + +End + +Public Sub TestPreserverUL() + + Dim md, expect, got As String + + md = "" + + expect = "" + + got = Markdown.ToHTML(md) + Assert.Todo() + Assert.Equals(got, expect, "Markdown preserve ul") + 'Assert.Note(got) + +End + +Public Sub TestPreserverOL() + + Dim md, expect, got As String + + md = "
    " & gb.Lf & + "
  1. First li
  2. " & gb.Lf & + "
  3. Second li
  4. " & gb.Lf & + "
  5. Third li
  6. " & gb.Lf & + "
  7. Fourth li
  8. " & gb.Lf & + "
  9. Mambo no five
  10. " & gb.Lf & + "
" + + expect = "
    " & gb.Lf & + Trim("
  1. First li
  2. ") & gb.Lf & + Trim("
  3. Second li
  4. ") & gb.Lf & + Trim("
  5. Third li
  6. ") & gb.Lf & + Trim("
  7. Fourth li
  8. ") & gb.Lf & + Trim("
  9. Mambo no five
  10. ") & gb.Lf & + "
" + + got = Markdown.ToHTML(md) + Assert.Todo() + Assert.Equals(got, expect, "Markdown preserve ol") + 'Assert.Note(got) + +End + +Public Sub TestStrong() + + Dim md, expect, got As String + + md = "Das berühmte Deganius Kräuterabo" & gb.lf & gb.Lf & "Balb" + expect = "

Das berühmte Deganius Kräuterabo

" & gb.lf & "

Balb

" + got = Markdown.ToHTML(md) + + If Assert.Equals(got, expect, "Markdown strong paragraph") = False Then + Test.Note(got) + Endif + +End diff --git a/comp/src/gb.markdown/.test b/comp/src/gb.markdown/.test new file mode 100644 index 000000000..f1a053492 --- /dev/null +++ b/comp/src/gb.markdown/.test @@ -0,0 +1,9 @@ +[TestSuites] +Count=1 +TestWith=1 +Default="TMarkdown.TestHeadline;TestHeadlineThree;TestHlAndLineAndParagraph;TestHlAndParagraph;TestHtmlTagIntegrity;TestHtmlTagIntegrityTwo;TestHtmlTags;TestOL;TestOLWithImage;TestParInTable;TestParagraph;TestParagraphThree;TestParagraphTwo;TestPreserverOL;TestPreserverUL;TestStrong;TestTable;TestUL" + +[TestSuites/1] +Name="OL" +Tests="TMarkdown.TestOL" +