Commit 66f4e32c authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add autotest

parent 2aaa8cc2
......@@ -52,4 +52,4 @@ add_unittest( kdeapplicationtreelistwidgettest.cpp "../src/loggingcategory.cpp;.
add_unittest( categorywarningtest.cpp "../src/categorywarning.cpp")
add_unittest( loggingcategorytest.cpp "../src/loggingcategory.cpp")
add_unittest( loadcategoriesjobtest.cpp "../src/loadcategoriesjob.cpp;../src/loggingcategory.cpp;../src/kdeloggingcategory.cpp;../src/kdebugsettings_debug.cpp;../src/kdebugsettingsutil.cpp")
add_unittest( renamecategorytest.cpp "../src/renamecategory.cpp")
add_unittest( renamecategorytest.cpp "../src/renamecategory.cpp;../src/kdebugsettingsutil.cpp;../src/kdeloggingcategory.cpp;../src/kdebugsettings_debug.cpp")
......@@ -18,6 +18,8 @@
*/
#include "renamecategorytest.h"
#include "../src/kdebugsettingsutil.h"
#include "../src/renamecategory.h"
#include <QTest>
RenameCategoryTest::RenameCategoryTest(QObject *parent)
......@@ -31,4 +33,36 @@ RenameCategoryTest::~RenameCategoryTest()
}
void RenameCategoryTest::shouldParseRenameLine_data()
{
QTest::addColumn<QString>("input");
QTest::addColumn<QString>("newname");
QTest::addColumn<QString>("original");
QTest::addColumn<bool>("valid");
QTest::newRow("empty") << QString() << QString() << QString() << false;
QTest::newRow("validLine") << QStringLiteral("log linux") << QStringLiteral("linux") << QStringLiteral("log") << true;
QTest::newRow("validLinewithspace") << QStringLiteral(" log linux ") << QStringLiteral("linux") << QStringLiteral("log") << true;
QTest::newRow("comment") << QStringLiteral("#log linux ") << QString() << QString() << false;
QTest::newRow("commentWithSpace") << QStringLiteral(" #log linux ") << QString() << QString() << false;
QTest::newRow("badline") << QStringLiteral("log") << QString() << QString() << false;
QTest::newRow("comment-2") << QStringLiteral("#log linux") << QString() << QString() << false;
QTest::newRow("linewithcomment") << QStringLiteral("log linux#comment about linux") << QStringLiteral("linux") << QStringLiteral("log") << true;
}
void RenameCategoryTest::shouldParseRenameLine()
{
QFETCH(QString, input);
QFETCH(QString, newname);
QFETCH(QString, original);
QFETCH(bool, valid);
RenameCategory result;
result.originalName = original;
result.newName = newname;
const RenameCategory cat = KDebugSettingsUtil::parseRenameCategories(input);
QCOMPARE(cat, result);
QCOMPARE(cat.isValid(), valid);
}
QTEST_MAIN(RenameCategoryTest)
......@@ -29,6 +29,9 @@ class RenameCategoryTest : public QObject
public:
explicit RenameCategoryTest(QObject *parent = Q_NULLPTR);
~RenameCategoryTest();
private Q_SLOTS:
void shouldParseRenameLine_data();
void shouldParseRenameLine();
};
#endif // RENAMECATEGORYTEST_H
Supports Markdown
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