From b5b06edaa8acb3b10e995864a55a2212aac333dc Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 5 Jun 2016 23:10:22 +0100 Subject: [PATCH] Added CLASS property for saving data from a CalendarJournalObject. Added the code and unit tests for the CLASS property. --- .../calendarjournal/CalendarJournal-Save.cpp | 26 +++++++++++++++++++ source/tests/xestiacalendar_icaljournalsave.h | 22 ++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/source/objects/calendarjournal/CalendarJournal-Save.cpp b/source/objects/calendarjournal/CalendarJournal-Save.cpp index 12578b7..e9651e8 100644 --- a/source/objects/calendarjournal/CalendarJournal-Save.cpp +++ b/source/objects/calendarjournal/CalendarJournal-Save.cpp @@ -106,6 +106,32 @@ void CalendarJournalObject::SaveObjectData(string *SaveData){ } + // Process the CLASS. + + if (ClassData.size() > 0){ + + DataLine += "CLASS"; + + if (ClassDataTokens.size() > 0){ + + DataLine += ";"; + DataLine += ClassDataTokens; + + } + + DataLine += ":"; + DataLine += ClassData; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + *SaveData += "END:VJOURNAL\n"; } \ No newline at end of file diff --git a/source/tests/xestiacalendar_icaljournalsave.h b/source/tests/xestiacalendar_icaljournalsave.h index 9561f55..69fcb2e 100644 --- a/source/tests/xestiacalendar_icaljournalsave.h +++ b/source/tests/xestiacalendar_icaljournalsave.h @@ -21,6 +21,7 @@ TEST(iCalendarSaveJournal, SaveEventTests){ CalendarJournalObject TestJournal; + CalendarJournalObject TestJournal2; // Load the test journal information. @@ -51,4 +52,25 @@ TEST(iCalendarSaveJournal, SaveEventTests){ ASSERT_EQ(SaveDataComparison, SaveData); + SaveData.clear(); + + ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestJournal2.LoadFile("iCalendarJournal-Load2.vcf")); + ASSERT_EQ(CALENDAROBJECTVALID_OK, TestJournal2.ValidBaseObject()); + + TestJournal2.SaveString(&SaveData); + + SaveDataComparison = "BEGIN:VCALENDAR\n" + "VERSION:2.0\n" + "PRODID:-//Xestia//Calendar Unit Testing//KW\n" + "BEGIN:VJOURNAL\n" + "UID;UNIQUEPARAM=CERTAINLY;OKAY=MAYBENOT:b3a16392-ad86-4061-be53-c215af2306c1\n" + "DTSTAMP;OTHER=PARAM:20160131T141500Z\n" + "SUMMARY;ALTREP=\"null:nodata\";LANGUAGE=kw;FAVOURITE=TOFU;NOTLIKE=NONE:A summar\n" + " y of the journal entry.\n" + "CLASS;CHOCOLATE=BAR:PUBLIC\n" + "END:VJOURNAL\n" + "END:VCALENDAR"; + + ASSERT_EQ(SaveDataComparison, SaveData); + } \ No newline at end of file -- 2.39.5