void testCompaction();
void testDebugStream();
void testCompactionError();
+private:
+ QString testDataDir;
};
TestQtJson::TestQtJson(QObject *parent) : QObject(parent)
void TestQtJson::initTestCase()
{
+ testDataDir = QFileInfo(QFINDTESTDATA("test.json")).absolutePath();
+ if (testDataDir.isEmpty())
+ testDataDir = QCoreApplication::applicationDirPath();
}
void TestQtJson::cleanupTestCase()
void TestQtJson::fromBinary()
{
- QFile file(QLatin1String(SRCDIR "test.json"));
+ QFile file(testDataDir + "/test.json");
file.open(QFile::ReadOnly);
QByteArray testJson = file.readAll();
QVERIFY(!outdoc.isNull());
QVERIFY(doc == outdoc);
- QFile bfile(QLatin1String(SRCDIR "test.bjson"));
+ QFile bfile(testDataDir + "/test.bjson");
bfile.open(QFile::ReadOnly);
QByteArray binary = bfile.readAll();
void TestQtJson::toAndFromBinary_data()
{
QTest::addColumn<QString>("filename");
- QTest::newRow("test.json") << QString::fromLatin1(SRCDIR "test.json");
- QTest::newRow("test2.json") << QString::fromLatin1(SRCDIR "test2.json");
+ QTest::newRow("test.json") << (testDataDir + "/test.json");
+ QTest::newRow("test2.json") << (testDataDir + "/test2.json");
}
void TestQtJson::toAndFromBinary()
void TestQtJson::testParser()
{
- QFile file(QLatin1String(SRCDIR "test.json"));
+ QFile file(testDataDir + "/test.json");
file.open(QFile::ReadOnly);
QByteArray testJson = file.readAll();
void TestQtJson::validation()
{
// this basically tests that we don't crash on corrupt data
- QFile file(QLatin1String(SRCDIR "test.json"));
+ QFile file(testDataDir + "/test.json");
QVERIFY(file.open(QFile::ReadOnly));
QByteArray testJson = file.readAll();
QVERIFY(!testJson.isEmpty());
}
- QFile file2(QLatin1String(SRCDIR "test3.json"));
+ QFile file2(testDataDir + "/test3.json");
file2.open(QFile::ReadOnly);
testJson = file2.readAll();
QVERIFY(!testJson.isEmpty());