From 1303db8204ff3fdbf8c3fd5a56ee937555e9202e Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 5 Jun 2016 03:24:21 +0100 Subject: [PATCH] Added DURATION property for saving data from a CalendarEventObject. Added the code and unit tests for the DURATION property. --- .../calendarevent/CalendarEvent-Save.cpp | 26 +++++++++++++++++++ source/tests/xestiacalendar_icaleventsave.h | 21 +++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/source/objects/calendarevent/CalendarEvent-Save.cpp b/source/objects/calendarevent/CalendarEvent-Save.cpp index 4dddd89..e6eaaae 100644 --- a/source/objects/calendarevent/CalendarEvent-Save.cpp +++ b/source/objects/calendarevent/CalendarEvent-Save.cpp @@ -621,6 +621,32 @@ void CalendarEventObject::SaveObjectData(string *SaveData){ } + // Process the DURATION value. + + if (DurationData.size() > 0){ + + DataLine += "DURATION"; + + if (DurationDataTokens.size() > 0){ + + DataLine += ";"; + DataLine += DurationDataTokens; + + } + + DataLine += ":"; + DataLine += DurationData; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + // Process the RRULE value. if (RecurranceRuleData.size() > 0){ diff --git a/source/tests/xestiacalendar_icaleventsave.h b/source/tests/xestiacalendar_icaleventsave.h index ae25a55..5686d3c 100644 --- a/source/tests/xestiacalendar_icaleventsave.h +++ b/source/tests/xestiacalendar_icaleventsave.h @@ -22,6 +22,7 @@ TEST(iCalendarSaveEvent, SaveEventTests){ CalendarEventObject TestEvent; CalendarEventObject TestEvent2; + CalendarEventObject TestEvent3; // Load the test event. @@ -197,4 +198,24 @@ TEST(iCalendarSaveEvent, SaveEventTests){ ASSERT_EQ(SaveDataComparison, SaveData); + ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestEvent3.LoadFile("iCalendarEvent-Load3.vcf")); + ASSERT_EQ(CALENDAROBJECTVALID_OK, TestEvent3.ValidBaseObject()); + + SaveData.clear(); + + SaveDataComparison = "BEGIN:VCALENDAR\n" + "VERSION:2.0\n" + "PRODID:-//Xestia//Calendar Unit Testing//KW\n" + "BEGIN:VEVENT\n" + "UID:b3a16392-ad86-4061-be53-c215af2306e1\n" + "DTSTAMP:20160127T111200Z\n" + "DTSTART:20160122T183000Z\n" + "DURATION;TEST=EXAMPLE:PT1H\n" + "END:VEVENT\n" + "END:VCALENDAR"; + + TestEvent3.SaveString(&SaveData); + + ASSERT_EQ(SaveDataComparison, SaveData); + } \ No newline at end of file -- 2.39.5