From c8b7a9ab635283c6fca4ddcdbf9905919096423a Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Tue, 7 Jun 2016 23:30:13 +0100 Subject: [PATCH] Added DURATION property for saving data from a CalendarTaskObject. Added the code and unit tests for the DURATION property. --- .../calendartask/CalendarTask-Save.cpp | 26 +++++++++++++++++++ source/tests/xestiacalendar_icaltasksave.h | 23 ++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/source/objects/calendartask/CalendarTask-Save.cpp b/source/objects/calendartask/CalendarTask-Save.cpp index a619e99..f8ae474 100644 --- a/source/objects/calendartask/CalendarTask-Save.cpp +++ b/source/objects/calendartask/CalendarTask-Save.cpp @@ -412,6 +412,32 @@ void CalendarTaskObject::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 PRIORITY value. if (PriorityData > -1 && PriorityData < 10){ diff --git a/source/tests/xestiacalendar_icaltasksave.h b/source/tests/xestiacalendar_icaltasksave.h index 84e554a..356fd4d 100644 --- a/source/tests/xestiacalendar_icaltasksave.h +++ b/source/tests/xestiacalendar_icaltasksave.h @@ -22,6 +22,7 @@ TEST(iCalendarSaveTask, SaveTaskTests){ CalendarTaskObject TestTask; CalendarTaskObject TestTask2; + CalendarTaskObject TestTask3; // Load the test journal information. @@ -186,4 +187,26 @@ TEST(iCalendarSaveTask, SaveTaskTests){ ASSERT_EQ(SaveDataComparison, SaveData); + // Third task file. + + SaveDataComparison = "BEGIN:VCALENDAR\n" + "VERSION:2.0\n" + "PRODID:-//Xestia//Calendar Unit Testing//KW\n" + "BEGIN:VTODO\n" + "UID:b3a16392-ad86-4061-be53-c215af2306df\n" + "DTSTAMP;OTHER=PARAM:20160131T104500Z\n" + "DTSTART:20160131T103000Z\n" + "DURATION;TEST=YES:PT15M\n" + "END:VTODO\n" + "END:VCALENDAR"; + + ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestTask3.LoadFile("iCalendarTask-Load3.vcf")); + ASSERT_EQ(CALENDAROBJECTVALID_OK, TestTask3.ValidBaseObject()); + + SaveData.clear(); + + TestTask3.SaveString(&SaveData); + + ASSERT_EQ(SaveDataComparison, SaveData); + } \ No newline at end of file -- 2.39.5