diff options
Diffstat (limited to 'tikzit/src/test')
-rw-r--r-- | tikzit/src/test/testmain.cpp | 19 | ||||
-rw-r--r-- | tikzit/src/test/testparser.cpp | 73 | ||||
-rw-r--r-- | tikzit/src/test/testparser.h | 17 | ||||
-rw-r--r-- | tikzit/src/test/testtest.cpp | 19 | ||||
-rw-r--r-- | tikzit/src/test/testtest.h | 17 |
5 files changed, 132 insertions, 13 deletions
diff --git a/tikzit/src/test/testmain.cpp b/tikzit/src/test/testmain.cpp new file mode 100644 index 0000000..613be7a --- /dev/null +++ b/tikzit/src/test/testmain.cpp @@ -0,0 +1,19 @@ +#include "testtest.h" +#include "testparser.h" + +#include <QTest> +#include <QDebug> +#include <iostream> + +int main(int argc, char *argv[]) +{ + TestTest test; + TestParser parser; + int r = QTest::qExec(&test, argc, argv) | + QTest::qExec(&parser, 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 new file mode 100644 index 0000000..e978892 --- /dev/null +++ b/tikzit/src/test/testparser.cpp @@ -0,0 +1,73 @@ +#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=none] (0) at (-1, -1) {};\n" + " \\node [style=none] (1) at (0, 1) {};\n" + " \\node [style=none] (2) at (1, -1) {};\n" + " \\end{pgfonlayer}\n" + " \\begin{pgfonlayer}{edgelayer}\n" + " \\draw [style=diredge] (1.center) to (2.center);\n" + " \\draw [style=diredge] (2.center) to (0.center);\n" + " \\draw [style=diredge] (0.center) to (1.center);\n" + " \\end{pgfonlayer}\n" + "\\end{tikzpicture}\n"); + QVERIFY(res); + QVERIFY(g->nodes().size() == 3); + QVERIFY(g->edges().size() == 3); + delete g; +} + + diff --git a/tikzit/src/test/testparser.h b/tikzit/src/test/testparser.h new file mode 100644 index 0000000..8e2e589 --- /dev/null +++ b/tikzit/src/test/testparser.h @@ -0,0 +1,17 @@ +#ifndef TESTPARSER_H +#define TESTPARSER_H + +#include <QObject> + +class TestParser : public QObject +{ + Q_OBJECT +private slots: + //void initTestCase(); + void parseEmptyGraph(); + void parseNodeGraph(); + void parseEdgeGraph(); + //void cleanupTestCase(); +}; + +#endif // TESTPARSER_H diff --git a/tikzit/src/test/testtest.cpp b/tikzit/src/test/testtest.cpp index c6de586..59173c0 100644 --- a/tikzit/src/test/testtest.cpp +++ b/tikzit/src/test/testtest.cpp @@ -1,17 +1,10 @@ +#include "testtest.h" + #include <QObject> #include <QTest> -class TestTest: public QObject -{ - Q_OBJECT -private slots: - void initTestCase() - { qDebug("initialising test"); } - void myFirstTest() - { QVERIFY(1 == 1); } - void mySecondTest() - { QVERIFY(1 != 2); } - void cleanupTestCase() - { qDebug("cleaning up test"); } -}; +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 new file mode 100644 index 0000000..69a0bc8 --- /dev/null +++ b/tikzit/src/test/testtest.h @@ -0,0 +1,17 @@ +#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 |