diff options
Diffstat (limited to 'meshmc/cmake/UnitTest/TestUtil.h')
| -rw-r--r-- | meshmc/cmake/UnitTest/TestUtil.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/meshmc/cmake/UnitTest/TestUtil.h b/meshmc/cmake/UnitTest/TestUtil.h new file mode 100644 index 0000000000..228905d46b --- /dev/null +++ b/meshmc/cmake/UnitTest/TestUtil.h @@ -0,0 +1,29 @@ +#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); + if (!f.open(QFile::ReadOnly)) + return QByteArray(); + return f.readAll(); + } + static QString readFileUtf8(const QString& fileName) + { + return QString::fromUtf8(readFile(fileName)); + } +}; + +#define GET_TEST_FILE(file) TestsInternal::readFile(QFINDTESTDATA(file)) +#define GET_TEST_FILE_UTF8(file) \ + TestsInternal::readFileUtf8(QFINDTESTDATA(file)) |
