summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRagnar Thomsen <rthomsen6@gmail.com>2016-10-17 18:22:43 (GMT)
committerRagnar Thomsen <rthomsen6@gmail.com>2016-10-17 18:22:43 (GMT)
commit34a46359d27d472c81a08de712bd1fddd8cfed9a (patch)
treef7fcd18b9b409b14d2d8c27630e99dbb774e6c4a
parentef1753b4b3b0123127c757c5de034f8c45232402 (diff)
Check numberOfEntries in Add-, Copy- and MoveTest
Verify that ReadOnlyArchiveInterface::m_numberOfEntries is updated properly in these tests.
-rw-r--r--autotests/kerfuffle/addtest.cpp24
-rw-r--r--autotests/kerfuffle/copytest.cpp39
-rw-r--r--autotests/kerfuffle/data/test.tar.bz2bin331 -> 20480 bytes
-rw-r--r--autotests/kerfuffle/movetest.cpp33
4 files changed, 67 insertions, 29 deletions
diff --git a/autotests/kerfuffle/addtest.cpp b/autotests/kerfuffle/addtest.cpp
index 094ae99..312a36f 100644
--- a/autotests/kerfuffle/addtest.cpp
+++ b/autotests/kerfuffle/addtest.cpp
@@ -32,7 +32,7 @@ class AddTest : public QObject
Q_OBJECT
private:
-void addAllFormatsRows(const QString &testName, const QString &archiveName, const QVector<Archive::Entry*> &entries, Archive::Entry *destination) {
+void addAllFormatsRows(const QString &testName, const QString &archiveName, const QVector<Archive::Entry*> &entries, Archive::Entry *destination, uint numberOfEntries) {
QStringList formats = QStringList()
<< QStringLiteral("7z")
<< QStringLiteral("rar")
@@ -44,7 +44,8 @@ void addAllFormatsRows(const QString &testName, const QString &archiveName, cons
QTest::newRow(testNameWithFormat.toUtf8())
<< archiveName + QLatin1Char('.') + format
<< entries
- << destination;
+ << destination
+ << numberOfEntries;
}
}
@@ -60,6 +61,7 @@ void AddTest::testAdding_data()
QTest::addColumn<QString>("archiveName");
QTest::addColumn<QVector<Archive::Entry*>>("files");
QTest::addColumn<Archive::Entry*>("destination");
+ QTest::addColumn<uint>("numberOfEntries");
addAllFormatsRows(QStringLiteral("without destination"),
QStringLiteral("test"),
@@ -67,7 +69,8 @@ void AddTest::testAdding_data()
new Archive::Entry(this, QStringLiteral("textfile1.txt")),
new Archive::Entry(this, QStringLiteral("textfile2.txt")),
},
- new Archive::Entry(this));
+ new Archive::Entry(this),
+ 15);
addAllFormatsRows(QStringLiteral("with destination, files"),
QStringLiteral("test"),
@@ -75,28 +78,32 @@ void AddTest::testAdding_data()
new Archive::Entry(this, QStringLiteral("textfile1.txt")),
new Archive::Entry(this, QStringLiteral("textfile2.txt")),
},
- new Archive::Entry(this, QStringLiteral("empty_dir/")));
+ new Archive::Entry(this, QStringLiteral("empty_dir/")),
+ 15);
addAllFormatsRows(QStringLiteral("with destination, directory"),
QStringLiteral("test"),
QVector<Archive::Entry*> {
new Archive::Entry(this, QStringLiteral("testdir/")),
},
- new Archive::Entry(this, QStringLiteral("empty_dir/")));
+ new Archive::Entry(this, QStringLiteral("empty_dir/")),
+ 16);
addAllFormatsRows(QStringLiteral("without destination, directory 2"),
QStringLiteral("test"),
QVector<Archive::Entry*> {
new Archive::Entry(this, QStringLiteral("testdir2/")),
},
- new Archive::Entry(this));
+ new Archive::Entry(this),
+ 17);
addAllFormatsRows(QStringLiteral("with destination, directory 2"),
QStringLiteral("test"),
QVector<Archive::Entry*> {
new Archive::Entry(this, QStringLiteral("testdir2/")),
},
- new Archive::Entry(this, QStringLiteral("empty_dir/")));
+ new Archive::Entry(this, QStringLiteral("empty_dir/")),
+ 17);
}
void AddTest::testAdding()
@@ -132,6 +139,9 @@ void AddTest::testAdding()
QVector<Archive::Entry*> resultedEntries = TestHelper::getEntryList(archive);
TestHelper::verifyAddedEntriesWithDestination(files, destination, oldEntries, resultedEntries);
+ QFETCH(uint, numberOfEntries);
+ QCOMPARE(archive->numberOfEntries(), numberOfEntries);
+
loadJob->deleteLater();
archive->deleteLater();
}
diff --git a/autotests/kerfuffle/copytest.cpp b/autotests/kerfuffle/copytest.cpp
index 7f926e8..d538d39 100644
--- a/autotests/kerfuffle/copytest.cpp
+++ b/autotests/kerfuffle/copytest.cpp
@@ -32,7 +32,7 @@ class CopyTest : public QObject
Q_OBJECT
private:
- void addAllFormatsRows(const QString &testName, const QString &archiveName, const QVector<Archive::Entry*> &entries, Archive::Entry *destination) {
+ void addAllFormatsRows(const QString &testName, const QString &archiveName, const QVector<Archive::Entry*> &entries, Archive::Entry *destination, uint numberOfEntries) {
QStringList formats = QStringList()
<< QStringLiteral("7z")
<< QStringLiteral("rar")
@@ -44,7 +44,8 @@ private:
QTest::newRow(testNameWithFormat.toUtf8())
<< archiveName + QLatin1Char('.') + format
<< entries
- << destination;
+ << destination
+ << numberOfEntries;
}
}
@@ -60,13 +61,15 @@ void CopyTest::testCopying_data()
QTest::addColumn<QString>("archiveName");
QTest::addColumn<QVector<Archive::Entry*>>("files");
QTest::addColumn<Archive::Entry*>("destination");
+ QTest::addColumn<uint>("numberOfEntries");
addAllFormatsRows(QStringLiteral("copy a single file"),
QStringLiteral("test"),
QVector<Archive::Entry*> {
new Archive::Entry(this, QStringLiteral("a.txt")),
},
- new Archive::Entry(this, QStringLiteral("empty_dir/")));
+ new Archive::Entry(this, QStringLiteral("empty_dir/")),
+ 14);
addAllFormatsRows(QStringLiteral("copy several files"),
QStringLiteral("test"),
@@ -74,7 +77,8 @@ void CopyTest::testCopying_data()
new Archive::Entry(this, QStringLiteral("a.txt")),
new Archive::Entry(this, QStringLiteral("b.txt")),
},
- new Archive::Entry(this, QStringLiteral("empty_dir/")));
+ new Archive::Entry(this, QStringLiteral("empty_dir/")),
+ 15);
addAllFormatsRows(QStringLiteral("copy a root directory"),
QStringLiteral("test"),
@@ -86,7 +90,8 @@ void CopyTest::testCopying_data()
new Archive::Entry(this, QStringLiteral("dir1/a.txt")),
new Archive::Entry(this, QStringLiteral("dir1/b.txt")),
},
- new Archive::Entry(this, QStringLiteral("empty_dir/")));
+ new Archive::Entry(this, QStringLiteral("empty_dir/")),
+ 19);
addAllFormatsRows(QStringLiteral("copy a root directory 2"),
QStringLiteral("test"),
@@ -96,7 +101,8 @@ void CopyTest::testCopying_data()
new Archive::Entry(this, QStringLiteral("dir2/dir/a.txt")),
new Archive::Entry(this, QStringLiteral("dir2/dir/b.txt")),
},
- new Archive::Entry(this, QStringLiteral("empty_dir/")));
+ new Archive::Entry(this, QStringLiteral("empty_dir/")),
+ 17);
addAllFormatsRows(QStringLiteral("copy a root directory 3"),
QStringLiteral("test"),
@@ -106,7 +112,8 @@ void CopyTest::testCopying_data()
new Archive::Entry(this, QStringLiteral("dir2/dir/a.txt")),
new Archive::Entry(this, QStringLiteral("dir2/dir/b.txt")),
},
- new Archive::Entry(this, QStringLiteral("dir1/")));
+ new Archive::Entry(this, QStringLiteral("dir1/")),
+ 17);
addAllFormatsRows(QStringLiteral("copy a directory"),
QStringLiteral("test"),
@@ -115,7 +122,8 @@ void CopyTest::testCopying_data()
new Archive::Entry(this, QStringLiteral("dir1/dir/a.txt")),
new Archive::Entry(this, QStringLiteral("dir1/dir/b.txt")),
},
- new Archive::Entry(this, QStringLiteral("empty_dir/")));
+ new Archive::Entry(this, QStringLiteral("empty_dir/")),
+ 16);
addAllFormatsRows(QStringLiteral("copy several directories"),
QStringLiteral("test"),
@@ -131,7 +139,8 @@ void CopyTest::testCopying_data()
new Archive::Entry(this, QStringLiteral("dir2/dir/a.txt")),
new Archive::Entry(this, QStringLiteral("dir2/dir/b.txt")),
},
- new Archive::Entry(this, QStringLiteral("empty_dir/")));
+ new Archive::Entry(this, QStringLiteral("empty_dir/")),
+ 23);
addAllFormatsRows(QStringLiteral("copy several entries"),
QStringLiteral("test"),
@@ -142,7 +151,8 @@ void CopyTest::testCopying_data()
new Archive::Entry(this, QStringLiteral("dir1/a.txt")),
new Archive::Entry(this, QStringLiteral("dir1/b.txt")),
},
- new Archive::Entry(this, QStringLiteral("empty_dir/")));
+ new Archive::Entry(this, QStringLiteral("empty_dir/")),
+ 18);
addAllFormatsRows(QStringLiteral("copy a directory inside itself"),
QStringLiteral("test"),
@@ -154,7 +164,8 @@ void CopyTest::testCopying_data()
new Archive::Entry(this, QStringLiteral("dir1/a.txt")),
new Archive::Entry(this, QStringLiteral("dir1/b.txt")),
},
- new Archive::Entry(this, QStringLiteral("dir1/")));
+ new Archive::Entry(this, QStringLiteral("dir1/")),
+ 19);
addAllFormatsRows(QStringLiteral("copy a directory to the root"),
QStringLiteral("test"),
@@ -163,7 +174,8 @@ void CopyTest::testCopying_data()
new Archive::Entry(this, QStringLiteral("dir1/dir/a.txt")),
new Archive::Entry(this, QStringLiteral("dir1/dir/b.txt")),
},
- new Archive::Entry(this, QStringLiteral("")));
+ new Archive::Entry(this, QStringLiteral("")),
+ 16);
}
void CopyTest::testCopying()
@@ -201,6 +213,9 @@ void CopyTest::testCopying()
QVector<Archive::Entry*> resultedEntries = TestHelper::getEntryList(archive);
TestHelper::verifyCopiedEntriesWithDestination(files, destination, oldEntries, resultedEntries);
+ QFETCH(uint, numberOfEntries);
+ QCOMPARE(archive->numberOfEntries(), numberOfEntries);
+
archive->deleteLater();
}
diff --git a/autotests/kerfuffle/data/test.tar.bz2 b/autotests/kerfuffle/data/test.tar.bz2
index bcd4105..5dbee08 100644
--- a/autotests/kerfuffle/data/test.tar.bz2
+++ b/autotests/kerfuffle/data/test.tar.bz2
Binary files differ
diff --git a/autotests/kerfuffle/movetest.cpp b/autotests/kerfuffle/movetest.cpp
index 87bbdc2..00cf923 100644
--- a/autotests/kerfuffle/movetest.cpp
+++ b/autotests/kerfuffle/movetest.cpp
@@ -37,7 +37,7 @@ private Q_SLOTS:
void testMoving();
private:
- void addAllFormatsRows(const QString &testName, const QString &archiveName, const QVector<Archive::Entry*> &targetEntries, Archive::Entry *destination, const QStringList &expectedNewPaths) {
+ void addAllFormatsRows(const QString &testName, const QString &archiveName, const QVector<Archive::Entry*> &targetEntries, Archive::Entry *destination, const QStringList &expectedNewPaths, uint numberOfEntries) {
const auto formats = QStringList {
QStringLiteral("7z"),
QStringLiteral("rar"),
@@ -57,7 +57,8 @@ private:
<< plugin
<< targetEntries
<< destination
- << expectedNewPaths;
+ << expectedNewPaths
+ << numberOfEntries;
}
}
}
@@ -85,6 +86,7 @@ void MoveTest::testMoving_data()
QTest::addColumn<QVector<Archive::Entry*>>("targetEntries");
QTest::addColumn<Archive::Entry*>("destination");
QTest::addColumn<QStringList>("expectedNewPaths");
+ QTest::addColumn<uint>("numberOfEntries");
addAllFormatsRows(QStringLiteral("replace a single file"),
QStringLiteral("test"),
@@ -94,7 +96,8 @@ void MoveTest::testMoving_data()
new Archive::Entry(this, QStringLiteral("empty_dir/a.txt")),
QStringList {
QStringLiteral("empty_dir/a.txt")
- });
+ },
+ 13);
addAllFormatsRows(QStringLiteral("replace several files"),
QStringLiteral("test"),
@@ -106,7 +109,8 @@ void MoveTest::testMoving_data()
QStringList {
QStringLiteral("empty_dir/a.txt"),
QStringLiteral("empty_dir/b.txt")
- });
+ },
+ 13);
addAllFormatsRows(QStringLiteral("replace a root directory"),
QStringLiteral("test"),
@@ -124,7 +128,8 @@ void MoveTest::testMoving_data()
QStringLiteral("empty_dir/dir/"),
QStringLiteral("empty_dir/dir/a.txt"),
QStringLiteral("empty_dir/dir/b.txt"),
- });
+ },
+ 13);
addAllFormatsRows(QStringLiteral("replace a root directory 2"),
QStringLiteral("test"),
@@ -138,7 +143,8 @@ void MoveTest::testMoving_data()
QStringLiteral("empty_dir/dir/"),
QStringLiteral("empty_dir/dir/a.txt"),
QStringLiteral("empty_dir/dir/b.txt"),
- });
+ },
+ 13);
addAllFormatsRows(QStringLiteral("replace a directory"),
QStringLiteral("test"),
@@ -152,7 +158,8 @@ void MoveTest::testMoving_data()
QStringLiteral("empty_dir/dir/"),
QStringLiteral("empty_dir/dir/a.txt"),
QStringLiteral("empty_dir/dir/b.txt"),
- });
+ },
+ 13);
addAllFormatsRows(QStringLiteral("replace several directories"),
QStringLiteral("test"),
@@ -180,7 +187,8 @@ void MoveTest::testMoving_data()
QStringLiteral("empty_dir/dir2/dir/"),
QStringLiteral("empty_dir/dir2/dir/a.txt"),
QStringLiteral("empty_dir/dir2/dir/b.txt")
- });
+ },
+ 13);
addAllFormatsRows(QStringLiteral("replace several entries"),
QStringLiteral("test"),
@@ -198,7 +206,8 @@ void MoveTest::testMoving_data()
QStringLiteral("empty_dir/dir/b.txt"),
QStringLiteral("empty_dir/a.txt"),
QStringLiteral("empty_dir/b.txt")
- });
+ },
+ 13);
addAllFormatsRows(QStringLiteral("move a directory to the root"),
QStringLiteral("test"),
@@ -212,7 +221,8 @@ void MoveTest::testMoving_data()
QStringLiteral("dir/"),
QStringLiteral("dir/a.txt"),
QStringLiteral("dir/b.txt"),
- });
+ },
+ 13);
}
void MoveTest::testMoving()
@@ -273,6 +283,9 @@ void MoveTest::testMoving()
QVERIFY(!newPaths.contains(entry->fullPath()));
}
+ QFETCH(uint, numberOfEntries);
+ QCOMPARE(archive->numberOfEntries(), numberOfEntries);
+
loadJob->deleteLater();
archive->deleteLater();
}