Warning, file /pim/mailcommon/src/search/autotests/searchpatterntest.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 Tomas Trnka <tomastrnka@gmx.com>
0003 
0004   SPDX-License-Identifier: GPL-2.0-only
0005 */
0006 
0007 #include "searchpatterntest.h"
0008 #include "../searchpattern.h"
0009 #include <QTest>
0010 
0011 SearchPatternTest::SearchPatternTest(QObject *parent)
0012     : QObject(parent)
0013 {
0014 }
0015 
0016 SearchPatternTest::~SearchPatternTest() = default;
0017 
0018 void SearchPatternTest::shouldRuleRequirePart_data()
0019 {
0020     QTest::addColumn<QByteArray>("field");
0021     QTest::addColumn<MailCommon::SearchRule::RequiredPart>("part");
0022 
0023     // SearchRuleStatus
0024     QTest::newRow("status") << QByteArray("<status>") << MailCommon::SearchRule::Envelope;
0025 
0026     // SearchRuleNumerical
0027     QTest::newRow("numerical") << QByteArray("<size>") << MailCommon::SearchRule::Envelope;
0028 
0029     // SearchRuleDate
0030     QTest::newRow("date") << QByteArray("<date>") << MailCommon::SearchRule::Envelope;
0031 
0032     // SearchRuleString
0033     QTest::newRow("recipients") << QByteArray("<recipients>") << MailCommon::SearchRule::Envelope;
0034     QTest::newRow("tag") << QByteArray("<tag>") << MailCommon::SearchRule::Envelope;
0035     QTest::newRow("subject") << QByteArray("subject") << MailCommon::SearchRule::Envelope;
0036     QTest::newRow("from") << QByteArray("from") << MailCommon::SearchRule::Envelope;
0037     QTest::newRow("sender") << QByteArray("sender") << MailCommon::SearchRule::Envelope;
0038     QTest::newRow("reply-to") << QByteArray("reply-to") << MailCommon::SearchRule::Envelope;
0039     QTest::newRow("to") << QByteArray("to") << MailCommon::SearchRule::Envelope;
0040     QTest::newRow("cc") << QByteArray("cc") << MailCommon::SearchRule::Envelope;
0041     QTest::newRow("bcc") << QByteArray("bcc") << MailCommon::SearchRule::Envelope;
0042     QTest::newRow("in-reply-to") << QByteArray("in-reply-to") << MailCommon::SearchRule::Envelope;
0043     QTest::newRow("message-id") << QByteArray("message-id") << MailCommon::SearchRule::Envelope;
0044     QTest::newRow("references") << QByteArray("references") << MailCommon::SearchRule::Envelope;
0045 
0046     QTest::newRow("any header") << QByteArray("<any header>") << MailCommon::SearchRule::Header;
0047     QTest::newRow("custom header") << QByteArray("X-DummyHeaderName") << MailCommon::SearchRule::Header;
0048     QTest::newRow("Organization") << QByteArray("Organization") << MailCommon::SearchRule::Header;
0049     QTest::newRow("List-Id") << QByteArray("List-Id") << MailCommon::SearchRule::Header;
0050     QTest::newRow("Resent-From") << QByteArray("Resent-From") << MailCommon::SearchRule::Header;
0051     QTest::newRow("X-Loop") << QByteArray("X-Loop") << MailCommon::SearchRule::Header;
0052     QTest::newRow("X-Mailing-List") << QByteArray("X-Mailing-List") << MailCommon::SearchRule::Header;
0053     QTest::newRow("X-Spam-Flag") << QByteArray("X-Spam-Flag") << MailCommon::SearchRule::Header;
0054 
0055     QTest::newRow("<message>") << QByteArray("<message>") << MailCommon::SearchRule::CompleteMessage;
0056     QTest::newRow("<body>") << QByteArray("<body>") << MailCommon::SearchRule::CompleteMessage;
0057 }
0058 
0059 void SearchPatternTest::shouldRuleRequirePart()
0060 {
0061     QFETCH(QByteArray, field);
0062     QFETCH(MailCommon::SearchRule::RequiredPart, part);
0063 
0064     const MailCommon::SearchRule::Ptr rule = MailCommon::SearchRule::createInstance(field, MailCommon::SearchRule::FuncNone, QString());
0065 
0066     QCOMPARE(rule->requiredPart(), part);
0067 }
0068 
0069 QTEST_MAIN(SearchPatternTest)
0070 
0071 #include "moc_searchpatterntest.cpp"