File indexing completed on 2024-12-22 05:00:49
0001 /* 0002 SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "archivemailagentutiltest.h" 0008 #include "archivemailagentutil.h" 0009 #include <QTest> 0010 QTEST_GUILESS_MAIN(ArchiveMailAgentUtilTest) 0011 ArchiveMailAgentUtilTest::ArchiveMailAgentUtilTest(QObject *parent) 0012 : QObject{parent} 0013 { 0014 } 0015 0016 void ArchiveMailAgentUtilTest::shouldTestTimeIsInRange() 0017 { 0018 QFETCH(QList<int>, range); 0019 QFETCH(QTime, time); 0020 QFETCH(bool, result); 0021 QCOMPARE(ArchiveMailAgentUtil::timeIsInRange(range, time), result); 0022 } 0023 0024 void ArchiveMailAgentUtilTest::shouldTestTimeIsInRange_data() 0025 { 0026 QTest::addColumn<QList<int>>("range"); 0027 QTest::addColumn<QTime>("time"); 0028 QTest::addColumn<bool>("result"); 0029 0030 { 0031 // 5h30m1 0032 const QTime t(5, 30, 1); 0033 // between 4h and 8h 0034 const QList<int> interval{4, 8}; 0035 QTest::newRow("test1") << interval << t << true; 0036 } 0037 { 0038 // 5h30m1 0039 const QTime t(5, 30, 1); 0040 // between 12h and 15h 0041 const QList<int> interval{12, 15}; 0042 QTest::newRow("test2") << interval << t << false; 0043 } 0044 { 0045 // 5h30m1 0046 const QTime t(5, 30, 1); 0047 // between 5h and 6h 0048 const QList<int> interval{5, 6}; 0049 QTest::newRow("test3") << interval << t << true; 0050 } 0051 { 0052 // 23h30m1 0053 const QTime t(23, 30, 1); 0054 // between 22h and 4h 0055 const QList<int> interval{22, 4}; 0056 QTest::newRow("test4") << interval << t << true; 0057 } 0058 { 0059 // 20h30m1 0060 const QTime t(20, 30, 1); 0061 // between 22h and 4h 0062 const QList<int> interval{22, 4}; 0063 QTest::newRow("test5") << interval << t << false; 0064 } 0065 { 0066 // 1h30m1 0067 const QTime t(1, 30, 1); 0068 // between 22h and 4h 0069 const QList<int> interval{22, 4}; 0070 QTest::newRow("test6") << interval << t << true; 0071 } 0072 { 0073 // 5h30m1 0074 const QTime t(5, 30, 1); 0075 // between 22h and 4h 0076 const QList<int> interval{22, 4}; 0077 QTest::newRow("test7") << interval << t << false; 0078 } 0079 { 0080 // 5h30m1 0081 const QTime t(5, 30, 1); 0082 // between 22h and 21h 0083 const QList<int> interval{22, 21}; 0084 QTest::newRow("test8") << interval << t << true; 0085 } 0086 { 0087 // 21h30m1 0088 const QTime t(21, 30, 1); 0089 // between 22h and 21h 0090 const QList<int> interval{22, 20}; 0091 QTest::newRow("test9") << interval << t << false; 0092 } 0093 } 0094 0095 #include "moc_archivemailagentutiltest.cpp"