Advance Wayland and KDE package bring-up
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
SPDX-FileCopyrightText: 2021 Harald Sitter <sitter@kde.org>
|
||||
*/
|
||||
|
||||
#include <QTest>
|
||||
|
||||
#include "../src/metadata.cpp"
|
||||
|
||||
using namespace KCrash;
|
||||
|
||||
class MetadataTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void testEverything()
|
||||
{
|
||||
QTemporaryDir tmpDir;
|
||||
QVERIFY(tmpDir.isValid());
|
||||
|
||||
const QString iniFile = QStringLiteral("%1/foo.ini").arg(tmpDir.path());
|
||||
Metadata data("BEFEHL");
|
||||
#ifdef Q_OS_LINUX
|
||||
MetadataINIWriter iniWriter(iniFile.toLocal8Bit());
|
||||
data.setAdditionalWriter(&iniWriter);
|
||||
#endif
|
||||
data.add("--ABC", "FOO\nBAR");
|
||||
data.addBool("--Meow");
|
||||
data.close();
|
||||
const int argc = data.argc;
|
||||
QCOMPARE(argc, 4);
|
||||
QCOMPARE(data.argv.at(0), QStringLiteral("BEFEHL")); // make sure we do stringy comparison
|
||||
QCOMPARE(data.argv.at(1), QStringLiteral("--ABC"));
|
||||
QCOMPARE(data.argv.at(2), QStringLiteral("FOO\nBAR"));
|
||||
QCOMPARE(data.argv.at(3), QStringLiteral("--Meow"));
|
||||
QCOMPARE(data.argv.at(4), nullptr); // list should be null terminated
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
QFile::exists(iniFile);
|
||||
QFile ini(iniFile);
|
||||
QVERIFY(ini.open(QFile::ReadOnly));
|
||||
QCOMPARE(ini.readLine(), "[KCrash]\n");
|
||||
QCOMPARE(ini.readLine(), "ABC=FOO\\nBAR\n");
|
||||
QCOMPARE(ini.readLine(), "Meow=true\n");
|
||||
QVERIFY(ini.atEnd()); // nothing after final newline
|
||||
#endif
|
||||
}
|
||||
|
||||
void testNoFile()
|
||||
{
|
||||
// Doesn't explode without writer
|
||||
Metadata data("BEFEHL");
|
||||
data.add("--ABC", "FOO");
|
||||
data.close();
|
||||
const int argc = data.argc;
|
||||
QCOMPARE(argc, 3);
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_MAIN(MetadataTest)
|
||||
|
||||
#include "metadatatest.moc"
|
||||
Reference in New Issue
Block a user