Warning, file /pim/mailcommon/src/search/autotests/searchrulestringtest.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 "searchrulestringtest.h"
0008 #include "../searchrule/searchrulestring.h"
0009 #include <QTest>
0010 
0011 SearchRuleStringTest::SearchRuleStringTest(QObject *parent)
0012     : QObject(parent)
0013 {
0014 }
0015 
0016 void SearchRuleStringTest::shouldHaveDefaultValue()
0017 {
0018     MailCommon::SearchRuleString searchrule;
0019     QCOMPARE(searchrule.function(), MailCommon::SearchRule::FuncContains);
0020     QVERIFY(searchrule.isEmpty());
0021 }
0022 
0023 void SearchRuleStringTest::shouldHaveRequirePart()
0024 {
0025     QFETCH(QByteArray, field);
0026     QFETCH(MailCommon::SearchRule::RequiredPart, requiredpart);
0027     MailCommon::SearchRuleString ruleStatus(field);
0028     QCOMPARE(ruleStatus.requiredPart(), requiredpart);
0029 }
0030 
0031 void SearchRuleStringTest::shouldHaveRequirePart_data()
0032 {
0033     QTest::addColumn<QByteArray>("field");
0034     QTest::addColumn<MailCommon::SearchRule::RequiredPart>("requiredpart");
0035 
0036     QTest::newRow("recipient") << QByteArray("<recipients>") << MailCommon::SearchRule::Envelope;
0037     QTest::newRow("status") << QByteArray("<status>") << MailCommon::SearchRule::Envelope;
0038     QTest::newRow("tag") << QByteArray("<tag>") << MailCommon::SearchRule::Envelope;
0039     QTest::newRow("subject") << QByteArray("subject") << MailCommon::SearchRule::Envelope;
0040     QTest::newRow("from") << QByteArray("from") << MailCommon::SearchRule::Envelope;
0041     QTest::newRow("sender") << QByteArray("sender") << MailCommon::SearchRule::Envelope;
0042     QTest::newRow("reply-to") << QByteArray("reply-to") << MailCommon::SearchRule::Envelope;
0043     QTest::newRow("to") << QByteArray("to") << MailCommon::SearchRule::Envelope;
0044     QTest::newRow("cc") << QByteArray("cc") << MailCommon::SearchRule::Envelope;
0045     QTest::newRow("in-reply-to") << QByteArray("in-reply-to") << MailCommon::SearchRule::Envelope;
0046     QTest::newRow("message-id") << QByteArray("message-id") << MailCommon::SearchRule::Envelope;
0047     QTest::newRow("references") << QByteArray("references") << MailCommon::SearchRule::Envelope;
0048 
0049     QTest::newRow("messages") << QByteArray("<message>") << MailCommon::SearchRule::CompleteMessage;
0050     QTest::newRow("body") << QByteArray("<body>") << MailCommon::SearchRule::CompleteMessage;
0051 
0052     QTest::newRow("unknown") << QByteArray("unknown") << MailCommon::SearchRule::Header;
0053 }
0054 
0055 void SearchRuleStringTest::shouldMatchString()
0056 {
0057 }
0058 
0059 void SearchRuleStringTest::shouldMatchString_data()
0060 {
0061 }
0062 
0063 void SearchRuleStringTest::shouldBeEmpty()
0064 {
0065     MailCommon::SearchRuleString searchrule;
0066     QVERIFY(searchrule.isEmpty());
0067     searchrule = MailCommon::SearchRuleString(QByteArray(), MailCommon::SearchRule::FuncContains, QStringLiteral("foo"));
0068     QVERIFY(searchrule.isEmpty());
0069     searchrule = MailCommon::SearchRuleString(QByteArray("<tag>"), MailCommon::SearchRule::FuncContains, QString());
0070     QVERIFY(searchrule.isEmpty());
0071 
0072     searchrule = MailCommon::SearchRuleString(QByteArray("<tag>"), MailCommon::SearchRule::FuncContains, QStringLiteral("foo"));
0073     QVERIFY(!searchrule.isEmpty());
0074 }
0075 
0076 QTEST_MAIN(SearchRuleStringTest)
0077 
0078 #include "moc_searchrulestringtest.cpp"