Commit 67e7d7ca authored by Ragnar Thomsen's avatar Ragnar Thomsen

Add unittests for multi-volume archives

Test cases were added to addArgsTest (clirar and cli7z) for specifying
volume size when adding files to multi-volume archives.
parent bf6425d1
......@@ -256,11 +256,12 @@ void Cli7zTest::testAddArgs_data()
QTest::addColumn<QString>("password");
QTest::addColumn<bool>("encryptHeader");
QTest::addColumn<int>("compressionLevel");
QTest::addColumn<ulong>("volumeSize");
QTest::addColumn<QStringList>("expectedArgs");
QTest::newRow("unencrypted")
<< QStringLiteral("/tmp/foo.7z")
<< QString() << false << 5
<< QString() << false << 5 << 0UL
<< QStringList {
QStringLiteral("a"),
QStringLiteral("/tmp/foo.7z"),
......@@ -269,7 +270,7 @@ void Cli7zTest::testAddArgs_data()
QTest::newRow("encrypted")
<< QStringLiteral("/tmp/foo.7z")
<< QStringLiteral("1234") << false << 5
<< QStringLiteral("1234") << false << 5 << 0UL
<< QStringList {
QStringLiteral("a"),
QStringLiteral("/tmp/foo.7z"),
......@@ -279,7 +280,7 @@ void Cli7zTest::testAddArgs_data()
QTest::newRow("header-encrypted")
<< QStringLiteral("/tmp/foo.7z")
<< QStringLiteral("1234") << true << 5
<< QStringLiteral("1234") << true << 5 << 0UL
<< QStringList {
QStringLiteral("a"),
QStringLiteral("/tmp/foo.7z"),
......@@ -287,6 +288,16 @@ void Cli7zTest::testAddArgs_data()
QStringLiteral("-mhe=on"),
QStringLiteral("-mx=5")
};
QTest::newRow("multi-volume")
<< QStringLiteral("/tmp/foo.7z")
<< QString() << false << 5 << 2500UL
<< QStringList {
QStringLiteral("a"),
QStringLiteral("/tmp/foo.7z"),
QStringLiteral("-mx=5"),
QStringLiteral("-v2500k")
};
}
void Cli7zTest::testAddArgs()
......@@ -299,13 +310,15 @@ void Cli7zTest::testAddArgs()
QStringLiteral("$Archive"),
QStringLiteral("$PasswordSwitch"),
QStringLiteral("$CompressionLevelSwitch"),
QStringLiteral("$MultiVolumeSwitch"),
QStringLiteral("$Files") };
QFETCH(QString, password);
QFETCH(bool, encryptHeader);
QFETCH(int, compressionLevel);
QFETCH(ulong, volumeSize);
QStringList replacedArgs = plugin->substituteAddVariables(addArgs, {}, password, encryptHeader, compressionLevel, 0);
QStringList replacedArgs = plugin->substituteAddVariables(addArgs, {}, password, encryptHeader, compressionLevel, volumeSize);
QFETCH(QStringList, expectedArgs);
QCOMPARE(replacedArgs, expectedArgs);
......
......@@ -286,11 +286,12 @@ void CliRarTest::testAddArgs_data()
QTest::addColumn<QString>("password");
QTest::addColumn<bool>("encryptHeader");
QTest::addColumn<int>("compressionLevel");
QTest::addColumn<ulong>("volumeSize");
QTest::addColumn<QStringList>("expectedArgs");
QTest::newRow("unencrypted")
<< QStringLiteral("/tmp/foo.rar")
<< QString() << false << 3
<< QString() << false << 3 << 0UL
<< QStringList {
QStringLiteral("a"),
QStringLiteral("/tmp/foo.rar"),
......@@ -299,7 +300,7 @@ void CliRarTest::testAddArgs_data()
QTest::newRow("encrypted")
<< QStringLiteral("/tmp/foo.rar")
<< QStringLiteral("1234") << false << 3
<< QStringLiteral("1234") << false << 3 << 0UL
<< QStringList {
QStringLiteral("a"),
QStringLiteral("/tmp/foo.rar"),
......@@ -309,13 +310,23 @@ void CliRarTest::testAddArgs_data()
QTest::newRow("header-encrypted")
<< QStringLiteral("/tmp/foo.rar")
<< QStringLiteral("1234") << true << 3
<< QStringLiteral("1234") << true << 3 << 0UL
<< QStringList {
QStringLiteral("a"),
QStringLiteral("/tmp/foo.rar"),
QStringLiteral("-hp1234"),
QStringLiteral("-m3")
};
QTest::newRow("multi-volume")
<< QStringLiteral("/tmp/foo.rar")
<< QString() << false << 3 << 2500UL
<< QStringList {
QStringLiteral("a"),
QStringLiteral("/tmp/foo.rar"),
QStringLiteral("-m3"),
QStringLiteral("-v2500k")
};
}
void CliRarTest::testAddArgs()
......@@ -328,13 +339,15 @@ void CliRarTest::testAddArgs()
QStringLiteral("$Archive"),
QStringLiteral("$PasswordSwitch"),
QStringLiteral("$CompressionLevelSwitch"),
QStringLiteral("$MultiVolumeSwitch"),
QStringLiteral("$Files") };
QFETCH(QString, password);
QFETCH(bool, encryptHeader);
QFETCH(int, compressionLevel);
QFETCH(ulong, volumeSize);
QStringList replacedArgs = rarPlugin->substituteAddVariables(addArgs, {}, password, encryptHeader, compressionLevel, 0);
QStringList replacedArgs = rarPlugin->substituteAddVariables(addArgs, {}, password, encryptHeader, compressionLevel, volumeSize);
QFETCH(QStringList, expectedArgs);
QCOMPARE(replacedArgs, expectedArgs);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment