summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-16 14:20:56 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-16 14:20:56 (GMT)
commit66f4e32c6537a876f912e0ba255188f41ddea2fd (patch)
tree017cb5725981adce32c53fb7ef7a4e59fa3bd2f7
parent2aaa8cc2b34d17cb31a5ecf7ea4199ad91eede0e (diff)
Add autotest
-rw-r--r--autotests/CMakeLists.txt2
-rw-r--r--autotests/renamecategorytest.cpp34
-rw-r--r--autotests/renamecategorytest.h3
3 files changed, 38 insertions, 1 deletions
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
index 5996425..2379e36 100644
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -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")
diff --git a/autotests/renamecategorytest.cpp b/autotests/renamecategorytest.cpp
index b24c751..bedf151 100644
--- a/autotests/renamecategorytest.cpp
+++ b/autotests/renamecategorytest.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)
diff --git a/autotests/renamecategorytest.h b/autotests/renamecategorytest.h
index 8f6f8ce..4a60e5d 100644
--- a/autotests/renamecategorytest.h
+++ b/autotests/renamecategorytest.h
@@ -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