diff options
author | Aleks Kissinger <aleks0@gmail.com> | 2018-01-04 16:00:52 +0100 |
---|---|---|
committer | Aleks Kissinger <aleks0@gmail.com> | 2018-01-04 16:00:52 +0100 |
commit | 738ecbd5fad2b46836bfd6a94aeebf165ae2bbca (patch) | |
tree | df04709807cc9ec8481a3ebc7d80ac25e5b2f457 /tikzit/src/test | |
parent | 0421a96749743868554d44585050b1b3d04864d2 (diff) |
relocated source code to the root
Diffstat (limited to 'tikzit/src/test')
-rw-r--r-- | tikzit/src/test/testmain.cpp | 22 | ||||
-rw-r--r-- | tikzit/src/test/testparser.cpp | 163 | ||||
-rw-r--r-- | tikzit/src/test/testparser.h | 18 | ||||
-rw-r--r-- | tikzit/src/test/testtest.cpp | 10 | ||||
-rw-r--r-- | tikzit/src/test/testtest.h | 17 | ||||
-rw-r--r-- | tikzit/src/test/testtikzoutput.cpp | 97 | ||||
-rw-r--r-- | tikzit/src/test/testtikzoutput.h | 17 |
7 files changed, 0 insertions, 344 deletions
diff --git a/tikzit/src/test/testmain.cpp b/tikzit/src/test/testmain.cpp deleted file mode 100644 index 56491ed..0000000 --- a/tikzit/src/test/testmain.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "testtest.h" -#include "testparser.h" -#include "testtikzoutput.h" - -#include <QTest> -#include <QDebug> -#include <iostream> - -int main(int argc, char *argv[]) -{ - TestTest test; - TestParser parser; - TestTikzOutput tikzOutput; - int r = QTest::qExec(&test, argc, argv) | - QTest::qExec(&parser, argc, argv) | - QTest::qExec(&tikzOutput, argc, argv); - - if (r == 0) std::cout << "***************** All tests passed! *****************\n"; - else std::cout << "***************** Some tests failed. *****************\n"; - - return r; -} diff --git a/tikzit/src/test/testparser.cpp b/tikzit/src/test/testparser.cpp deleted file mode 100644 index e220e2e..0000000 --- a/tikzit/src/test/testparser.cpp +++ /dev/null @@ -1,163 +0,0 @@ -#include "testparser.h" -#include "graph.h" -#include "tikzgraphassembler.h" - -#include <QTest> -#include <QVector> - -//void TestParser::initTestCase() -//{ - -//} - -//void TestParser::cleanupTestCase() -//{ - -//} - -void TestParser::parseEmptyGraph() -{ - Graph *g = new Graph(); - TikzGraphAssembler ga(g); - bool res = ga.parse("\\begin{tikzpicture}\n\\end{tikzpicture}"); - QVERIFY(res); - QVERIFY(g->nodes().size() == 0); - QVERIFY(g->edges().size() == 0); - delete g; -} - -void TestParser::parseNodeGraph() -{ - Graph *g = new Graph(); - TikzGraphAssembler ga(g); - bool res = ga.parse( - "\\begin{tikzpicture}\n" - " \\node (node0) at (1.1, -2.2) {};\n" - " \\node (node1) at (3, 4) {test};\n" - "\\end{tikzpicture}"); - QVERIFY(res); - QVERIFY(g->nodes().size() == 2); - QVERIFY(g->edges().size() == 0); - QVERIFY(g->nodes()[0]->name() == "node0"); - QVERIFY(g->nodes()[0]->label() == ""); - QVERIFY(g->nodes()[0]->point() == QPointF(1.1,-2.2)); - QVERIFY(g->nodes()[1]->name() == "node1"); - QVERIFY(g->nodes()[1]->label() == "test"); - QVERIFY(g->nodes()[1]->point() == QPointF(3,4)); - delete g; -} - -void TestParser::parseEdgeGraph() -{ - Graph *g = new Graph(); - TikzGraphAssembler ga(g); - bool res = ga.parse( - "\\begin{tikzpicture}\n" - " \\begin{pgfonlayer}{nodelayer}\n" - " \\node [style=x, {foo++}] (0) at (-1, -1) {};\n" - " \\node [style=y] (1) at (0, 1) {};\n" - " \\node [style=z] (2) at (1, -1) {};\n" - " \\end{pgfonlayer}\n" - " \\begin{pgfonlayer}{edgelayer}\n" - " \\draw [style=a] (1.center) to (2);\n" - " \\draw [style=b, foo] (2) to (0.west);\n" - " \\draw [style=c] (0) to (1);\n" - " \\end{pgfonlayer}\n" - "\\end{tikzpicture}\n"); - QVERIFY(res); - QVERIFY(g->nodes().size() == 3); - QVERIFY(g->edges().size() == 3); - QVERIFY(g->nodes()[0]->data()->atom("foo++")); - QVERIFY(g->edges()[0]->data()->property("style") == "a"); - QVERIFY(!g->edges()[0]->data()->atom("foo")); - QVERIFY(g->edges()[1]->data()->property("style") == "b"); - QVERIFY(g->edges()[1]->data()->atom("foo")); - QVERIFY(g->edges()[2]->data()->property("style") == "c"); - Node *en = g->edges()[0]->edgeNode(); - QVERIFY(en == 0); - delete g; -} - -void TestParser::parseEdgeNode() -{ - Graph *g = new Graph(); - TikzGraphAssembler ga(g); - bool res = ga.parse( - "\\begin{tikzpicture}\n" - " \\begin{pgfonlayer}{nodelayer}\n" - " \\node [style=none] (0) at (-1, 0) {};\n" - " \\node [style=none] (1) at (1, 0) {};\n" - " \\end{pgfonlayer}\n" - " \\begin{pgfonlayer}{edgelayer}\n" - " \\draw [style=diredge] (0.center) to node[foo, bar=baz baz]{test} (1.center);\n" - " \\end{pgfonlayer}\n" - "\\end{tikzpicture}\n"); - QVERIFY(res); - QVERIFY(g->nodes().size() == 2); - QVERIFY(g->edges().size() == 1); - Node *en = g->edges()[0]->edgeNode(); - QVERIFY(en != 0); - QVERIFY(en->label() == "test"); - QVERIFY(en->data()->atom("foo")); - QVERIFY(en->data()->property("bar") == "baz baz"); - delete g; -} - -void TestParser::parseEdgeBends() -{ - Graph *g = new Graph(); - TikzGraphAssembler ga(g); - bool res = ga.parse( - "\\begin{tikzpicture}\n" - " \\begin{pgfonlayer}{nodelayer}\n" - " \\node [style=white] (0) at (-1, 0) {};\n" - " \\node [style=black] (1) at (1, 0) {};\n" - " \\end{pgfonlayer}\n" - " \\begin{pgfonlayer}{edgelayer}\n" - " \\draw [style=diredge,bend left] (0) to (1);\n" - " \\draw [style=diredge,bend right] (0) to (1);\n" - " \\draw [style=diredge,bend left=20] (0) to (1);\n" - " \\draw [style=diredge,bend right=80] (0) to (1);\n" - " \\draw [style=diredge,in=10,out=150,looseness=2] (0) to (1);\n" - " \\end{pgfonlayer}\n" - "\\end{tikzpicture}\n"); - QVERIFY(res); - QVERIFY(g->nodes().size() == 2); - QVERIFY(g->edges().size() == 5); - QVERIFY(g->edges()[0]->bend() == -30); - QVERIFY(g->edges()[1]->bend() == 30); - QVERIFY(g->edges()[2]->bend() == -20); - QVERIFY(g->edges()[3]->bend() == 80); - QVERIFY(g->edges()[4]->inAngle() == 10); - QVERIFY(g->edges()[4]->outAngle() == 150); - QVERIFY(g->edges()[4]->weight() == 2.0f/2.5f); -} - -void TestParser::parseBbox() -{ - Graph *g = new Graph(); - TikzGraphAssembler ga(g); - bool res = ga.parse( - "\\begin{tikzpicture}\n" - " \\path [use as bounding box] (-1.5,-1.5) rectangle (1.5,1.5);\n" - " \\begin{pgfonlayer}{nodelayer}\n" - " \\node [style=white dot] (0) at (-1, -1) {};\n" - " \\node [style=white dot] (1) at (0, 1) {};\n" - " \\node [style=white dot] (2) at (1, -1) {};\n" - " \\end{pgfonlayer}\n" - " \\begin{pgfonlayer}{edgelayer}\n" - " \\draw [style=diredge] (1) to (2);\n" - " \\draw [style=diredge] (2) to (0);\n" - " \\draw [style=diredge] (0) to (1);\n" - " \\end{pgfonlayer}\n" - "\\end{tikzpicture}\n"); - QVERIFY(res); - QVERIFY(g->nodes().size() == 3); - QVERIFY(g->edges().size() == 3); - QVERIFY(g->hasBbox()); - QVERIFY(g->bbox() == QRectF(QPointF(-1.5,-1.5), QPointF(1.5,1.5))); - - delete g; -} - - diff --git a/tikzit/src/test/testparser.h b/tikzit/src/test/testparser.h deleted file mode 100644 index a40a58f..0000000 --- a/tikzit/src/test/testparser.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef TESTPARSER_H -#define TESTPARSER_H - -#include <QObject> - -class TestParser : public QObject -{ - Q_OBJECT -private slots: - void parseEmptyGraph(); - void parseNodeGraph(); - void parseEdgeGraph(); - void parseEdgeNode(); - void parseEdgeBends(); - void parseBbox(); -}; - -#endif // TESTPARSER_H diff --git a/tikzit/src/test/testtest.cpp b/tikzit/src/test/testtest.cpp deleted file mode 100644 index 59173c0..0000000 --- a/tikzit/src/test/testtest.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "testtest.h" - -#include <QObject> -#include <QTest> - -void TestTest::initTestCase() { qDebug("initialising test"); } -void TestTest::myFirstTest() { QVERIFY(1 == 1); } -void TestTest::mySecondTest() { QVERIFY(1 != 2); } -void TestTest::cleanupTestCase() { qDebug("cleaning up test"); } - diff --git a/tikzit/src/test/testtest.h b/tikzit/src/test/testtest.h deleted file mode 100644 index 69a0bc8..0000000 --- a/tikzit/src/test/testtest.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef TESTTEST_H -#define TESTTEST_H - -#include <QObject> -#include <QTest> - -class TestTest: public QObject -{ - Q_OBJECT -private slots: - void initTestCase(); - void myFirstTest(); - void mySecondTest(); - void cleanupTestCase(); -}; - -#endif // TESTTEST_H diff --git a/tikzit/src/test/testtikzoutput.cpp b/tikzit/src/test/testtikzoutput.cpp deleted file mode 100644 index f086786..0000000 --- a/tikzit/src/test/testtikzoutput.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "testtikzoutput.h" -#include "graphelementproperty.h" -#include "graphelementdata.h" -#include "graph.h" -#include "tikzgraphassembler.h" - -#include <QTest> -#include <QRectF> -#include <QPointF> - -void TestTikzOutput::escape() -{ - QVERIFY(GraphElementProperty::tikzEscape("foo") == "foo"); - QVERIFY(GraphElementProperty::tikzEscape("foo'") == "foo'"); - QVERIFY(GraphElementProperty::tikzEscape("foo bar") == "foo bar"); - QVERIFY(GraphElementProperty::tikzEscape("foo.bar") == "foo.bar"); - QVERIFY(GraphElementProperty::tikzEscape("foo-bar") == "foo-bar"); - QVERIFY(GraphElementProperty::tikzEscape("foo >") == "foo >"); - QVERIFY(GraphElementProperty::tikzEscape("foo <") == "foo <"); - QVERIFY(GraphElementProperty::tikzEscape("foo+") == "{foo+}"); - QVERIFY(GraphElementProperty::tikzEscape("foo{bar}") == "{foo{bar}}"); -} - -void TestTikzOutput::data() -{ - GraphElementData d; - QVERIFY(d.tikz() == ""); - d.setAtom("foo"); - QVERIFY(d.tikz() == "[foo]"); - d.setAtom("bar"); - QVERIFY(d.tikz() == "[foo, bar]"); - d.setProperty("foo","bar"); - QVERIFY(d.tikz() == "[foo, bar, foo=bar]"); - d.setAtom("foo+"); - QVERIFY(d.tikz() == "[foo, bar, foo=bar, {foo+}]"); - d.unsetAtom("foo"); - QVERIFY(d.tikz() == "[bar, foo=bar, {foo+}]"); - d.unsetProperty("foo"); - QVERIFY(d.tikz() == "[bar, {foo+}]"); - d.unsetAtom("foo+"); - QVERIFY(d.tikz() == "[bar]"); - 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 deleted file mode 100644 index dff1db1..0000000 --- a/tikzit/src/test/testtikzoutput.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef TESTTIKZOUTPUT_H -#define TESTTIKZOUTPUT_H - -#include <QObject> - -class TestTikzOutput : public QObject -{ - Q_OBJECT -private slots: - void escape(); - void data(); - void graphBbox(); - void graphEmpty(); - void graphFromTikz(); -}; - -#endif // TESTTIKZOUTPUT_H |