123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- #include "../../tedi2lang/dessert.hpp"
- #include "../../tedi2lang/tedi2lang.h"
- #include "../tedi2html.h"
- #include "../../tedi2lang/exception.h"
- #include <string>
- #include <cstring>
- #include <iostream>
- int main(){
-
- tedi2html td;
- //Empty string
- cout << "EMPTY STRINGS" << endl;
- dessert((td.convert("", "", "")) == (""));
- dessert(td.convert(" ", "", "") == (" \n"));
- dessert(td.convert("\n\n\n", "", "") == ("\n\n\n"));
- //Titles
- cout << "TITLES" << endl;
- dessert(throws(td.convert("#####", "", "")));
- dessert(td.convert("paragraph\n#This isn't a title", "", "") == ("<p>paragraph\n</p>\n<h1>This isn't a title</h1>\n"));
- dessert(td.convert("#This isn't a title", "", "") == ("<h1>This isn't a title</h1>\n"));
- dessert(td.convert(" #This isn't a title", "", "") == ("<h1>This isn't a title</h1>\n"));
- dessert(td.convert("\t##This isn't a title", "", "") == ("<h2>This isn't a title</h2>\n"));
- dessert(td.convert("##This isn't a title", "", "") == ("<h2>This isn't a title</h2>\n"));
- dessert(td.convert("###This isn't a title", "", "") == ("<h3>This isn't a title</h3>\n"));
- dessert(td.convert("####This isn't a title", "", "") == ("<h4>This isn't a title</h4>\n"));
- dessert(td.convert("#####This isn't a title", "", "") == "<h4>This isn't a title</h4>\n" );
- dessert(td.convert("#####This isn't a title", "", "") == "<h4>This isn't a title</h4>\n" );
- cout << "LIST" << endl;
- dessert(td.convert("__", "", "") == ("<ul>\n"));
- dessert(td.convert("--Text", "", "") == ("<p>--Text\n</p>\n"));
- dessert(td.convert(",,", "", "") == ("<p>,,\n</p>\n"));
- dessert(td.convert("__\n--Text\n,,", "", "") == ("<ul>\n<li>Text\n</ul>\n"));
- cout << "QUOTE" << endl;
- dessert(td.convert("\"Quoted text\"", "", "") == ("<p>Quoted text\n</p>\n"));
- dessert(throws(td.convert("\"Bad quoting", "", "")));
- cout << "LINKS" << endl;
- dessert(td.convert("[Test with a open square bracket", "", "") == ("<p>[Test with a open square bracket\n</p>\n"));
- dessert(throws(td.convert("[(Test with a open square bracket and parenthesis", "", "")));
- dessert(throws(td.convert("[(Test without closing square bracket)", "", "")));
- dessert(throws(td.convert("[(Test with closing square bracket)]", "", "")));
- dessert(td.convert("[(Test with closing square bracket) ]", "", "") == "<p><a href=\"Test with closing square bracket\"></a>\n</p>\n");
- dessert(td.convert("[() ]", "", "") == "<p><a href=\"\"></a>\n</p>\n");
- dessert(td.convert("[( ) ]", "", "") == "<p><a href=\" \"></a>\n</p>\n");
- dessert(throws(td.convert("[(test\\) test with escaped char\\) ]", "", "")));
- dessert(td.convert("[(test\\) test with escaped char) ]", "", "") == "<p><a href=\"test) test with escaped char\"></a>\n</p>\n");
- dessert(td.convert("[(test\\) test with escaped char) \\]sasdfasd]", "", "") == "<p><a href=\"test) test with escaped char\">]sasdfasd</a>\n</p>\n");
- dessert(td.convert("[(test\\( test with escaped char) \\]sasdfasd]", "", "") == "<p><a href=\"test( test with escaped char\">]sasdfasd</a>\n</p>\n");
- dessert(td.convert("\\([Test with closing square bracket) text", "", "") == "<p>([Test with closing square bracket) text\n</p>\n");
- dessert(td.convert("\\([ ([Test with closing square bracket] text)", "", "") == "<p>([ <img alt=\"Test with closing square bracket\" src=\"text\">\n</p>\n");
- cout << "IMAGES" << endl;
- dessert(td.convert("(Test with an open parenthesis", "", "") == ("<p>(Test with an open parenthesis\n</p>\n"));
-
- dessert(throws(td.convert("([Test with a open square bracket and parenthesis", "", "")));
- dessert(throws(td.convert("([Test without closing square bracket]", "", "")));
- dessert(throws(td.convert("([Test with closing square bracket])", "", "")));
- dessert(td.convert("([Test with closing square bracket] )", "", "") == "<p><img alt=\"Test with closing square bracket\" src=\"\">\n</p>\n");
- dessert(td.convert("([] )", "", "") == "<p><img alt=\"\" src=\"\">\n</p>\n");
- dessert(td.convert("([ ] )", "", "") == "<p><img alt=\" \" src=\"\">\n</p>\n");
- dessert(throws(td.convert("([test\\] test with escaped char\\] )", "", "")));
- dessert(td.convert("([test\\] test with escaped char] )", "", "") == "<p><img alt=\"test] test with escaped char\" src=\"\">\n</p>\n");
- dessert(td.convert("([test\\] test with escaped char] \\)sasdfasd)", "", "") == "<p><img alt=\"test] test with escaped char\" src=\")sasdfasd\">\n</p>\n");
- dessert(td.convert("\\([Test with closing square bracket) text", "", "") == "<p>([Test with closing square bracket) text\n</p>\n");
- dessert(td.convert("\\([ ([Test with closing square bracket] text)", "", "") == "<p>([ <img alt=\"Test with closing square bracket\" src=\"text\">\n</p>\n");
- cout << "BLOCKS" << endl;
- dessert(td.convert("{Test with an open parenthesis", "", "") == ("<p>{Test with an open parenthesis\n</p>\n"));
- dessert(throws(td.convert("{(Test with a open square bracket and parenthesis", "", "")));
- dessert(throws(td.convert("{(Test without closing square bracket)", "", "")));
- dessert(throws(td.convert("{(Test with closing square bracket)}", "", "")));
- dessert(td.convert("{(Test with closing square bracket) }", "", "") == "<div class=\"Test with closing square bracket\"></div>\n");
- dessert(td.convert("{() }", "", "") == "<div class=\"\"></div>\n");
- dessert(td.convert("{( ) }", "", "") == "<div class=\" \"></div>\n");
- dessert(throws(td.convert("{(test\\) test with escaped char\\) }", "", "")));
- dessert(td.convert("{(test\\) test with escaped char) }", "", "") == "<div class=\"test) test with escaped char\"></div>\n");
- dessert(td.convert("{(test\\) test with escaped char) \\}sasdfasd}", "", "") == "<div class=\"test) test with escaped char\">}sasdfasd</div>\n");
- dessert(td.convert("\\{(Test with closing square bracket) text", "", "") == "<p>{(Test with closing square bracket) text\n</p>\n");
- dessert(td.convert("\\{( {(Test with closing square bracket) text}", "", "") == "{( <div class=\"Test with closing square bracket\">text</div>\n");
- cout << "MULTIPLES UNQUOTED TAGS" << endl;
- dessert(td.convert("[Test with a open square bracket ( also parenthesis and { brackets", "", "") == ("<p>[Test with a open square bracket ( also parenthesis and { brackets\n</p>\n"));
- dessert(td.convert("[(url) Test with a link ([alternative text] image url)] and {(class) brackets}", "", "") == ("<a href=\"url\">Test with a link <img alt=\"alternative text\" src=\"image url\"></a> and <div class=\"class\">brackets</div>\n"));
- dessert(td.convert("{(class) [(url) Test with a link ([alternative text] image url)] and brackets}", "", "") == ("<div class=\"class\"><a href=\"url\">Test with a link <img alt=\"alternative text\" src=\"image url\"></a> and brackets</div>\n"));
- cout << "TABLE" << endl;
- dessert(td.convert("| first cell | second cell |", "", "") == "<table>\n<tr>\n<td> first cell </td>\n<td> second cell </td>\n</tr>\n</table>\n");
- dessert(td.convert("| first cell ", "", "") == "<p>| first cell </p>\n");
- dessert(throws(td.convert("| first cell | second cell ", "", "")));
- dessert(td.convert("| first cell | second cell |\n| third cell | fourth cell |", "", "") == "<table>\n<tr>\n<td> first cell </td>\n<td> second cell </td>\n</tr>\n<tr>\n<td> third cell </td>\n<td> fourth cell </td>\n</tr>\n</table>\n");
- dessert(td.convert("| first cell |\n| second cell | third cell |", "", "") == "<table>\n<tr>\n<td> first cell </td>\n</tr>\n<tr>\n<td> second cell </td>\n<td> third cell </td>\n</tr>\n</table>\n");
- dessert(td.convert("| first cell | second cell |\nText line\n| third cell | fourth cell |", "", "") == "<table>\n<tr>\n<td> first cell </td>\n<td> second cell </td>\n</tr>\n</table>\n<p>Text line\n</p>\n<table>\n<tr>\n<td> third cell </td>\n<td> fourth cell </td>\n</tr>\n</table>\n");
- dessert(td.convert("Text adhoc for testing\n| a | b |\n| c | d |\n", "", "") == "<p>Text adhoc for testing\n</p>\n<table>\n<tr>\n<td> a </td>\n<td> b </td>\n</tr>\n<tr>\n<td> c </td>\n<td> d </td>\n</tr>\n</table>\n");
- dessert(td.convert("Text adhoc for testing\n| a | b |\n| c | d |\nText adhoc for testing\n", "", "") == "<p>Text adhoc for testing\n</p>\n<table>\n<tr>\n<td> a </td>\n<td> b </td>\n</tr>\n<tr>\n<td> c </td>\n<td> d </td>\n</tr>\n</table>\n<p>Text adhoc for testing\n</p>\n");
- dessert(td.convert(" {() #This isn't a title}", "", "") == (" <div class=\"\">#This isn't a title</div>\n"));
- dessert(td.convert(" {(class) #This isn't a title}", "", "") == (" <div class=\"class\">#This isn't a title</div>\n"));
- dessert(td.convert(" {(class) \n #This is a title \n }", "", "") == (" <div class=\"class\">\n<h1>This is a title </h1>\n </div>\n"));
- dessert(throws(td.convert(" {(class)#This isn't a title", "", "")));
- cout << "END TABLE" << endl;
- dessert(td.convert("| first cell | second cell |\nText line\n| third cell | fourth cell |\n#Title1", "", "") == "<table>\n<tr>\n<td> first cell </td>\n<td> second cell </td>\n</tr>\n</table>\n<p>Text line\n</p>\n<table>\n<tr>\n<td> third cell </td>\n<td> fourth cell </td>\n</tr>\n</table>\n<h1>Title1</h1>\n");
- dessert(td.convert("| first cell | second cell |\nText line\n| third cell | fourth cell |\n__\n--Item\n,,", "", "") == "<table>\n<tr>\n<td> first cell </td>\n<td> second cell </td>\n</tr>\n</table>\n<p>Text line\n</p>\n<table>\n<tr>\n<td> third cell </td>\n<td> fourth cell </td>\n</tr>\n</table>\n<ul>\n<li>Item\n</ul>\n");
- dessert(td.convert("__\n| first cell | second cell |\nText line\n| third cell | fourth cell |\n--Item\n,,", "", "") == "<ul>\n<table>\n<tr>\n<td> first cell </td>\n<td> second cell </td>\n</tr>\n</table>\nText line\n<table>\n<tr>\n<td> third cell </td>\n<td> fourth cell </td>\n</tr>\n</table>\n<li>Item\n</ul>\n");
- dessert(td.convert("__\n--Item\n| first cell | second cell |\nText line\n| third cell | fourth cell |\n,,", "", "") == "<ul>\n<li>Item\n<table>\n<tr>\n<td> first cell </td>\n<td> second cell </td>\n</tr>\n</table>\nText line\n<table>\n<tr>\n<td> third cell </td>\n<td> fourth cell </td>\n</tr>\n</table>\n</ul>\n");
- dessert(td.convert("| first cell | second cell |\nText line\n| third cell | fourth cell |\n<Test\n", "", "") == "<table>\n<tr>\n<td> first cell </td>\n<td> second cell </td>\n</tr>\n</table>\n<p>Text line\n</p>\n<table>\n<tr>\n<td> third cell </td>\n<td> fourth cell </td>\n</tr>\n</table>\nTest\n");
- dessert(td.convert("| first cell | second cell |\nText line\n| third cell | fourth cell |\n<+Test\n", "", "") == "<table>\n<tr>\n<td> first cell </td>\n<td> second cell </td>\n</tr>\n</table>\n<p>Text line\n</p>\n<table>\n<tr>\n<td> third cell </td>\n<td> fourth cell </td>\n</tr>\n</table>\n<p>Test</p>\n");
- dessert(td.convert("| first cell | second cell |\nText line\n| third cell | fourth cell |\n<+Test with pipe |\n", "", "") == "<table>\n<tr>\n<td> first cell </td>\n<td> second cell </td>\n</tr>\n</table>\n<p>Text line\n</p>\n<table>\n<tr>\n<td> third cell </td>\n<td> fourth cell </td>\n</tr>\n</table>\n<p>Test with pipe |</p>\n");
- cout << "NEW LINE" << endl;
- dessert(td.convert("Lorem Ipsum \n ", "", "") == ("<p>Lorem Ipsum </p>\n \n"));
- dessert(td.convert("First line\nLorem Ipsum \n ", "", "") == ("<p>First line\nLorem Ipsum </p>\n \n"));
- dessert(td.convert("First line \nLorem Ipsum \n ", "", "") == ("<p>First line </p>\n<p>Lorem Ipsum </p>\n \n"));
- dessert(td.convert("Lorem{(class) Ipsum} \n", "", "") == ("Lorem<div class=\"class\">Ipsum</div> \n"));
- dessert(td.convert("Lorem\nIpsum\nDolor\n", "", "") == ("<p>Lorem\nIpsum\nDolor\n</p>\n"));
- dessert(td.convert("{(class) text}\n", "", "") == ("<div class=\"class\">text</div>\n"));
- dessert(td.convert("Lorem\n{(class) text}\nDolor\n", "", "") == ("<p>Lorem\n</p>\n<div class=\"class\">text</div>\n<p>Dolor\n</p>\n"));
- cout << "METATAGS" << endl;
- dessert(td.convert("<! Comment commenting things", "", "") == "");
- dessert(td.convert("Text adhoc for testing\n< metatag without space at end\nText adhoc for testing", "", "") == "<p>Text adhoc for testing\n metatag without space at end\nText adhoc for testing\n</p>\n");
- dessert(td.convert("Text adhoc for testing \n< metatag without space at end\nText adhoc for testing", "", "") == "<p>Text adhoc for testing </p>\n metatag without space at end\n<p>Text adhoc for testing\n</p>\n");
- dessert(td.convert("Text adhoc for testing\n< metatag without space at end\nText adhoc for testing ", "", "") == "<p>Text adhoc for testing\n metatag without space at end\nText adhoc for testing </p>\n");
- dessert(td.convert("Text adhoc for testing\n<+ metatag with space at end\nText adhoc for testing", "", "") == "<p>Text adhoc for testing\n metatag with space at end</p>\n<p>Text adhoc for testing\n</p>\n");
- dessert(td.convert("Text adhoc for testing \n<+ metatag with space at end\nText adhoc for testing", "", "") == "<p>Text adhoc for testing </p>\n<p> metatag with space at end</p>\n<p>Text adhoc for testing\n</p>\n");
- dessert(td.convert("Text adhoc for testing\n<+ metatag with space at end\nText adhoc for testing ", "", "") == "<p>Text adhoc for testing\n metatag with space at end</p>\n<p>Text adhoc for testing </p>\n");
- dessert(td.convert("Text adhoc for testing\n<> embed with space at end\nText adhoc for testing ", "", "") == "<p>Text adhoc for testing\n embed with space at end\nText adhoc for testing </p>\n");
- cout << "MISC." << endl;
- dessert(td.convert("alkasdfasdf \n#This isn't a title\nksadjfañlskdfj", "", "")
- == ("<p>alkasdfasdf </p>\n<h1>This isn't a title</h1>\n<p>ksadjfañlskdfj\n</p>\n"));
- dessert(td.convert("alkasdfasdf\n#This isn't a title\nksadjfañlskdfj", "", "")
- == "<p>alkasdfasdf\n</p>\n<h1>This isn't a title</h1>\n<p>ksadjfañlskdfj\n</p>\n");
- dessert(td.convert("Text adhoc for testing\n{(class) container text } Text adhoc for testing ", "", "") == "<p>Text adhoc for testing\n</p>\n<div class=\"class\">container text </div> Text adhoc for testing \n");
- dessert(td.convert("Text adhoc for testing \n{(class) container text }\nText adhoc for testing ", "", "") == "<p>Text adhoc for testing </p>\n<div class=\"class\">container text </div>\n<p>Text adhoc for testing </p>\n");
- dessert(td.convert("Text adhoc for testing \n{(class) container text}Text adhoc for testing ", "", "") == "<p>Text adhoc for testing </p>\n<div class=\"class\">container text</div>Text adhoc for testing \n");
- dessert(td.convert("Paragraph without space at end\n< hello ", "", "") == "<p>Paragraph without space at end\n hello \n</p>\n");
- dessert(td.convert("Paragraph without space at end\n< hello without space at end\n lsdkjfgsñdlkfjñlk", "", "") == "<p>Paragraph without space at end\n hello without space at end\n lsdkjfgsñdlkfjñlk\n</p>\n");
- dessert(td.convert("Paragraph without space at end\n< hello ", "", "") == "<p>Paragraph without space at end\n hello \n</p>\n");
-
- }
|