X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/fa988586bc923b33497cbc97aaac07fc93a4ca83..df5cf6fe851021a73159fdd3487fe629c1ea8376:/src/tests/kitemsettest.cpp diff --git a/src/tests/kitemsettest.cpp b/src/tests/kitemsettest.cpp index 9cc02d060..b5e0a82cd 100644 --- a/src/tests/kitemsettest.cpp +++ b/src/tests/kitemsettest.cpp @@ -1,29 +1,15 @@ -/*************************************************************************** - * Copyright (C) 2013 by Frank Reininghaus * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#include +/* + * SPDX-FileCopyrightText: 2013 Frank Reininghaus + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ #include "kitemviews/kitemset.h" -#include +#include +#include -Q_DECLARE_METATYPE(KItemRangeList); +Q_DECLARE_METATYPE(KItemRangeList) /** * Converts a KItemRangeList to a KItemSet. @@ -31,7 +17,7 @@ Q_DECLARE_METATYPE(KItemRangeList); KItemSet KItemRangeList2KItemSet(const KItemRangeList& itemRanges) { KItemSet result; - foreach (const KItemRange& range, itemRanges) { + for (const KItemRange& range : itemRanges) { for (int i = range.index; i < range.index + range.count; ++i) { result.insert(i); } @@ -45,7 +31,7 @@ KItemSet KItemRangeList2KItemSet(const KItemRangeList& itemRanges) QSet KItemRangeList2QSet(const KItemRangeList& itemRanges) { QSet result; - foreach (const KItemRange& range, itemRanges) { + for (const KItemRange& range : itemRanges) { for (int i = range.index; i < range.index + range.count; ++i) { result.insert(i); } @@ -59,7 +45,7 @@ QSet KItemRangeList2QSet(const KItemRangeList& itemRanges) QVector KItemRangeList2QVector(const KItemRangeList& itemRanges) { QVector result; - foreach (const KItemRange& range, itemRanges) { + for (const KItemRange& range : itemRanges) { for (int i = range.index; i < range.index + range.count; ++i) { result.append(i); } @@ -73,18 +59,18 @@ QVector KItemRangeList2QVector(const KItemRangeList& itemRanges) static QSet KItemSet2QSet(const KItemSet& itemSet) { QSet result; - foreach (int i, itemSet) { + for (int i : itemSet) { result.insert(i); } // Check that the conversion was successful. Q_ASSERT(itemSet.count() == result.count()); - foreach (int i, itemSet) { + for (int i : qAsConst(itemSet)) { Q_ASSERT(result.contains(i)); } - foreach (int i, result) { + for (int i : qAsConst(result)) { Q_ASSERT(itemSet.contains(i)); } @@ -99,7 +85,7 @@ class KItemSetTest : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void testConstruction_data(); @@ -125,6 +111,8 @@ private: void KItemSetTest::initTestCase() { + QStandardPaths::setTestModeEnabled(true); + m_testCases.insert("empty", KItemRangeList()); m_testCases.insert("[0]", KItemRangeList() << KItemRange(0, 1)); m_testCases.insert("[1]", KItemRangeList() << KItemRange(1, 1)); @@ -205,7 +193,7 @@ void KItemSetTest::testIterators() QVERIFY(itemSet.isValid()); QVERIFY(itemSet.count() == itemsQVector.count()); - if (itemSet.count() == 0) { + if (itemSet.isEmpty()) { QVERIFY(itemSet.isEmpty()); QVERIFY(itemSet.begin() == itemSet.end()); QVERIFY(itemSet.constBegin() == itemSet.constEnd()); @@ -240,7 +228,7 @@ void KItemSetTest::testIterators() QCOMPARE(testQVector, itemsQVector); testQVector.clear(); - foreach (int i, itemSet) { + for (int i : itemSet) { testQVector.append(i); } QCOMPARE(testQVector, itemsQVector); @@ -328,7 +316,7 @@ void KItemSetTest::testFind_data() /** * Test all functions that find items: - * contais(int), find(int), constFind(int) + * contains(int), find(int), constFind(int) */ void KItemSetTest::testFind() { @@ -344,7 +332,7 @@ void KItemSetTest::testFind() int min; int max; - if (itemSet.count() == 0) { + if (itemSet.isEmpty()) { // Use some arbitrary values for the upcoming tests. min = 0; max = 5; @@ -403,7 +391,7 @@ void KItemSetTest::testChangingOneItem() int min; int max; - if (itemSet.count() == 0) { + if (itemSet.isEmpty()) { // Use some arbitrary values for the upcoming tests. min = 0; max = 5; @@ -500,7 +488,7 @@ void KItemSetTest::testChangingOneItem() QCOMPARE(tmp.end(), tmp.find(i)); QCOMPARE(tmp.constEnd(), tmp.constFind(i)); - // Check the returen value, now contained in 'it'. + // Check the returned value, now contained in 'it'. if (i == max) { QCOMPARE(it, tmp.end()); } else { @@ -607,6 +595,6 @@ void KItemSetTest::testSymmetricDifference() } -QTEST_MAIN(KItemSetTest) +QTEST_GUILESS_MAIN(KItemSetTest) #include "kitemsettest.moc"