File indexing completed on 2024-05-12 16:35:54
0001 /* This file is part of the KDE project 0002 Copyright 2011 Marijn Kruisselbrink <mkruisselbrink@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #include "TestDatabaseFilter.h" 0021 0022 #include <sheets/database/Filter.h> 0023 0024 #include <QTest> 0025 0026 using namespace Calligra::Sheets; 0027 0028 void DatabaseFilterTest::testIsEmpty() 0029 { 0030 Filter f; 0031 QVERIFY(f.isEmpty()); 0032 } 0033 0034 void DatabaseFilterTest::testEmptyEquals() 0035 { 0036 Filter a, b; 0037 QVERIFY2(a == b, "Two empty filters are equal"); 0038 } 0039 0040 void DatabaseFilterTest::testSimpleEquals() 0041 { 0042 Filter a; 0043 Filter b; 0044 a.addCondition(Filter::AndComposition, 0, Filter::Match, "test"); 0045 QVERIFY(a != b); 0046 b.addCondition(Filter::AndComposition, 0, Filter::Match, "test"); 0047 QVERIFY(a == b); 0048 } 0049 0050 void DatabaseFilterTest::testNotEquals1() 0051 { 0052 Filter a; 0053 Filter b; 0054 a.addCondition(Filter::AndComposition, 0, Filter::Match, "test"); 0055 b.addCondition(Filter::AndComposition, 0, Filter::Match, "test2"); 0056 QVERIFY(a != b); 0057 } 0058 0059 void DatabaseFilterTest::testNotEquals2() 0060 { 0061 Filter a; 0062 Filter b; 0063 a.addCondition(Filter::AndComposition, 0, Filter::Match, "test"); 0064 b.addCondition(Filter::AndComposition, 0, Filter::NotMatch, "test"); 0065 QVERIFY(a != b); 0066 } 0067 0068 void DatabaseFilterTest::testAndEquals() 0069 { 0070 Filter a; 0071 Filter b; 0072 a.addCondition(Filter::AndComposition, 0, Filter::Match, "test"); 0073 b.addCondition(Filter::AndComposition, 0, Filter::Match, "test"); 0074 a.addCondition(Filter::AndComposition, 0, Filter::Match, "test2"); 0075 b.addCondition(Filter::AndComposition, 0, Filter::Match, "test2"); 0076 QVERIFY(a == b); 0077 } 0078 0079 void DatabaseFilterTest::testOrEquals() 0080 { 0081 Filter a; 0082 Filter b; 0083 a.addCondition(Filter::OrComposition, 0, Filter::Match, "test"); 0084 b.addCondition(Filter::OrComposition, 0, Filter::Match, "test"); 0085 a.addCondition(Filter::OrComposition, 0, Filter::Match, "test2"); 0086 b.addCondition(Filter::OrComposition, 0, Filter::Match, "test2"); 0087 QVERIFY(a == b); 0088 } 0089 0090 QTEST_MAIN(DatabaseFilterTest)