File indexing completed on 2024-05-12 05:46:54
0001 /* 0002 * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com> 0003 * 0004 * This program is free software: you can redistribute it and/or modify 0005 * it under the terms of the GNU Lesser General Public License as published by 0006 * the Free Software Foundation, either version 3 of the License, or 0007 * (at your option) any later version. 0008 * 0009 * This program is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 * GNU Lesser General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Lesser General Public License 0015 * along with this program. If not, see <https://www.gnu.org/licenses/>. 0016 */ 0017 0018 #include "testcreateddatecompat.h" 0019 #include "icalformat.h" 0020 #include "memorycalendar.h" 0021 0022 #include <iostream> 0023 0024 #include <QTest> 0025 #include <QTimeZone> 0026 0027 //"X-KDE-ICAL-IMPLEMENTATION-VERSION:1.0\n" 0028 0029 const char *const icalFile32 0030 = "BEGIN:VCALENDAR\n" 0031 "PRODID:-//K Desktop Environment//NONSGML libkcal 3.2//EN\n" 0032 "VERSION:2.0\n" 0033 "BEGIN:VEVENT\n" 0034 "DTSTAMP:20031213T204753Z\n" 0035 "ORGANIZER:MAILTO:nobody@nowhere\n" 0036 "CREATED:20031213T204152Z\n" 0037 "UID:uid\n" 0038 "SEQUENCE:0\n" 0039 "LAST-MODIFIED:20031213T204152Z\n" 0040 "SUMMARY:Holladiho\n" 0041 "DTSTART:20031213T071500Z\n" 0042 "END:VEVENT\n" 0043 "END:VCALENDAR\n"; 0044 0045 const char *const icalFile33 0046 = "BEGIN:VCALENDAR\n" 0047 "PRODID:-//K Desktop Environment//NONSGML libkcal 3.2//EN\n" 0048 "VERSION:2.0\n" 0049 "X-KDE-ICAL-IMPLEMENTATION-VERSION:1.0\n" 0050 "BEGIN:VEVENT\n" 0051 "DTSTAMP:20031213T204753Z\n" 0052 "ORGANIZER:MAILTO:nobody@nowhere\n" 0053 "CREATED:20031213T204152Z\n" 0054 "UID:uid\n" 0055 "SEQUENCE:0\n" 0056 "LAST-MODIFIED:20031213T204152Z\n" 0057 "SUMMARY:Holladiho\n" 0058 "DTSTART:20031213T071500Z\n" 0059 "END:VEVENT\n" 0060 "END:VCALENDAR\n"; 0061 0062 void CreatedDateCompatTest::testCompat32() 0063 { 0064 KCalendarCore::MemoryCalendar::Ptr cal(new KCalendarCore::MemoryCalendar(QTimeZone::utc())); 0065 KCalendarCore::ICalFormat format; 0066 QVERIFY(format.fromRawString(cal, QByteArray(icalFile32))); 0067 KCalendarCore::Event::Ptr event = cal->event(QStringLiteral("uid")); 0068 QVERIFY(event); 0069 QCOMPARE(event->created(), 0070 QDateTime(QDate(2003, 12, 13), QTime(20, 47, 53), Qt::UTC)); 0071 } 0072 0073 void CreatedDateCompatTest::testCompat33() 0074 { 0075 KCalendarCore::MemoryCalendar::Ptr cal(new KCalendarCore::MemoryCalendar(QTimeZone::utc())); 0076 KCalendarCore::ICalFormat format; 0077 QVERIFY(format.fromRawString(cal, QByteArray(icalFile33))); 0078 KCalendarCore::Event::Ptr event = cal->event(QStringLiteral("uid")); 0079 QVERIFY(event); 0080 QCOMPARE(event->created(), 0081 QDateTime(QDate(2003, 12, 13), QTime(20, 41, 52), Qt::UTC)); 0082 QVERIFY(!event->customProperties().contains("X-KDE-ICAL-IMPLEMENTATION-VERSION")); 0083 } 0084 0085 QTEST_MAIN(CreatedDateCompatTest)