Skip to content

Commit

Permalink
feat: move compressed test data to files instead of base64 strings
Browse files Browse the repository at this point in the history
  • Loading branch information
lievenhey committed Nov 19, 2024
1 parent 06cfd33 commit 3e74a87
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 19 deletions.
Binary file added tests/integrationtests/archives/test.bz2
Binary file not shown.
Binary file added tests/integrationtests/archives/test.gz
Binary file not shown.
1 change: 1 addition & 0 deletions tests/integrationtests/archives/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World
Binary file added tests/integrationtests/archives/test.xz
Binary file not shown.
24 changes: 5 additions & 19 deletions tests/integrationtests/tst_perfparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,34 +798,20 @@ private slots:
#if KFArchive_FOUND
void testDecompression_data()
{
QTest::addColumn<QByteArray>("content");
QTest::addColumn<QString>("filename");

QTest::newRow("plain") << QByteArrayLiteral("Hello World\n") << QStringLiteral("XXXXXX");
QTest::newRow("gzip") << QByteArray::fromBase64(
QByteArrayLiteral("H4sIAAAAAAAAA/NIzcnJVwjPL8pJ4QIA4+WVsAwAAAA="))
<< QStringLiteral("XXXXXX.gz");
QTest::newRow("bzip2") << QByteArray::fromBase64(
QByteArrayLiteral("QlpoOTFBWSZTWdhyAS8AAAFXgAAQQAAAQACABgSQACAAIgaG1CDJiMdp6Cgfi7kinChIbDkAl4A="))
<< QStringLiteral("XXXXXX.bz2");
QTest::newRow("xz") << QByteArray::fromBase64(QByteArrayLiteral(
"/Td6WFoAAATm1rRGAgAhARYAAAB0L+WjAQALSGVsbG8gV29ybGQKACLgdT/V7Tg+AAEkDKYY2NgftvN9AQAAAAAEWVo="))
<< QStringLiteral("XXXXXX.xz");
QTest::newRow("plain") << QFINDTESTDATA("archives/test.txt");
QTest::newRow("gzip") << QFINDTESTDATA("archives/test.gz");
QTest::newRow("bzip2") << QFINDTESTDATA("archives/test.bz2");
QTest::newRow("xz") << QFINDTESTDATA("archives/test.xz");
}

void testDecompression()
{
QFETCH(QByteArray, content);
QFETCH(QString, filename);

QTemporaryFile compressed;
compressed.setFileTemplate(filename);
compressed.open();
compressed.write(content);
compressed.close();

PerfParser parser;
QFile decompressed(parser.decompressIfNeeded(compressed.fileName()));
QFile decompressed(parser.decompressIfNeeded(filename));
decompressed.open(QIODevice::ReadOnly);

QCOMPARE(decompressed.readAll(), QByteArrayLiteral("Hello World\n"));
Expand Down

0 comments on commit 3e74a87

Please sign in to comment.