File indexing completed on 2024-04-21 14:55:09

0001 /*
0002     Copyright 2005 Brad Hards <bradh@kde.org>
0003     Copyright 2007, 2009, 2010, 2011 John Layt <john@layt.net>
0004 
0005     This library is free software; you can redistribute it and/or
0006     modify it under the terms of the GNU Library General Public
0007     License as published by the Free Software Foundation; either
0008     version 2 of the License, or (at your option) any later version.
0009 
0010     This library is distributed in the hope that it will be useful,
0011     but WITHOUT ANY WARRANTY; without even the implied warranty of
0012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013     Library General Public License for more details.
0014 
0015     You should have received a copy of the GNU Library General Public License
0016     along with this library; see the file COPYING.LIB.  If not, write to
0017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018     Boston, MA 02110-1301, USA.
0019 */
0020 
0021 #ifndef KCALENDARTEST_H
0022 #define KCALENDARTEST_H
0023 
0024 #include <QObject>
0025 
0026 #include "klocale.h"
0027 
0028 class QString;
0029 class QDate;
0030 
0031 class KCalendarSystem;
0032 
0033 class KCalendarTest : public QObject
0034 {
0035     Q_OBJECT
0036 
0037 protected:
0038     void testCalendarSystemType(const KCalendarSystem *calendar,
0039                                 KLocale::CalendarSystem system,
0040                                 const QString &type, const QString &label);
0041     void testValid(const KCalendarSystem *calendar, int lowInvalidYear, int highInvalidYear,
0042                    int highInvalidMonth, int highInvalidDay, const QDate &invalidDate);
0043     void testEpoch(const KCalendarSystem *calendar, int y, int m, int d, int jd);
0044     void testEarliestValidDate(const KCalendarSystem *calendar, int y, int m, int d, int jd);
0045     void testLatestValidDate(const KCalendarSystem *calendar, int y, int m, int d, int jd);
0046     void testYear(const KCalendarSystem *calendar, const QDate &date,
0047                   int year, const QString &shortString, const QString &longString);
0048     void testMonth(const KCalendarSystem *calendar, const QDate &date,
0049                    int month, const QString &shortString, const QString &longString);
0050     void testDay(const KCalendarSystem *calendar, const QDate &date,
0051                  int day, const QString &shortString, const QString &longString);
0052     void testEraDate(const KCalendarSystem *calendar, const QDate &date,
0053                      int yearInEra, const QString &shortYearInEraString, const QString &longYearInEraString,
0054                      const QString &shortEraName, const QString &longEraName);
0055     void testYmd(const KCalendarSystem *calendar, int y, int m, int d, int jd);
0056     void testWeekDayName(const KCalendarSystem *calendar, int weekDay, const QDate &date,
0057                          const QString &narrowName, const QString &shortName, const QString &longName);
0058     void testMonthName(const KCalendarSystem *calendar, int month, int year, const QDate &date,
0059                        const QString &narrowName, const QString &shortName, const QString &longName,
0060                        const QString &shortNamePossessive, const QString &longNamePossessive);
0061 
0062     void testStrings(KLocale::DigitSet testDigitSet);
0063     QDate setDayOfYearDate(const KCalendarSystem *calendar, int year, int dayOfYear);
0064     void compareDateDifference(const KCalendarSystem *calendar,
0065                                const QDate &lowDate, const QDate &highDate,
0066                                int yearsDiff, int monthsDiff, int daysDiff);
0067     void compareYearDifference(const KCalendarSystem *calendar,
0068                                const QDate &lowDate, const QDate &highDate,
0069                                int yearsDiff);
0070     void compareMonthDifference(const KCalendarSystem *calendar,
0071                                 const QDate &lowDate, const QDate &highDate,
0072                                 int monthsDiff);
0073     QDate setIsoWeekDate(const KCalendarSystem *calendar, int year, int isoWeek, int dayOfWeek);
0074     QDate setEraDate(const KCalendarSystem *calendar, const QString &era, int yearInEra, int month, int day);
0075     void testRoundTrip(const KCalendarSystem *calendar, bool testFullRange = false);
0076     void compareFormatUnicode(const KCalendarSystem *calendar, const QDate &testDate, const QString &testFormat);
0077 
0078 private Q_SLOTS:
0079     void testTypes();
0080     void testFormatDate();
0081     void testFormatUnicode();
0082     void testReadDate();
0083     void testStringForms();
0084     void testHebrewStrings();
0085     void testIsoWeekDate();
0086     void testDayOfYearDate();
0087     void testDateDifference();
0088     void testFirstLast();
0089     void testEra();
0090     void testGregorianCalendar();
0091     void testHebrew();
0092     void testIndianNational();
0093     void testIslamicCivil();
0094     void testGregorianCalendarBasic();
0095     void testGregorianCalendarYmd();
0096     void testGregorianCalendarSpecialCases();
0097     void testHebrewBasic();
0098     void testHebrewYmd();
0099     void testHebrewCompare();
0100     void testIslamicCivilBasic();
0101     void testIslamicCivilYmd();
0102     void testJalaliBasic();
0103     void testJalaliYmd();
0104     void testJapanese();
0105     void testJapaneseBasic();
0106     void testJapaneseYmd();
0107     void testJapaneseSpecialCases();
0108     void testMinguoBasic();
0109     void testThaiBasic();
0110     void testGregorianAddYears();
0111     void testGregorianAddMonths();
0112     void testGregorianAddDays();
0113     void testGregorianDaysInYear();
0114     void testGregorianDaysInMonth();
0115     void testGregorianDayOfYear();
0116     void testGregorianDayOfWeek();
0117     void testGregorianIsLeapYear();
0118     void testKLocalizedDate();
0119     void testWeekNumberSystem();
0120 };
0121 
0122 #endif