123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- #include "../../tedi2lang/dessert.hpp"
- #include "../../tedi2lang/tedi2lang.h"
- #include "../tedi2tex.h"
- #include "../../tedi2lang/exception.h"
- #include <string>
- #include <cstring>
- #include <iostream>
- int main(){
-
- tedi2tex td;
- //Empty string
- cout << "EMPTY STRINGS" << endl;
- dessert((td.convert("", "", "")) == (""));
- dessert(td.convert(" ", "", "") == (" \n\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", "", "") == ("paragraph\n\\section{This isn't a title}\n"));
- dessert(td.convert("#This isn't a title", "", "") == ("\\section{This isn't a title}\n"));
- dessert(td.convert(" #This isn't a title", "", "") == ("\\section{This isn't a title}\n"));
- dessert(td.convert("\t##This isn't a title", "", "") == ("\\subsection{This isn't a title}\n"));
- dessert(td.convert("##This isn't a title", "", "") == ("\\subsection{This isn't a title}\n"));
- dessert(td.convert("###This isn't a title", "", "") == ("\\subsubsection{This isn't a title}\n"));
- dessert(td.convert("####This isn't a title", "", "") == ("\\subsubsection{This isn't a title}\n"));
- dessert(td.convert("#####This isn't a title", "", "") == "\\subsubsection{This isn't a title}\n" );
- dessert(td.convert("#####This isn't a title", "", "") == "\\subsubsection{This isn't a title}\n" );
- cout << "LIST" << endl;
- dessert(td.convert("__", "", "") == ("\\begin{itemize}\n"));
- dessert(td.convert("--Text", "", "") == ("--Text\n"));
- dessert(td.convert(",,", "", "") == (",,\n"));
- dessert(td.convert("__\n--Text\n,,", "", "") == ("\\begin{itemize}\n\\item Text\n\\end{itemize}\n"));
- cout << "QUOTE" << endl;
- dessert(td.convert("\"Quoted text\"", "", "") == ("Quoted text\n"));
- dessert(throws(td.convert("\"Bad quoting", "", "")));
- cout << "LINKS" << endl;
- dessert(td.convert("[Test with a open square bracket", "", "") == ("[Test with a open square bracket\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) ]", "", "") == "\\href{Test with closing square bracket}{}\n");
- dessert(td.convert("[() ]", "", "") == "\\href{}{}\n");
- dessert(td.convert("[( ) ]", "", "") == "\\href{ }{}\n");
- dessert(throws(td.convert("[(test\\) test with escaped char\\) ]", "", "")));
- dessert(td.convert("[(test\\) test with escaped char) ]", "", "") == "\\href{test) test with escaped char}{}\n");
- dessert(td.convert("[(test\\) test with escaped char) \\]sasdfasd]", "", "") == "\\href{test) test with escaped char}{]sasdfasd}\n");
- dessert(td.convert("[(test\\( test with escaped char) \\]sasdfasd]", "", "") == "\\href{test( test with escaped char}{]sasdfasd}\n");
- dessert(td.convert("\\[(Test with closing square bracket) text", "", "") == "[(Test with closing square bracket) text\n");
- dessert(td.convert("\\[( [(Test with closing square bracket) text]", "", "") == "[( \\href{Test with closing square bracket}{text}\n");
- cout << "IMAGES" << endl;
- dessert(td.convert("(Test with an open parenthesis", "", "") == ("(Test with an open parenthesis\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] )", "", "") == "\\begin{figure}[h!]\n\\centering\n\\includegraphics[width=1\\textwidth]{}\n\\caption{Test with closing square bracket}\n\\end{figure}\n");
- dessert(td.convert("([] )", "", "") == "\\begin{figure}[h!]\n\\centering\n\\includegraphics[width=1\\textwidth]{}\n\\caption{}\n\\end{figure}\n");
- dessert(td.convert("([ ] )", "", "") == "\\begin{figure}[h!]\n\\centering\n\\includegraphics[width=1\\textwidth]{}\n\\caption{ }\n\\end{figure}\n");
- dessert(throws(td.convert("([test\\] test with escaped char\\] )", "", "")));
- dessert(td.convert("([test\\] test with escaped char] )", "", "") == "\\begin{figure}[h!]\n\\centering\n\\includegraphics[width=1\\textwidth]{}\n\\caption{test] test with escaped char}\n\\end{figure}\n");
- dessert(td.convert("([test\\] test with escaped char] \\)sasdfasd)", "", "") == "\\begin{figure}[h!]\n\\centering\n\\includegraphics[width=1\\textwidth]{)sasdfasd}\n\\caption{test] test with escaped char}\n\\end{figure}\n");
- dessert(td.convert("\\([Test with closing square bracket) text", "", "") == "([Test with closing square bracket) text\n");
- dessert(td.convert("\\([ ([Test with closing square bracket] text)", "", "") == "([ \\begin{figure}[h!]\n\\centering\n\\includegraphics[width=1\\textwidth]{text}\n\\caption{Test with closing square bracket}\n\\end{figure}\n");
- cout << "BLOCKS" << endl;
- dessert(td.convert("{Test with an open parenthesis", "", "") == ("{Test with an open parenthesis\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) }", "", "") == "\n");
- dessert(td.convert("{() }", "", "") == "\n");
- dessert(td.convert("{( ) }", "", "") == "\n");
- dessert(throws(td.convert("{(test\\) test with escaped char\\) }", "", "")));
- dessert(td.convert("{(test\\) test with escaped char) }", "", "") == "\n");
- dessert(td.convert("{(test\\) test with escaped char) \\}sasdfasd}", "", "") == "}sasdfasd\n");
- dessert(td.convert("\\{(Test with closing square bracket) text", "", "") == "{(Test with closing square bracket) text\n");
- dessert(td.convert("\\{( {(Test with closing square bracket) text}", "", "") == "{( text\n");
- cout << "MULTIPLES UNQUOTED TAGS" << endl;
- dessert(td.convert("[Test with a open square bracket ( also parenthesis and { brackets", "", "") == ("[Test with a open square bracket ( also parenthesis and { brackets\n"));
- dessert(td.convert("[(url) Test with a link ([alternative text] image url)] and {(class) brackets}", "", "") == ("\\href{url}{Test with a link \\begin{figure}[h!]\n\\centering\n\\includegraphics[width=1\\textwidth]{image url}\n\\caption{alternative text}\n\\end{figure}} and brackets\n"));
- dessert(td.convert("{(class) [(url) Test with a link ([alternative text] image url)] and brackets}", "", "") == ("\\href{url}{Test with a link \\begin{figure}[h!]\n\\centering\n\\includegraphics[width=1\\textwidth]{image url}\n\\caption{alternative text}\n\\end{figure}} and brackets\n"));
- cout << "TABLE" << endl;
- dessert(td.convert("| first cell | second cell |", "", "") == "\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n first cell & second cell \\tabularnewline\n\\hline\n\\end{longtable}\n\n");
- dessert(td.convert("| first cell ", "", "") == "| first cell \n\n");
- dessert(throws(td.convert("| first cell | second cell ", "", "")));
- dessert(td.convert("| first cell | second cell |\n| third cell | fourth cell |", "", "") == "\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n first cell & second cell \\tabularnewline\n\\hline\n third cell & fourth cell \\tabularnewline\n\\hline\n\\end{longtable}\n\n");
- dessert(td.convert("| first cell |\n| second cell | third cell |", "", "") == "\\begin{longtable}{|p{0.900000\\linewidth}|}\n\\hline\n first cell \\tabularnewline\n\\hline\n second cell & third cell \\tabularnewline\n\\hline\n\\end{longtable}\n\n");
- dessert(td.convert("| first cell | second cell |\nText line\n| third cell | fourth cell |", "", "") == "\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n first cell & second cell \\tabularnewline\n\\hline\n\\end{longtable}\n\nText line\n\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n third cell & fourth cell \\tabularnewline\n\\hline\n\\end{longtable}\n\n");
- dessert(td.convert("Text adhoc for testing\n| a | b |\n| c | d |\n", "", "") == "Text adhoc for testing\n\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n a & b \\tabularnewline\n\\hline\n c & d \\tabularnewline\n\\hline\n\\end{longtable}\n\n");
- dessert(td.convert("Text adhoc for testing\n| a | b |\n| c | d |\nText adhoc for testing\n", "", "") == "Text adhoc for testing\n\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n a & b \\tabularnewline\n\\hline\n c & d \\tabularnewline\n\\hline\n\\end{longtable}\n\nText adhoc for testing\n");
- dessert(td.convert(" {() #This isn't a title}", "", "") == (" #This isn't a title\n"));
- dessert(td.convert(" {(class) #This isn't a title}", "", "") == (" #This isn't a title\n"));
- dessert(td.convert(" {(class) \n #This is a title \n }", "", "") == (" \n\n\\section{This is a title }\n \n\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", "", "") == "\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n first cell & second cell \\tabularnewline\n\\hline\n\\end{longtable}\n\nText line\n\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n third cell & fourth cell \\tabularnewline\n\\hline\n\\end{longtable}\n\n\\section{Title1}\n");
- dessert(td.convert("| first cell | second cell |\nText line\n| third cell | fourth cell |\n__\n--Item\n,,", "", "") == "\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n first cell & second cell \\tabularnewline\n\\hline\n\\end{longtable}\n\nText line\n\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n third cell & fourth cell \\tabularnewline\n\\hline\n\\end{longtable}\n\n\\begin{itemize}\n\\item Item\n\\end{itemize}\n");
- dessert(td.convert("__\n| first cell | second cell |\nText line\n| third cell | fourth cell |\n--Item\n,,", "", "") == "\\begin{itemize}\n\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n first cell & second cell \\tabularnewline\n\\hline\n\\end{longtable}\n\nText line\n\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n third cell & fourth cell \\tabularnewline\n\\hline\n\\end{longtable}\n\n\\item Item\n\\end{itemize}\n");
- dessert(td.convert("__\n--Item\n| first cell | second cell |\nText line\n| third cell | fourth cell |\n,,", "", "") == "\\begin{itemize}\n\\item Item\n\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n first cell & second cell \\tabularnewline\n\\hline\n\\end{longtable}\n\nText line\n\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n third cell & fourth cell \\tabularnewline\n\\hline\n\\end{longtable}\n\n\\end{itemize}\n");
- dessert(td.convert("| first cell | second cell |\nText line\n| third cell | fourth cell |\n<Test\n", "", "") == "\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n first cell & second cell \\tabularnewline\n\\hline\n\\end{longtable}\n\nText line\n\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n third cell & fourth cell \\tabularnewline\n\\hline\n\\end{longtable}\n\n\\verb!Test!\n");
- dessert(td.convert("| first cell | second cell |\nText line\n| third cell | fourth cell |\n<+Test\n", "", "") == "\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n first cell & second cell \\tabularnewline\n\\hline\n\\end{longtable}\n\nText line\n\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n third cell & fourth cell \\tabularnewline\n\\hline\n\\end{longtable}\n\n\\begin{verbatim}\nTest\n\\end{verbatim}\n\n");
- dessert(td.convert("| first cell | second cell |\nText line\n| third cell | fourth cell |\n<+Test with pipe |\n", "", "") == "\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n first cell & second cell \\tabularnewline\n\\hline\n\\end{longtable}\n\nText line\n\\begin{longtable}{|p{0.450000\\linewidth}|p{0.450000\\linewidth}|}\n\\hline\n third cell & fourth cell \\tabularnewline\n\\hline\n\\end{longtable}\n\n\\begin{verbatim}\nTest with pipe |\n\\end{verbatim}\n\n");
- cout << "NEW LINE" << endl;
- dessert(td.convert("Lorem Ipsum \n ", "", "") == ("Lorem Ipsum \n\n \n\n"));
- dessert(td.convert("First line\nLorem Ipsum \n ", "", "") == ("First line\nLorem Ipsum \n\n \n\n"));
- dessert(td.convert("First line \nLorem Ipsum \n ", "", "") == ("First line \n\nLorem Ipsum \n\n \n\n"));
- dessert(td.convert("Lorem{(class) Ipsum} \n", "", "") == ("LoremIpsum \n\n"));
- dessert(td.convert("Lorem\nIpsum\nDolor\n", "", "") == ("Lorem\nIpsum\nDolor\n"));
- dessert(td.convert("{(class) text}\n", "", "") == ("text\n"));
- dessert(td.convert("Lorem\n{(class) text}\nDolor\n", "", "") == ("Lorem\ntext\nDolor\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", "", "") == "Text adhoc for testing\n\\verb! metatag without space at end!\nText adhoc for testing\n");
- dessert(td.convert("Text adhoc for testing \n< metatag without space at end\nText adhoc for testing", "", "") == "Text adhoc for testing \n\n\\verb! metatag without space at end!\nText adhoc for testing\n");
- dessert(td.convert("Text adhoc for testing\n< metatag without space at end\nText adhoc for testing ", "", "") == "Text adhoc for testing\n\\verb! metatag without space at end!\nText adhoc for testing \n\n");
- dessert(td.convert("Text adhoc for testing\n<+ metatag with space at end\nText adhoc for testing", "", "") == "Text adhoc for testing\n\\begin{verbatim}\n metatag with space at end\n\\end{verbatim}\n\nText adhoc for testing\n");
- dessert(td.convert("Text adhoc for testing \n<+ metatag with space at end\nText adhoc for testing", "", "") == "Text adhoc for testing \n\n\\begin{verbatim}\n metatag with space at end\n\\end{verbatim}\n\nText adhoc for testing\n");
- dessert(td.convert("Text adhoc for testing\n<+ metatag with space at end\nText adhoc for testing ", "", "") == "Text adhoc for testing\n\\begin{verbatim}\n metatag with space at end\n\\end{verbatim}\n\nText adhoc for testing \n\n");
- dessert(td.convert("Text adhoc for testing\n<> embed with space at end\nText adhoc for testing ", "", "") == "Text adhoc for testing\n embed with space at end\nText adhoc for testing \n\n");
- cout << "MISC." << endl;
- dessert(td.convert("alkasdfasdf \n#This isn't a title\nksadjfañlskdfj", "", "")
- == ("alkasdfasdf \n\n\\section{This isn't a title}\nksadjfañlskdfj\n"));
- dessert(td.convert("alkasdfasdf\n#This isn't a title\nksadjfañlskdfj", "", "")
- == "alkasdfasdf\n\\section{This isn't a title}\nksadjfañlskdfj\n");
- dessert(td.convert("Text adhoc for testing\n{(class) container text } Text adhoc for testing ", "", "") == "Text adhoc for testing\ncontainer text Text adhoc for testing \n\n");
- dessert(td.convert("Text adhoc for testing \n{(class) container text }\nText adhoc for testing ", "", "") == "Text adhoc for testing \n\ncontainer text \n\nText adhoc for testing \n\n");
- dessert(td.convert("Text adhoc for testing \n{(class) container text}Text adhoc for testing ", "", "") == "Text adhoc for testing \n\ncontainer textText adhoc for testing \n\n");
- dessert(td.convert("Paragraph without space at end\n< hello ", "", "") == "Paragraph without space at end\n\\verb! hello !\n");
- dessert(td.convert("Paragraph without space at end\n< hello without space at end\n lsdkjfgsñdlkfjñlk", "", "") == "Paragraph without space at end\n\\verb! hello without space at end!\n lsdkjfgsñdlkfjñlk\n");
- dessert(td.convert("Paragraph without space at end\n< hello ", "", "") == "Paragraph without space at end\n\\verb! hello !\n");
- cout << "TEST FOR THIS MODULE ONLY" << endl;
- dessert(td.convert("< hello! ", "", "") == "\\verb{ hello! }\n");
- dessert(td.convert("< hello¡ ", "", "") == "\\verb{ hello¡ }\n");
- dessert(td.convert("< hello} ", "", "") == "\\verb! hello} !\n");
- dessert(td.convert("< hello{ ", "", "") == "\\verb! hello{ !\n");
- dessert(td.convert("< hello!{ ", "", "") == "\\begin{verbatim}\n hello!{ \n\\end{verbatim}\n\n");
-
- }
|