aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tests/fuzzer/testcase.cpp
diff options
context:
space:
mode:
authorrenaud guezennec <renaud@rolisteam.org>2019-07-29 20:35:52 +0000
committerrenaud guezennec <renaud@rolisteam.org>2019-07-29 20:35:52 +0000
commit1a902d383eef1e042d4462cd07b9384fcdf4d118 (patch)
tree766b8ab720fa5da11730d2fc2388f51b9d14de49 /tests/fuzzer/testcase.cpp
parentf5906125576a8323a731c9456ce3dfc53b67ef59 (diff)
parent0d4b68221bda594cc695d216dfa21306ddb69c85 (diff)
downloadOneRoll-1a902d383eef1e042d4462cd07b9384fcdf4d118.tar.gz
OneRoll-1a902d383eef1e042d4462cd07b9384fcdf4d118.zip
Merge branch 'liberation' into 'master'
Add fuzzer on the DiceParser See merge request kde/rolisteam-diceparser!2
Diffstat (limited to 'tests/fuzzer/testcase.cpp')
-rw-r--r--tests/fuzzer/testcase.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/fuzzer/testcase.cpp b/tests/fuzzer/testcase.cpp
new file mode 100644
index 0000000..87d1867
--- /dev/null
+++ b/tests/fuzzer/testcase.cpp
@@ -0,0 +1,37 @@
+#include <QCoreApplication>
+#include <QDebug>
+#include <QFile>
+#include <diceparser.h>
+
+static DiceParser* parser= new DiceParser();
+
+void runCommand(const QString& cmd)
+{
+ qDebug() << "cmd" << cmd;
+ if(parser->parseLine(cmd))
+ {
+ parser->start();
+ }
+}
+
+int main(int argc, char** argv)
+{
+ // qDebug() << "first";
+ QCoreApplication app(argc, argv);
+
+ // qDebug() << "start";
+ QFile file(app.arguments().at(1));
+ // qDebug() << "file" << app.arguments().at(1);
+ if(!file.open(QIODevice::ReadOnly))
+ return 1;
+
+ auto line= file.readLine();
+ while(!line.isEmpty())
+ {
+ // qDebug() << line;
+ runCommand(QString::fromUtf8(line));
+ line= file.readLine();
+ }
+
+ return 0;
+}