From b316bf0e7fd76a92694e87f04a74ff58a2e454a2 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Tue, 31 May 2016 20:06:12 +0100 Subject: [PATCH] Added code and unit tests for saving CLASS in CalendarEventObject. --- .../calendarevent/CalendarEvent-Save.cpp | 31 +++++++++++++++++-- source/tests/xestiacalendar_icaleventsave.h | 25 +++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/source/objects/calendarevent/CalendarEvent-Save.cpp b/source/objects/calendarevent/CalendarEvent-Save.cpp index 911947b..a1d743c 100644 --- a/source/objects/calendarevent/CalendarEvent-Save.cpp +++ b/source/objects/calendarevent/CalendarEvent-Save.cpp @@ -9,9 +9,6 @@ void CalendarEventObject::SaveObjectData(string *SaveData){ *SaveData += "BEGIN:VEVENT\n"; - // TODO: Replace SaveData with DataLine, DataLineProcessed - // and use the new OutputText function. - // Process the UID. if (UniqueID.size() > 0){ @@ -187,6 +184,34 @@ void CalendarEventObject::SaveObjectData(string *SaveData){ DataLineProcessed.clear(); } + + // Process the CLASS. + + if (ClassData.size() > 0){ + + if (ClassDataTokens.size() > 0){ + + DataLine += "CLASS;"; + DataLine += ClassDataTokens; + + } else { + + DataLine += "CLASS"; + + } + + DataLine += ":"; + DataLine += ClassData; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } *SaveData += "END:VEVENT\n"; diff --git a/source/tests/xestiacalendar_icaleventsave.h b/source/tests/xestiacalendar_icaleventsave.h index bd00909..1ed9ae6 100644 --- a/source/tests/xestiacalendar_icaleventsave.h +++ b/source/tests/xestiacalendar_icaleventsave.h @@ -21,6 +21,7 @@ TEST(iCalendarSaveEvent, SaveEventTests){ CalendarEventObject TestEvent; + CalendarEventObject TestEvent2; // Load the test event. @@ -58,5 +59,29 @@ TEST(iCalendarSaveEvent, SaveEventTests){ TestEvent.SaveString(&SaveData); ASSERT_EQ(SaveDataComparison, SaveData); + + // Process the second calendar item. + + ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestEvent2.LoadFile("iCalendarEvent-Load2.vcf")); + ASSERT_EQ(CALENDAROBJECTVALID_OK, TestEvent2.ValidBaseObject()); + + SaveDataComparison = "BEGIN:VCARD\n" + "VERSION:2.0\n" + "PRODID:-//Xestia//Calendar Unit Testing//KW\n" + "BEGIN:VEVENT\n" + "UID;UNIQUEPARAM=CERTAINLY;OKAY=MAYBENOT:b3a16392-ad86-4061-be53-c215af2306e0\n" + "DTSTAMP;OTHER=PARAM:20160122T124100Z\n" + "DTSTART;VALUE=DATE-TIME;TZID=Europe/Truro;PARAMONE=YES;PARAMTWO=NO:20160122T1\n" + " 83000Z\n" + "DTEND;VALUE=DATE-TIME;TZID=Europe/Truro;PARAMTHREE=NO;PARAMFOUR=YES:20160124\n" + " T183000Z\n" + "SUMMARY;ALTREP="null:nodata";LANGUAGE=kw;FAVOURITE=TOFU;NOTLIKE=NONE:A summa\n" + " ry of the event.\n" + "END:VEVENT\n" + "END:VCARD"; + + TestEvent2.SaveString(&SaveData); + + ASSERT_EQ(SaveDataComparison, SaveData); } \ No newline at end of file -- 2.39.5