From cb8d4797b79986b452602d7d03f0991dfc305043 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Sun, 4 Dec 2022 08:31:14 +0100 Subject: [PATCH] TaskTree: Add TreeStorageBase::operator== Change-Id: I50144978b86f2e5fa89fc35c687b64ed102803e6 Reviewed-by: hjk Reviewed-by: --- src/libs/utils/tasktree.h | 4 ++++ tests/auto/utils/tasktree/tst_tasktree.cpp | 22 +++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/libs/utils/tasktree.h b/src/libs/utils/tasktree.h index b89a68828d8..5d0b3c5b2b3 100644 --- a/src/libs/utils/tasktree.h +++ b/src/libs/utils/tasktree.h @@ -31,6 +31,10 @@ class QTCREATOR_UTILS_EXPORT TreeStorageBase { public: bool isValid() const; + friend bool operator==(const TreeStorageBase &first, const TreeStorageBase &second) + { return first.m_storageData == second.m_storageData; } + friend bool operator!=(const TreeStorageBase &first, const TreeStorageBase &second) + { return first.m_storageData != second.m_storageData; } protected: using StorageConstructor = std::function; diff --git a/tests/auto/utils/tasktree/tst_tasktree.cpp b/tests/auto/utils/tasktree/tst_tasktree.cpp index a764cb4c94c..6a8f2454c27 100644 --- a/tests/auto/utils/tasktree/tst_tasktree.cpp +++ b/tests/auto/utils/tasktree/tst_tasktree.cpp @@ -14,6 +14,7 @@ #include using namespace Utils; +using namespace Utils::Tasking; enum class Handler { Setup, @@ -38,6 +39,7 @@ private slots: void processTree(); void storage_data(); void storage(); + void storageOperators(); void storageDestructor(); void cleanupTestCase(); @@ -65,8 +67,6 @@ void tst_TaskTree::cleanupTestCase() void tst_TaskTree::validConstructs() { - using namespace Tasking; - const Group process { parallel, Process([](QtcProcess &) {}, [](const QtcProcess &) {}), @@ -107,7 +107,6 @@ static const char s_processIdProperty[] = "__processId"; void tst_TaskTree::processTree_data() { - using namespace Tasking; using namespace std::placeholders; QTest::addColumn("root"); @@ -462,7 +461,6 @@ void tst_TaskTree::processTree_data() void tst_TaskTree::processTree() { m_log = {}; - using namespace Tasking; QFETCH(Group, root); QFETCH(Log, expectedLog); @@ -519,7 +517,6 @@ static Log s_log; void tst_TaskTree::storage_data() { - using namespace Tasking; using namespace std::placeholders; QTest::addColumn("root"); @@ -599,8 +596,6 @@ void tst_TaskTree::storage_data() void tst_TaskTree::storage() { - using namespace Tasking; - QFETCH(Group, root); QFETCH(TreeStorage, storageLog); QFETCH(Log, expectedLog); @@ -639,10 +634,19 @@ void tst_TaskTree::storage() QCOMPARE(errorCount, expectedErrorCount); } +void tst_TaskTree::storageOperators() +{ + TreeStorageBase storage1 = TreeStorage(); + TreeStorageBase storage2 = TreeStorage(); + TreeStorageBase storage3 = storage1; + + QVERIFY(storage1 == storage3); + QVERIFY(storage1 != storage2); + QVERIFY(storage2 != storage3); +} + void tst_TaskTree::storageDestructor() { - using namespace Tasking; - QCOMPARE(CustomStorage::instanceCount(), 0); { const auto setupProcess = [this](QtcProcess &process) {