diff options
author | Aleks Kissinger <aleks0@gmail.com> | 2017-01-22 17:59:44 +0100 |
---|---|---|
committer | Aleks Kissinger <aleks0@gmail.com> | 2017-01-22 17:59:44 +0100 |
commit | b392859bb192a2e02aec09f2eacf5ecdf44fdfe4 (patch) | |
tree | 41a9bd6aead48dc990286bfdd6fe3dc63930c2a6 /tikzit/src/test/testtikzoutput.cpp | |
parent | bd6c301c136ca7dd8f0bc89a90ad85e0f01be01b (diff) |
tikz output done
Diffstat (limited to 'tikzit/src/test/testtikzoutput.cpp')
-rw-r--r-- | tikzit/src/test/testtikzoutput.cpp | 57 |
1 files changed, 57 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; +} |