File indexing completed on 2024-04-14 03:50:34

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 <QDebug>
0014 #include <QTest>
0015 
0016 using namespace KCalendarCore;
0017 
0018 class IncidencesTest : public QObject
0019 {
0020     Q_OBJECT
0021 private Q_SLOTS:
0022     void testClone()
0023     {
0024         ICalFormat f;
0025 
0026         Event::Ptr event1 = Event::Ptr(new Event);
0027         event1->setSummary(QStringLiteral("Test Event"));
0028         event1->recurrence()->setDaily(2);
0029         event1->recurrence()->setDuration(3);
0030         event1->setSchedulingID(QStringLiteral("foo"));
0031         QString eventString1 = f.toString(event1.staticCast<Incidence>());
0032 
0033         Incidence::Ptr event2 = Incidence::Ptr(event1->clone());
0034         QCOMPARE(event1->uid(), event2->uid());
0035         QCOMPARE(event1->schedulingID(), event2->schedulingID());
0036 
0037         QString eventString2 = f.toString(event2.staticCast<Incidence>());
0038         QCOMPARE(eventString1, eventString2);
0039 
0040         Todo::Ptr todo1 = Todo::Ptr(new Todo);
0041         todo1->setSummary(QStringLiteral("Test todo"));
0042         QString todoString1 = f.toString(todo1.staticCast<Incidence>());
0043 
0044         Incidence::Ptr todo2 = Incidence::Ptr(todo1->clone());
0045         QString todoString2 = f.toString(todo2);
0046         QCOMPARE(todoString1, todoString2);
0047     }
0048 };
0049 
0050 QTEST_APPLESS_MAIN(IncidencesTest)
0051 
0052 #include "incidencestest.moc"