File indexing completed on 2024-04-28 11:33:56

0001 /*
0002   This file is part of the kcalcore library.
0003 
0004   SPDX-FileCopyrightText: 2003 Cornelius Schumacher <schumacher@kde.org>
0005 
0006   SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #include "event.h"
0010 #include "icalformat.h"
0011 #include "todo.h"
0012 
0013 #include <QCommandLineParser>
0014 #include <QCoreApplication>
0015 #include <QDebug>
0016 
0017 using namespace KCalendarCore;
0018 
0019 int main(int argc, char **argv)
0020 {
0021     QCommandLineParser parser;
0022     parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("verbose"), QStringLiteral("Verbose output")));
0023 
0024     QCoreApplication app(argc, argv);
0025     QCoreApplication::setApplicationName(QStringLiteral("testincidence"));
0026     QCoreApplication::setApplicationVersion(QStringLiteral("0.1"));
0027     parser.process(app);
0028 
0029     const bool verbose = parser.isSet(QStringLiteral("verbose"));
0030 
0031     ICalFormat f;
0032 
0033     Event::Ptr event1 = Event::Ptr(new Event);
0034     event1->setSummary(QStringLiteral("Test Event"));
0035     event1->recurrence()->setDaily(2);
0036     event1->recurrence()->setDuration(3);
0037 
0038     QString eventString1 = f.toString(event1.staticCast<Incidence>());
0039     if (verbose) {
0040         qDebug() << "EVENT1 START:" << eventString1 << "EVENT1 END";
0041     }
0042 
0043     event1->setSchedulingID(QStringLiteral("foo"));
0044     Incidence::Ptr event2 = Incidence::Ptr(event1->clone());
0045 
0046     Q_ASSERT(event1->uid() == event2->uid());
0047     Q_ASSERT(event1->schedulingID() == event2->schedulingID());
0048 
0049     QString eventString2 = f.toString(event2.staticCast<Incidence>());
0050     if (verbose) {
0051         qDebug() << "EVENT2 START:" << eventString2 << "EVENT2 END";
0052     }
0053 
0054     if (eventString1 != eventString2) {
0055         qDebug() << "Clone Event FAILED.";
0056     } else {
0057         qDebug() << "Clone Event SUCCEEDED.";
0058     }
0059 
0060     Todo::Ptr todo1 = Todo::Ptr(new Todo);
0061     todo1->setSummary(QStringLiteral("Test todo"));
0062     QString todoString1 = f.toString(todo1.staticCast<Incidence>());
0063     if (verbose) {
0064         qDebug() << "todo1 START:" << todoString1 << "todo1 END";
0065     }
0066 
0067     Incidence::Ptr todo2 = Incidence::Ptr(todo1->clone());
0068     QString todoString2 = f.toString(todo2);
0069     if (verbose) {
0070         qDebug() << "todo2 START:" << todoString2 << "todo2 END";
0071     }
0072 
0073     if (todoString1 != todoString2) {
0074         qDebug() << "Clone Todo FAILED.";
0075     } else {
0076         qDebug() << "Clone Todo SUCCEEDED.";
0077     }
0078 }