From b392859bb192a2e02aec09f2eacf5ecdf44fdfe4 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Sun, 22 Jan 2017 17:59:44 +0100 Subject: tikz output done --- tikzit/src/test/testtikzoutput.cpp | 57 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'tikzit/src/test/testtikzoutput.cpp') 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 +#include +#include 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; +} -- cgit v1.2.3