X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Ftests%2Fxestiacalendar_icaltimezonesave.h;h=2de91fd9853a182f4a581e7f5dd46fc50364b9aa;hb=0c16b6458c0fdc03b94288c17d7a685b95f122fc;hp=1cfd595bc23eb0952e1cbdb078b702d86d1a0cba;hpb=c4b1b7959bcf3a87e4695c53144186bc317fc8c4;p=xestiacalendar%2F.git diff --git a/source/tests/xestiacalendar_icaltimezonesave.h b/source/tests/xestiacalendar_icaltimezonesave.h index 1cfd595..2de91fd 100644 --- a/source/tests/xestiacalendar_icaltimezonesave.h +++ b/source/tests/xestiacalendar_icaltimezonesave.h @@ -1,14 +1,14 @@ // xestiacalendar_icaltimezonesave.h - Xestia Calendar iCalendar Timezone Component Save Unit Tests // -// (c) 2016 Xestia Software Development. +// (c) 2016-2017 Xestia Software Development. // // This file is part of Xestia Calendar. // -// Xestia Address Book is free software: you can redistribute it and/or modify +// Xestia Calendar is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by the // Free Software Foundation, version 3 of the license. // -// Xestia Address Book is distributed in the hope that it will be useful, +// Xestia Calendar is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. @@ -20,13 +20,111 @@ TEST(iCalendarSaveTimezone, SaveTimezoneTests){ - CalendarTimezoneObject TestTimezone; + CalendarTimezoneObject testTimezone; + CalendarTimezoneObject testTimezone2; // Load the first test timezone. - ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestTimezone.LoadFile("iCalendarTimezone-Load1.vcf")); - ASSERT_EQ(CALENDAROBJECTVALID_OK, TestTimezone.ValidBaseObject()); + ASSERT_EQ(CALENDAROBJECTLOAD_OK, testTimezone.LoadFile("iCalendarTimezone-Load1.vcf")); + ASSERT_EQ(CALENDAROBJECTVALID_OK, testTimezone.ValidBaseObject()); + ASSERT_EQ(CALENDAROBJECTSAVE_CANNOTOPEN, testTimezone.SaveFile("/stupidfilelocation/dontsavehere.ics")); + // Save the data to a string and compare the data. + + // First contact file. + + std::string saveDataComparison = "BEGIN:VCALENDAR\n" + "VERSION:2.0\n" + "PRODID:-//Xestia//Calendar Unit Testing//KW\n" + "BEGIN:VTIMEZONE\n" + "TZID:Example/Starrgazy\n" + "END:VTIMEZONE\n" + "END:VCALENDAR"; + + std::string saveData; + testTimezone.SaveString(&saveData); + + ASSERT_EQ(saveDataComparison, saveData); + + // Process the second calendar item. + + ASSERT_EQ(CALENDAROBJECTLOAD_OK, testTimezone2.LoadFile("iCalendarTimezone-Load2.vcf")); + ASSERT_EQ(CALENDAROBJECTVALID_OK, testTimezone2.ValidBaseObject()); + + saveData.clear(); + + testTimezone2.SaveString(&saveData); + + saveDataComparison = "BEGIN:VCALENDAR\n" + "VERSION:2.0\n" + "PRODID:-//Xestia//Calendar Unit Testing//KW\n" + "BEGIN:VTIMEZONE\n" + "TZID;OTHER=PARAM:Example/Starrgazy\n" + "LAST-MODIFIED;FUTURE=ODD:20160203T200700Z\n" + "TZURL;URL=YES:http://www.example.com/\n" + "BEGIN:STANDARD\n" + "DTSTART:20160204T020000\n" + "TZOFFSETFROM:-0500\n" + "TZOFFSETTO:-0400\n" + "END:STANDARD\n" + "BEGIN:STANDARD\n" + "DTSTART;MEEP=MOO:20160205T020000\n" + "TZOFFSETFROM;LETS=GO:-0500\n" + "TZOFFSETTO;EXAMPLE=DATA:-0400\n" + "END:STANDARD\n" + "BEGIN:STANDARD\n" + "DTSTART;MEEP=MOO:20160206T020000\n" + "TZOFFSETFROM;LETS=GO:-0500\n" + "TZOFFSETTO;EXAMPLE=DATA:-0400\n" + "RRULE;YAK=YES:FREQ=DAILY;COUNT=10\n" + "COMMENT;ALTREP=\"null:nodata\";LANGUAGE=kw;YO=YOYOS:Example timezone comment.\n" + "RDATE;VALUE=DATE;TZID=Europe/Truro;BEEP=BOOP:20160205,20160207,20160216,20160\n" + " 305\n" + "TZNAME;LANGUAGE=en;NOPE=YES:Example Timezone Name 1\n" + "X-MOO:Meep\n" + "X-MOO:Moop\n" + "X-MOO;MEEP=YIKES:Zaap\n" + "X-ITEM:Fork\n" + "X-ITEM:Spoon\n" + "X-ITEM;DIRTY=NO:Knife\n" + "X-NOPE:1\n" + "X-NOPE:2\n" + "X-NOPE;LONG=YES:3\n" + "END:STANDARD\n" + "BEGIN:DAYLIGHT\n" + "DTSTART:20160204T020000\n" + "TZOFFSETFROM:-0500\n" + "TZOFFSETTO:-0400\n" + "END:DAYLIGHT\n" + "BEGIN:DAYLIGHT\n" + "DTSTART;MEEP=MOO:20160205T020000\n" + "TZOFFSETFROM;LETS=GO:-0500\n" + "TZOFFSETTO;EXAMPLE=DATA:-0400\n" + "END:DAYLIGHT\n" + "BEGIN:DAYLIGHT\n" + "DTSTART;MEEP=MOO:20160206T020000\n" + "TZOFFSETFROM;LETS=GO:-0500\n" + "TZOFFSETTO;EXAMPLE=DATA:-0400\n" + "RRULE;YAK=YES:FREQ=DAILY;COUNT=10\n" + "COMMENT;ALTREP=\"null:nodata\";LANGUAGE=kw;YO=YOYOS:Example timezone comment.\n" + "RDATE;VALUE=DATE;TZID=Europe/Truro;BEEP=BOOP:20160205,20160207,20160216,20160\n" + " 305\n" + "TZNAME;LANGUAGE=en;NOPE=YES:Example Timezone Name 1\n" + "X-MOO:Meep\n" + "X-MOO:Moop\n" + "X-MOO;MEEP=YIKES:Zaap\n" + "X-ITEM:Fork\n" + "X-ITEM:Spoon\n" + "X-ITEM;DIRTY=NO:Knife\n" + "X-NOPE:1\n" + "X-NOPE:2\n" + "X-NOPE;LONG=YES:3\n" + "END:DAYLIGHT\n" + "END:VTIMEZONE\n" + "END:VCALENDAR"; + + ASSERT_EQ(saveDataComparison, saveData); + } \ No newline at end of file