1 // xestiacalendar_icaltimezonesave.h - Xestia Calendar iCalendar Timezone Component Save Unit Tests
3 // (c) 2016-2017 Xestia Software Development.
5 // This file is part of Xestia Calendar.
7 // Xestia Calendar is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Calendar is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
19 #include "CalendarTimezone.h"
20 #include <gtest/gtest.h>
22 class iCalendarTimezoneSaveTests : public ::testing::Test
29 virtual void TearDown()
34 TEST_F(iCalendarTimezoneSaveTests, SaveTimezoneTests){
36 CalendarTimezoneObject testTimezone;
37 CalendarTimezoneObject testTimezone2;
39 // Load the first test timezone.
41 ASSERT_EQ(CALENDAROBJECTLOAD_OK, testTimezone.LoadFile("iCalendarTimezone-Load1.vcf"));
42 ASSERT_EQ(CALENDAROBJECTVALID_OK, testTimezone.ValidBaseObject());
44 ASSERT_EQ(CALENDAROBJECTSAVE_CANNOTOPEN, testTimezone.SaveFile("/stupidfilelocation/dontsavehere.ics"));
46 // Save the data to a string and compare the data.
48 // First contact file.
50 std::string saveDataComparison = "BEGIN:VCALENDAR\n"
52 "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
54 "TZID:Example/Starrgazy\n"
60 testTimezone.SaveString(&saveData);
62 ASSERT_EQ(saveDataComparison, saveData);
64 // Process the second calendar item.
66 ASSERT_EQ(CALENDAROBJECTLOAD_OK, testTimezone2.LoadFile("iCalendarTimezone-Load2.vcf"));
67 ASSERT_EQ(CALENDAROBJECTVALID_OK, testTimezone2.ValidBaseObject());
71 testTimezone2.SaveString(&saveData);
73 saveDataComparison = "BEGIN:VCALENDAR\n"
75 "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
77 "TZID;OTHER=PARAM:Example/Starrgazy\n"
78 "LAST-MODIFIED;FUTURE=ODD:20160203T200700Z\n"
79 "TZURL;URL=YES:http://www.example.com/\n"
81 "DTSTART:20160204T020000\n"
82 "TZOFFSETFROM:-0500\n"
86 "DTSTART;MEEP=MOO:20160205T020000\n"
87 "TZOFFSETFROM;LETS=GO:-0500\n"
88 "TZOFFSETTO;EXAMPLE=DATA:-0400\n"
91 "DTSTART;MEEP=MOO:20160206T020000\n"
92 "TZOFFSETFROM;LETS=GO:-0500\n"
93 "TZOFFSETTO;EXAMPLE=DATA:-0400\n"
94 "RRULE;YAK=YES:FREQ=DAILY;COUNT=10\n"
95 "COMMENT;ALTREP=\"null:nodata\";LANGUAGE=kw;YO=YOYOS:Example timezone comment.\n"
96 "RDATE;VALUE=DATE;TZID=Europe/Truro;BEEP=BOOP:20160205,20160207,20160216,20160\n"
98 "TZNAME;LANGUAGE=en;NOPE=YES:Example Timezone Name 1\n"
101 "X-MOO;MEEP=YIKES:Zaap\n"
104 "X-ITEM;DIRTY=NO:Knife\n"
107 "X-NOPE;LONG=YES:3\n"
110 "DTSTART:20160204T020000\n"
111 "TZOFFSETFROM:-0500\n"
115 "DTSTART;MEEP=MOO:20160205T020000\n"
116 "TZOFFSETFROM;LETS=GO:-0500\n"
117 "TZOFFSETTO;EXAMPLE=DATA:-0400\n"
120 "DTSTART;MEEP=MOO:20160206T020000\n"
121 "TZOFFSETFROM;LETS=GO:-0500\n"
122 "TZOFFSETTO;EXAMPLE=DATA:-0400\n"
123 "RRULE;YAK=YES:FREQ=DAILY;COUNT=10\n"
124 "COMMENT;ALTREP=\"null:nodata\";LANGUAGE=kw;YO=YOYOS:Example timezone comment.\n"
125 "RDATE;VALUE=DATE;TZID=Europe/Truro;BEEP=BOOP:20160205,20160207,20160216,20160\n"
127 "TZNAME;LANGUAGE=en;NOPE=YES:Example Timezone Name 1\n"
130 "X-MOO;MEEP=YIKES:Zaap\n"
133 "X-ITEM;DIRTY=NO:Knife\n"
136 "X-NOPE;LONG=YES:3\n"
141 ASSERT_EQ(saveDataComparison, saveData);