Warning, file /pim/mailcommon/src/search/autotests/searchrulenumericaltest.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-only 0005 */ 0006 0007 #include "searchrulenumericaltest.h" 0008 #include "../searchrule/searchrulenumerical.h" 0009 #include <QTest> 0010 SearchRuleNumericalTest::SearchRuleNumericalTest(QObject *parent) 0011 : QObject(parent) 0012 { 0013 } 0014 0015 void SearchRuleNumericalTest::shouldHaveDefaultValue() 0016 { 0017 MailCommon::SearchRuleNumerical ruleStatus; 0018 QVERIFY(ruleStatus.contents().isEmpty()); 0019 QVERIFY(ruleStatus.field().isEmpty()); 0020 QCOMPARE(ruleStatus.function(), MailCommon::SearchRule::FuncContains); 0021 QVERIFY(ruleStatus.isEmpty()); 0022 } 0023 0024 void SearchRuleNumericalTest::shouldBeEmpty() 0025 { 0026 MailCommon::SearchRuleNumerical ruleStatus(QByteArray(), MailCommon::SearchRule::FuncContains, QStringLiteral("foo")); 0027 QVERIFY(ruleStatus.isEmpty()); 0028 ruleStatus = MailCommon::SearchRuleNumerical(QByteArray(), MailCommon::SearchRule::FuncContains, QStringLiteral("0")); 0029 QVERIFY(!ruleStatus.isEmpty()); 0030 } 0031 0032 void SearchRuleNumericalTest::shouldHaveRequirePart() 0033 { 0034 MailCommon::SearchRuleNumerical ruleStatus; 0035 QCOMPARE(ruleStatus.requiredPart(), MailCommon::SearchRule::Envelope); 0036 } 0037 0038 void SearchRuleNumericalTest::shouldMatchNumericalsize_data() 0039 { 0040 #if 0 0041 QTest::addColumn<MailCommon::SearchRule::Function>("function"); 0042 QTest::addColumn<long>("value"); 0043 QTest::addColumn<long>("matchvalue"); 0044 QTest::addColumn<bool>("match"); 0045 #endif 0046 } 0047 0048 void SearchRuleNumericalTest::shouldMatchNumericalsize() 0049 { 0050 #if 0 0051 QFETCH(MailCommon::SearchRule::Function, function); 0052 QFETCH(long, value); 0053 QFETCH(long, matchvalue); 0054 QFETCH(bool, match); 0055 MailCommon::SearchRuleNumerical searchrule("<size>", function, QString::number(value)); 0056 KMime::Message::Ptr msgPtr = KMime::Message::Ptr(new KMime::Message()); 0057 msgPtr->date(true)->setDateTime(maildate); 0058 Akonadi::Item item; 0059 item.setPayload<KMime::Message::Ptr>(msgPtr); 0060 QCOMPARE(searchrule.matches(item), match); 0061 #endif 0062 } 0063 0064 QTEST_MAIN(SearchRuleNumericalTest) 0065 0066 #include "moc_searchrulenumericaltest.cpp"