diff options
Diffstat (limited to 'tikzit/src/test')
-rw-r--r-- | tikzit/src/test/testtikzoutput.cpp | 57 | ||||
-rw-r--r-- | tikzit/src/test/testtikzoutput.h | 3 |
2 files changed, 60 insertions, 0 deletions
diff --git a/tikzit/src/test/testtikzoutput.cpp b/tikzit/src/test/testtikzoutput.cpp index 8b14bd3..f086786 100644 --- a/tikzit/src/test/testtikzoutput.cpp +++ b/tikzit/src/test/testtikzoutput.cpp @@ -1,8 +1,12 @@ #include "testtikzoutput.h" #include "graphelementproperty.h" #include "graphelementdata.h" +#include "graph.h" +#include "tikzgraphassembler.h" #include <QTest> +#include <QRectF> +#include <QPointF> void TestTikzOutput::escape() { @@ -38,3 +42,56 @@ void TestTikzOutput::data() d.unsetAtom("bar"); QVERIFY(d.tikz() == ""); } + +void TestTikzOutput::graphEmpty() +{ + Graph *g = new Graph(); + + QString tikz = + "\\begin{tikzpicture}\n" + "\\end{tikzpicture}\n"; + QVERIFY(g->tikz() == tikz); + + delete g; +} + +void TestTikzOutput::graphFromTikz() +{ + Graph *g = new Graph(); + TikzGraphAssembler ga(g); + + QString tikz = + "\\begin{tikzpicture}\n" + "\t\\path [use as bounding box] (-1.5,-1.5) rectangle (1.5,1.5);\n" + "\t\\begin{pgfonlayer}{nodelayer}\n" + "\t\t\\node [style=white dot] (0) at (-1, -1) {};\n" + "\t\t\\node [style=white dot] (1) at (0, 1) {};\n" + "\t\t\\node [style=white dot] (2) at (1, -1) {};\n" + "\t\\end{pgfonlayer}\n" + "\t\\begin{pgfonlayer}{edgelayer}\n" + "\t\t\\draw [style=diredge] (1) to (2);\n" + "\t\t\\draw [style=diredge] (2.center) to (0);\n" + "\t\t\\draw [style=diredge] (0) to ();\n" + "\t\\end{pgfonlayer}\n" + "\\end{tikzpicture}\n"; + bool res = ga.parse(tikz); + QVERIFY2(res, "parsed successfully"); + QVERIFY2(g->tikz() == tikz, "produced matching tikz"); + + delete g; +} + +void TestTikzOutput::graphBbox() +{ + Graph *g = new Graph(); + g->setBbox(QRectF(QPointF(-0.75, -0.5), QPointF(0.25, 1))); + + QString tikz = + "\\begin{tikzpicture}\n" + "\t\\path [use as bounding box] (-0.75,-0.5) rectangle (0.25,1);\n" + "\\end{tikzpicture}\n"; + QVERIFY(g->tikz() == tikz); + + + delete g; +} diff --git a/tikzit/src/test/testtikzoutput.h b/tikzit/src/test/testtikzoutput.h index 24c594e..dff1db1 100644 --- a/tikzit/src/test/testtikzoutput.h +++ b/tikzit/src/test/testtikzoutput.h @@ -9,6 +9,9 @@ class TestTikzOutput : public QObject private slots: void escape(); void data(); + void graphBbox(); + void graphEmpty(); + void graphFromTikz(); }; #endif // TESTTIKZOUTPUT_H |