From: Steve Brokenshire Date: Mon, 6 Jun 2016 20:40:36 +0000 (+0100) Subject: Added CLASS property for saving data from a CalendarTaskObject. X-Git-Tag: release-0.02~172 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=513a6239422f911603c8c8575a33fd0365744db4;p=xestiacalendar%2F.git Added CLASS property for saving data from a CalendarTaskObject. Added the code and unit tests for the CLASS property. --- diff --git a/source/objects/calendartask/CalendarTask-Save.cpp b/source/objects/calendartask/CalendarTask-Save.cpp index 89da0ac..5e64ecc 100644 --- a/source/objects/calendartask/CalendarTask-Save.cpp +++ b/source/objects/calendartask/CalendarTask-Save.cpp @@ -65,6 +65,34 @@ void CalendarTaskObject::SaveObjectData(string *SaveData){ } + // Process the CLASS value. + + 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:VTODO\n"; } \ No newline at end of file diff --git a/source/tests/xestiacalendar_icaltasksave.h b/source/tests/xestiacalendar_icaltasksave.h index 7906a17..8ea88e4 100644 --- a/source/tests/xestiacalendar_icaltasksave.h +++ b/source/tests/xestiacalendar_icaltasksave.h @@ -21,6 +21,7 @@ TEST(iCalendarSaveTask, SaveTaskTests){ CalendarTaskObject TestTask; + CalendarTaskObject TestTask2; // Load the test journal information. @@ -45,5 +46,26 @@ TEST(iCalendarSaveTask, SaveTaskTests){ TestTask.SaveString(&SaveData); ASSERT_EQ(SaveDataComparison, SaveData); + + ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestTask2.LoadFile("iCalendarTask-Load2.vcf")); + ASSERT_EQ(CALENDAROBJECTVALID_OK, TestTask2.ValidBaseObject()); + + // Second task file. + + SaveDataComparison = "BEGIN:VCALENDAR\n" + "VERSION:2.0\n" + "PRODID:-//Xestia//Calendar Unit Testing//KW\n" + "BEGIN:VTODO\n" + "UID;UNIQUEPARAM=CERTAINLY;OKAY=MAYBENOT:b3a16392-ad86-4061-be53-c215af2306e1\n" + "DTSTAMP;OTHER=PARAM:20160131T104500Z\n" + "CLASS;CHOCOLATE=NONE:PUBLIC\n" + "END:VTODO\n" + "END:VCALENDAR"; + + SaveData.clear(); + TestTask2.SaveString(&SaveData); + + ASSERT_EQ(SaveDataComparison, SaveData); + } \ No newline at end of file