diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-03-03 01:40:12 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-03-03 01:40:12 +0100 |
commit | 94d46848095bc75627873708b1d0d5b2632b85db (patch) | |
tree | aaff777681ea6b6fe8107460a011511984b948b5 /tests/tst_MojangVersionFormat.cpp | |
parent | b54839b8976b5c1455c838828f2bc92cdeb178eb (diff) | |
download | MultiMC-94d46848095bc75627873708b1d0d5b2632b85db.tar MultiMC-94d46848095bc75627873708b1d0d5b2632b85db.tar.gz MultiMC-94d46848095bc75627873708b1d0d5b2632b85db.tar.lz MultiMC-94d46848095bc75627873708b1d0d5b2632b85db.tar.xz MultiMC-94d46848095bc75627873708b1d0d5b2632b85db.zip |
NOISSUE add basic unit tests for MojangVersionFormat reading/writing
will have to make them pass now
Diffstat (limited to 'tests/tst_MojangVersionFormat.cpp')
-rw-r--r-- | tests/tst_MojangVersionFormat.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/tst_MojangVersionFormat.cpp b/tests/tst_MojangVersionFormat.cpp new file mode 100644 index 00000000..760f65b1 --- /dev/null +++ b/tests/tst_MojangVersionFormat.cpp @@ -0,0 +1,54 @@ +#include <QTest> +#include <QDebug> +#include "TestUtil.h" + +#include "minecraft/MojangVersionFormat.h" + +class MojangVersionFormatTest : public QObject +{ + Q_OBJECT + + static QJsonDocument readJson(const char *file) + { + auto path = QFINDTESTDATA(file); + QFile jsonFile(path); + jsonFile.open(QIODevice::ReadOnly); + auto data = jsonFile.readAll(); + jsonFile.close(); + return QJsonDocument::fromJson(data); + } + static void writeJson(const char *file, QJsonDocument doc) + { + QFile jsonFile(file); + jsonFile.open(QIODevice::WriteOnly | QIODevice::Text); + auto data = doc.toJson(QJsonDocument::Indented); + jsonFile.write(data); + jsonFile.close(); + } + +private +slots: + void test_Through_Simple() + { + + QJsonDocument doc = readJson("tests/data/1.9-simple.json"); + auto vfile = MojangVersionFormat::versionFileFromJson(doc, "1.9-simple.json"); + auto doc2 = MojangVersionFormat::profilePatchToJson(vfile); + writeJson("beast.json", doc2); + QCOMPARE(doc, doc2); + } + void test_Through() + { + + QJsonDocument doc = readJson("tests/data/1.9.json"); + auto vfile = MojangVersionFormat::versionFileFromJson(doc, "1.9.json"); + auto doc2 = MojangVersionFormat::profilePatchToJson(vfile); + QCOMPARE(doc, doc2); + } + +}; + +QTEST_GUILESS_MAIN(MojangVersionFormatTest) + +#include "tst_MojangVersionFormat.moc" + |