summaryrefslogtreecommitdiffstats
path: root/cmake/UnitTest/TestUtil.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-04-13 01:24:55 +0200
committerPetr Mrázek <peterix@gmail.com>2016-05-01 00:01:39 +0200
commite8ba5dafc63de65ed8a469353b808e391633f0fc (patch)
tree1e7d8c340bd68ae339904dde867875226f10b150 /cmake/UnitTest/TestUtil.h
parented3884fd38c26185522248994c79c9525b8892ad (diff)
downloadMultiMC-e8ba5dafc63de65ed8a469353b808e391633f0fc.tar
MultiMC-e8ba5dafc63de65ed8a469353b808e391633f0fc.tar.gz
MultiMC-e8ba5dafc63de65ed8a469353b808e391633f0fc.tar.lz
MultiMC-e8ba5dafc63de65ed8a469353b808e391633f0fc.tar.xz
MultiMC-e8ba5dafc63de65ed8a469353b808e391633f0fc.zip
NOISSUE remove dead unit tests and reorganize CMake code related to unit tests
Diffstat (limited to 'cmake/UnitTest/TestUtil.h')
-rw-r--r--cmake/UnitTest/TestUtil.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/cmake/UnitTest/TestUtil.h b/cmake/UnitTest/TestUtil.h
new file mode 100644
index 00000000..84f18a2e
--- /dev/null
+++ b/cmake/UnitTest/TestUtil.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include <QFile>
+#include <QCoreApplication>
+#include <QTest>
+#include <QDir>
+
+#define expandstr(s) expandstr2(s)
+#define expandstr2(s) #s
+
+class TestsInternal
+{
+public:
+ static QByteArray readFile(const QString &fileName)
+ {
+ QFile f(fileName);
+ f.open(QFile::ReadOnly);
+ return f.readAll();
+ }
+ static QString readFileUtf8(const QString &fileName)
+ {
+ return QString::fromUtf8(readFile(fileName));
+ }
+};
+
+#define MULTIMC_GET_TEST_FILE(file) TestsInternal::readFile(QFINDTESTDATA(file))
+#define MULTIMC_GET_TEST_FILE_UTF8(file) TestsInternal::readFileUtf8(QFINDTESTDATA(file))
+