Changeset View
Changeset View
Standalone View
Standalone View
autotests/karchivetest.cpp
Show First 20 Lines • Show All 1153 Lines • ▼ Show 20 Line(s) | 1150 | { | |||
---|---|---|---|---|---|
1154 | KZip zip(fileName); | 1154 | KZip zip(fileName); | ||
1155 | 1155 | | |||
1156 | QVERIFY(zip.open(QIODevice::ReadOnly)); | 1156 | QVERIFY(zip.open(QIODevice::ReadOnly)); | ||
1157 | const KArchiveDirectory *dir = zip.directory(); | 1157 | const KArchiveDirectory *dir = zip.directory(); | ||
1158 | const QStringList listing = recursiveListEntries(dir, QString(), 0); | 1158 | const QStringList listing = recursiveListEntries(dir, QString(), 0); | ||
1159 | QCOMPARE(listing.join(' '), QLatin1String("mode=40744 path=test type=dir mode=744 path=test/os-release type=file size=199")); | 1159 | QCOMPARE(listing.join(' '), QLatin1String("mode=40744 path=test type=dir mode=744 path=test/os-release type=file size=199")); | ||
1160 | } | 1160 | } | ||
1161 | 1161 | | |||
1162 | void KArchiveTest::testZipDuplicateNames() | ||||
1163 | { | ||||
1164 | QString fileName = QFINDTESTDATA("data/out.epub"); | ||||
1165 | QVERIFY(!fileName.isEmpty()); | ||||
1166 | | ||||
1167 | KZip zip(fileName); | ||||
1168 | | ||||
1169 | QVERIFY(zip.open(QIODevice::ReadOnly)); | ||||
dfaure: Maybe do a directory listing too, to check if the duplicate name appears twice? | |||||
1170 | | ||||
1171 | int metaInfCount = 0; | ||||
1172 | for (const QString &entryName : zip.directory()->entries()) { | ||||
This detaches the list, put it in a const local variable. (standard range-for trap with Qt containers) dfaure: This detaches the list, put it in a const local variable.
(standard range-for trap with Qt… | |||||
the performance impact here was negligible so I preferred to keep the code simpler, but changed it now sandsmark: the performance impact here was negligible so I preferred to keep the code simpler, but changed… | |||||
1173 | if (entryName.startsWith("META-INF")) { | ||||
1174 | metaInfCount++; | ||||
1175 | } | ||||
1176 | } | ||||
1177 | | ||||
1178 | QVERIFY2(metaInfCount == 1, "Archive root directory contains duplicates"); | ||||
1179 | } | ||||
1180 | | ||||
1181 | | ||||
1162 | void KArchiveTest::testRcc() | 1182 | void KArchiveTest::testRcc() | ||
1163 | { | 1183 | { | ||
1164 | const QString rccFile = QFINDTESTDATA("runtime_resource.rcc"); // was copied from qtbase/tests/auto/corelib/io/qresourceengine | 1184 | const QString rccFile = QFINDTESTDATA("runtime_resource.rcc"); // was copied from qtbase/tests/auto/corelib/io/qresourceengine | ||
1165 | QVERIFY(!rccFile.isEmpty()); | 1185 | QVERIFY(!rccFile.isEmpty()); | ||
1166 | KRcc rcc(rccFile); | 1186 | KRcc rcc(rccFile); | ||
1167 | QVERIFY(rcc.open(QIODevice::ReadOnly)); | 1187 | QVERIFY(rcc.open(QIODevice::ReadOnly)); | ||
1168 | const KArchiveDirectory *rootDir = rcc.directory(); | 1188 | const KArchiveDirectory *rootDir = rcc.directory(); | ||
1169 | QVERIFY(rootDir != nullptr); | 1189 | QVERIFY(rootDir != nullptr); | ||
▲ Show 20 Lines • Show All 215 Lines • Show Last 20 Lines |
Maybe do a directory listing too, to check if the duplicate name appears twice?