File indexing completed on 2024-11-10 04:40:17
0001 /* 0002 SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "imapsettest.h" 0008 #include "private/imapset_p.h" 0009 0010 #include <QTest> 0011 0012 QTEST_MAIN(ImapSetTest) 0013 0014 Q_DECLARE_METATYPE(QList<qint64>) 0015 0016 using namespace Akonadi; 0017 0018 void ImapSetTest::testAddList_data() 0019 { 0020 QTest::addColumn<QList<qint64>>("source"); 0021 QTest::addColumn<ImapInterval::List>("intervals"); 0022 QTest::addColumn<QByteArray>("seqset"); 0023 0024 // empty set 0025 QList<qint64> source; 0026 ImapInterval::List intervals; 0027 QTest::newRow("empty") << source << intervals << QByteArray(); 0028 0029 // single value 0030 source << 4; 0031 intervals << ImapInterval(4, 4); 0032 QTest::newRow("single value") << source << intervals << QByteArray("4"); 0033 0034 // single 2-value interval 0035 source << 5; 0036 intervals.clear(); 0037 intervals << ImapInterval(4, 5); 0038 QTest::newRow("single 2 interval") << source << intervals << QByteArray("4:5"); 0039 0040 // single large interval 0041 source << 6 << 3 << 7 << 2 << 8; 0042 intervals.clear(); 0043 intervals << ImapInterval(2, 8); 0044 QTest::newRow("single 7 interval") << source << intervals << QByteArray("2:8"); 0045 0046 // double interval 0047 source << 12; 0048 intervals << ImapInterval(12, 12); 0049 QTest::newRow("double interval") << source << intervals << QByteArray("2:8,12"); 0050 } 0051 0052 void ImapSetTest::testAddList() 0053 { 0054 QFETCH(QList<qint64>, source); 0055 QFETCH(ImapInterval::List, intervals); 0056 QFETCH(QByteArray, seqset); 0057 0058 ImapSet set; 0059 set.add(source); 0060 ImapInterval::List result = set.intervals(); 0061 QCOMPARE(result, intervals); 0062 QCOMPARE(set.toImapSequenceSet(), seqset); 0063 } 0064 0065 #include "moc_imapsettest.cpp"