// xestiacalendar_icaltimezonesave.h - Xestia Calendar iCalendar Timezone Component Save Unit Tests
//
// (c) 2016-2017 Xestia Software Development.
//
// This file is part of Xestia Calendar.
//
// 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 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.
//
// You should have received a copy of the GNU General Public License along
// with Xestia Calendar. If not, see
#include "CalendarTimezone.h"
#include
class iCalendarTimezoneSaveTests : public ::testing::Test
{
private:
virtual void SetUp()
{
}
virtual void TearDown()
{
}
};
TEST_F(iCalendarTimezoneSaveTests, SaveTimezoneTests){
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(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);
}