File indexing completed on 2025-01-19 04:51:26

0001 /*
0002   This file is part of KOrganizer.
0003 
0004   SPDX-FileCopyrightText: 2011 Sérgio Martins <iamsergio@gmail.com>
0005 
0006   SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 #include "testkodaymatrix.h"
0009 
0010 #include "../kodaymatrix.h"
0011 
0012 #include <QTest>
0013 QTEST_MAIN(KODayMatrixTest)
0014 
0015 using DateRange = QPair<QDate, QDate>;
0016 
0017 void KODayMatrixTest::testMatrixLimits()
0018 {
0019     QMap<QDate, DateRange> dates;
0020     QLocale::setDefault(QLocale(QStringLiteral("de_DE"))); // week start on Monday
0021     dates.insert(QDate(2011, 1, 1), DateRange(QDate(2010, 12, 27), QDate(2011, 2, 6)));
0022     dates.insert(QDate(2011, 2, 1), DateRange(QDate(2011, 1, 31), QDate(2011, 3, 13)));
0023     dates.insert(QDate(2011, 3, 1), DateRange(QDate(2011, 2, 28), QDate(2011, 4, 10)));
0024     dates.insert(QDate(2011, 4, 1), DateRange(QDate(2011, 3, 28), QDate(2011, 5, 8)));
0025     dates.insert(QDate(2011, 5, 1), DateRange(QDate(2011, 4, 25), QDate(2011, 6, 5)));
0026 
0027     QMapIterator<QDate, DateRange> iterator(dates);
0028     while (iterator.hasNext()) {
0029         iterator.next();
0030         const DateRange range = KODayMatrix::matrixLimits(iterator.key());
0031         // qCDebug(KORGANIZER_LOG) << "Expected is " << iterator.value() << " and got " << range;
0032         QVERIFY(range == iterator.value());
0033     }
0034 }
0035 
0036 #include "moc_testkodaymatrix.cpp"