summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2018-11-01 15:57:35 -0700
committerLiang Qi <liang.qi@qt.io>2018-11-19 09:09:20 +0000
commit6125fce79936d3ce96e3faac9ad3a9bad3101796 (patch)
tree376ccd5c558525bf25d56c7289e50e800f27bfba /tests
parent7a4f41bad98da9953abcea05a71c2986406c7695 (diff)
tst_QResourceEngine: store the actual byte contents that we expect
Instead of using a QString with only the prefix, let's do a full comparison to make sure there's no junk at the end of the file. Take the opportunity to remove the nonsense of a space at the end of most of these files (I didn't remove from all). Change-Id: I343f2beed55440a7ac0bfffd15632228c1bfe78f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qresourceengine/.gitattributes1
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/aliasdir/aliasdir.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/blahblah.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/currentdir.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/currentdir2.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/otherdir/otherdir.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/subdir/subdir.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/test/test/test1.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/test/test/test2.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/test/testdir.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/test/testdir2.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp59
12 files changed, 41 insertions, 39 deletions
diff --git a/tests/auto/corelib/io/qresourceengine/.gitattributes b/tests/auto/corelib/io/qresourceengine/.gitattributes
index add3716d81..88edd3681a 100644
--- a/tests/auto/corelib/io/qresourceengine/.gitattributes
+++ b/tests/auto/corelib/io/qresourceengine/.gitattributes
@@ -1 +1,2 @@
testqrc/test.qrc -crlf
+*.txt -crlf
diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/aliasdir/aliasdir.txt b/tests/auto/corelib/io/qresourceengine/testqrc/aliasdir/aliasdir.txt
index 21a3dfa0b8..dcf7937f0a 100644
--- a/tests/auto/corelib/io/qresourceengine/testqrc/aliasdir/aliasdir.txt
+++ b/tests/auto/corelib/io/qresourceengine/testqrc/aliasdir/aliasdir.txt
@@ -1 +1 @@
-"This is a korean text file"
+"This is a korean text file"
diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/blahblah.txt b/tests/auto/corelib/io/qresourceengine/testqrc/blahblah.txt
index 436c4d11c3..19f0805d8d 100644
--- a/tests/auto/corelib/io/qresourceengine/testqrc/blahblah.txt
+++ b/tests/auto/corelib/io/qresourceengine/testqrc/blahblah.txt
@@ -1 +1 @@
-qwerty
+qwerty
diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/currentdir.txt b/tests/auto/corelib/io/qresourceengine/testqrc/currentdir.txt
index 38e389979a..65f1f43def 100644
--- a/tests/auto/corelib/io/qresourceengine/testqrc/currentdir.txt
+++ b/tests/auto/corelib/io/qresourceengine/testqrc/currentdir.txt
@@ -1 +1 @@
-"This is the current dir"
+"This is the current dir"
diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/currentdir2.txt b/tests/auto/corelib/io/qresourceengine/testqrc/currentdir2.txt
index 6ac16a3306..7d89108011 100644
--- a/tests/auto/corelib/io/qresourceengine/testqrc/currentdir2.txt
+++ b/tests/auto/corelib/io/qresourceengine/testqrc/currentdir2.txt
@@ -1 +1 @@
-"This is also the current dir"
+"This is also the current dir"
diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/otherdir/otherdir.txt b/tests/auto/corelib/io/qresourceengine/testqrc/otherdir/otherdir.txt
index b0e4a124ee..e1b430f33b 100644
--- a/tests/auto/corelib/io/qresourceengine/testqrc/otherdir/otherdir.txt
+++ b/tests/auto/corelib/io/qresourceengine/testqrc/otherdir/otherdir.txt
@@ -1 +1 @@
-"This is the other dir"
+"This is the other dir"
diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/subdir/subdir.txt b/tests/auto/corelib/io/qresourceengine/testqrc/subdir/subdir.txt
index b6115207a2..4506acf413 100644
--- a/tests/auto/corelib/io/qresourceengine/testqrc/subdir/subdir.txt
+++ b/tests/auto/corelib/io/qresourceengine/testqrc/subdir/subdir.txt
@@ -1 +1 @@
-"This is in the sub directory"
+"This is in the sub directory"
diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test1.txt b/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test1.txt
index adc01d1354..8baef1b4ab 100644
--- a/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test1.txt
+++ b/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test1.txt
@@ -1 +1 @@
-abc
+abc
diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test2.txt b/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test2.txt
index 3f48e3cdc3..24c5735c3e 100644
--- a/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test2.txt
+++ b/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test2.txt
@@ -1 +1 @@
-def
+def
diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir.txt b/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir.txt
index 40ee68dccb..b8cb3a8c01 100644
--- a/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir.txt
+++ b/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir.txt
@@ -1 +1 @@
-"This is in the test directory"
+"This is in the test directory"
diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir2.txt b/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir2.txt
index 051430298a..dccfdc9bcf 100644
--- a/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir2.txt
+++ b/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir2.txt
@@ -1 +1 @@
-"This is another file in this directory"
+"This is another file in this directory"
diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
index ab49dea6d8..2678bb0db3 100644
--- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
+++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -104,7 +105,7 @@ void tst_QResourceEngine::cleanupTestCase()
void tst_QResourceEngine::checkStructure_data()
{
QTest::addColumn<QString>("pathName");
- QTest::addColumn<QString>("contents");
+ QTest::addColumn<QByteArray>("contents");
QTest::addColumn<QStringList>("containedFiles");
QTest::addColumn<QStringList>("containedDirs");
QTest::addColumn<QLocale>("locale");
@@ -134,7 +135,7 @@ void tst_QResourceEngine::checkStructure_data()
QTest::newRow("root dir") << QString(":/")
- << QString()
+ << QByteArray()
<< (QStringList()
#if defined(BUILTIN_TESTDATA)
<< "parentdir.txt"
@@ -146,7 +147,7 @@ void tst_QResourceEngine::checkStructure_data()
<< qlonglong(0);
QTest::newRow("secondary root") << QString(":/secondary_root/")
- << QString()
+ << QByteArray()
<< QStringList()
<< (QStringList() << QLatin1String("runtime_resource"))
<< QLocale::c()
@@ -158,56 +159,56 @@ void tst_QResourceEngine::checkStructure_data()
const QString root = roots.at(i);
QTest::newRow(QString(root + "prefix dir").toLatin1().constData()) << QString(root + "test/abc/123/+++")
- << QString()
+ << QByteArray()
<< (QStringList() << QLatin1String("currentdir.txt") << QLatin1String("currentdir2.txt") << QLatin1String("parentdir.txt"))
<< (QStringList() << QLatin1String("subdir"))
<< QLocale::c()
<< qlonglong(0);
QTest::newRow(QString(root + "parent to prefix").toLatin1().constData()) << QString(root + "test/abc/123")
- << QString()
+ << QByteArray()
<< QStringList()
<< (QStringList() << QLatin1String("+++"))
<< QLocale::c()
<< qlonglong(0);
QTest::newRow(QString(root + "two parents prefix").toLatin1().constData()) << QString(root + "test/abc")
- << QString()
+ << QByteArray()
<< QStringList()
<< QStringList(QLatin1String("123"))
<< QLocale::c()
<< qlonglong(0);
QTest::newRow(QString(root + "test dir ").toLatin1().constData()) << QString(root + "test")
- << QString()
+ << QByteArray()
<< (QStringList() << QLatin1String("testdir.txt"))
<< (QStringList() << QLatin1String("abc") << QLatin1String("test"))
<< QLocale::c()
<< qlonglong(0);
QTest::newRow(QString(root + "prefix no slashes").toLatin1().constData()) << QString(root + "withoutslashes")
- << QString()
+ << QByteArray()
<< QStringList("blahblah.txt")
<< QStringList()
<< QLocale::c()
<< qlonglong(0);
QTest::newRow(QString(root + "other dir").toLatin1().constData()) << QString(root + "otherdir")
- << QString()
+ << QByteArray()
<< QStringList(QLatin1String("otherdir.txt"))
<< QStringList()
<< QLocale::c()
<< qlonglong(0);
QTest::newRow(QString(root + "alias dir").toLatin1().constData()) << QString(root + "aliasdir")
- << QString()
+ << QByteArray()
<< QStringList(QLatin1String("aliasdir.txt"))
<< QStringList()
<< QLocale::c()
<< qlonglong(0);
QTest::newRow(QString(root + "second test dir").toLatin1().constData()) << QString(root + "test/test")
- << QString()
+ << QByteArray()
<< (QStringList() << QLatin1String("test1.txt") << QLatin1String("test2.txt"))
<< QStringList()
<< QLocale::c()
@@ -215,7 +216,7 @@ void tst_QResourceEngine::checkStructure_data()
info = QFileInfo(QFINDTESTDATA("testqrc/test/test/test1.txt"));
QTest::newRow(QString(root + "test1 text").toLatin1().constData()) << QString(root + "test/test/test1.txt")
- << QString("abc")
+ << QByteArray("abc\n")
<< QStringList()
<< QStringList()
<< QLocale::c()
@@ -223,7 +224,7 @@ void tst_QResourceEngine::checkStructure_data()
info = QFileInfo(QFINDTESTDATA("testqrc/blahblah.txt"));
QTest::newRow(QString(root + "text no slashes").toLatin1().constData()) << QString(root + "withoutslashes/blahblah.txt")
- << QString("qwerty")
+ << QByteArray("qwerty\n")
<< QStringList()
<< QStringList()
<< QLocale::c()
@@ -232,7 +233,7 @@ void tst_QResourceEngine::checkStructure_data()
info = QFileInfo(QFINDTESTDATA("testqrc/test/test/test2.txt"));
QTest::newRow(QString(root + "test1 text").toLatin1().constData()) << QString(root + "test/test/test2.txt")
- << QString("def")
+ << QByteArray("def\n")
<< QStringList()
<< QStringList()
<< QLocale::c()
@@ -240,7 +241,7 @@ void tst_QResourceEngine::checkStructure_data()
info = QFileInfo(QFINDTESTDATA("testqrc/currentdir.txt"));
QTest::newRow(QString(root + "currentdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/currentdir.txt")
- << QString("\"This is the current dir\" ")
+ << QByteArray("\"This is the current dir\"\n")
<< QStringList()
<< QStringList()
<< QLocale::c()
@@ -248,7 +249,7 @@ void tst_QResourceEngine::checkStructure_data()
info = QFileInfo(QFINDTESTDATA("testqrc/currentdir2.txt"));
QTest::newRow(QString(root + "currentdir text2").toLatin1().constData()) << QString(root + "test/abc/123/+++/currentdir2.txt")
- << QString("\"This is also the current dir\" ")
+ << QByteArray("\"This is also the current dir\"\n")
<< QStringList()
<< QStringList()
<< QLocale::c()
@@ -256,7 +257,7 @@ void tst_QResourceEngine::checkStructure_data()
info = QFileInfo(QFINDTESTDATA("parentdir.txt"));
QTest::newRow(QString(root + "parentdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/parentdir.txt")
- << QString("abcdefgihklmnopqrstuvwxyz ")
+ << QByteArray("abcdefgihklmnopqrstuvwxyz \n")
<< QStringList()
<< QStringList()
<< QLocale::c()
@@ -264,7 +265,7 @@ void tst_QResourceEngine::checkStructure_data()
info = QFileInfo(QFINDTESTDATA("testqrc/subdir/subdir.txt"));
QTest::newRow(QString(root + "subdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/subdir/subdir.txt")
- << QString("\"This is in the sub directory\" ")
+ << QByteArray("\"This is in the sub directory\"\n")
<< QStringList()
<< QStringList()
<< QLocale::c()
@@ -272,7 +273,7 @@ void tst_QResourceEngine::checkStructure_data()
info = QFileInfo(QFINDTESTDATA("testqrc/test/testdir.txt"));
QTest::newRow(QString(root + "testdir text").toLatin1().constData()) << QString(root + "test/testdir.txt")
- << QString("\"This is in the test directory\" ")
+ << QByteArray("\"This is in the test directory\"\n")
<< QStringList()
<< QStringList()
<< QLocale::c()
@@ -280,7 +281,7 @@ void tst_QResourceEngine::checkStructure_data()
info = QFileInfo(QFINDTESTDATA("testqrc/otherdir/otherdir.txt"));
QTest::newRow(QString(root + "otherdir text").toLatin1().constData()) << QString(root + "otherdir/otherdir.txt")
- << QString("\"This is the other dir\" ")
+ << QByteArray("\"This is the other dir\"\n")
<< QStringList()
<< QStringList()
<< QLocale::c()
@@ -288,7 +289,7 @@ void tst_QResourceEngine::checkStructure_data()
info = QFileInfo(QFINDTESTDATA("testqrc/test/testdir2.txt"));
QTest::newRow(QString(root + "alias text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
- << QString("\"This is another file in this directory\" ")
+ << QByteArray("\"This is another file in this directory\"\n")
<< QStringList()
<< QStringList()
<< QLocale::c()
@@ -296,7 +297,7 @@ void tst_QResourceEngine::checkStructure_data()
info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/aliasdir.txt"));
QTest::newRow(QString(root + "korean text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
- << QString("\"This is a korean text file\" ")
+ << QByteArray("\"This is a korean text file\"\n")
<< QStringList()
<< QStringList()
<< QLocale("ko")
@@ -304,7 +305,7 @@ void tst_QResourceEngine::checkStructure_data()
info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/aliasdir.txt"));
QTest::newRow(QString(root + "korean text 2").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
- << QString("\"This is a korean text file\" ")
+ << QByteArray("\"This is a korean text file\"\n")
<< QStringList()
<< QStringList()
<< QLocale("ko_KR")
@@ -312,7 +313,7 @@ void tst_QResourceEngine::checkStructure_data()
info = QFileInfo(QFINDTESTDATA("testqrc/test/german.txt"));
QTest::newRow(QString(root + "german text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
- << QString("Deutsch")
+ << QByteArray("Deutsch\n")
<< QStringList()
<< QStringList()
<< QLocale("de")
@@ -320,7 +321,7 @@ void tst_QResourceEngine::checkStructure_data()
info = QFileInfo(QFINDTESTDATA("testqrc/test/german.txt"));
QTest::newRow(QString(root + "german text 2").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
- << QString("Deutsch")
+ << QByteArray("Deutsch\n")
<< QStringList()
<< QStringList()
<< QLocale("de_DE")
@@ -330,7 +331,7 @@ void tst_QResourceEngine::checkStructure_data()
file.open(QFile::ReadOnly);
info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/compressme.txt"));
QTest::newRow(QString(root + "compressed text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
- << QString(file.readAll())
+ << file.readAll()
<< QStringList()
<< QStringList()
<< QLocale("de_CH")
@@ -341,7 +342,7 @@ void tst_QResourceEngine::checkStructure_data()
void tst_QResourceEngine::checkStructure()
{
QFETCH(QString, pathName);
- QFETCH(QString, contents);
+ QFETCH(QByteArray, contents);
QFETCH(QStringList, containedFiles);
QFETCH(QStringList, containedDirs);
QFETCH(QLocale, locale);
@@ -401,8 +402,8 @@ void tst_QResourceEngine::checkStructure()
QFile file(pathName);
QVERIFY(file.open(QFile::ReadOnly));
- QByteArray ba = file.readAll();
- QVERIFY(QString(ba).startsWith(contents));
+ // check contents
+ QCOMPARE(file.readAll(), contents);
}
QLocale::setDefault(QLocale::system());
}