1 // xestiacalendar_icaltasksave.h - Xestia Calendar iCalendar Task Component Save Unit Tests
3 // (c) 2016 Xestia Software Development.
5 // This file is part of Xestia Calendar.
7 // Xestia Address Book 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 Address Book 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 "../objects/calendartask/CalendarTask.h"
21 TEST(iCalendarSaveTask, SaveTaskTests){
23 CalendarTaskObject TestTask;
24 CalendarTaskObject TestTask2;
26 // Load the test journal information.
28 ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestTask.LoadFile("iCalendarTask-Load1.vcf"));
29 ASSERT_EQ(CALENDAROBJECTVALID_OK, TestTask.ValidBaseObject());
31 ASSERT_EQ(CALENDAROBJECTSAVE_CANNOTOPEN, TestTask.SaveFile("/stupidfilelocation/dontsavehere.ics"));
35 std::string SaveDataComparison = "BEGIN:VCALENDAR\n"
37 "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
40 "DTSTAMP:20160131T160000Z\n"
46 TestTask.SaveString(&SaveData);
48 ASSERT_EQ(SaveDataComparison, SaveData);
50 ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestTask2.LoadFile("iCalendarTask-Load2.vcf"));
51 ASSERT_EQ(CALENDAROBJECTVALID_OK, TestTask2.ValidBaseObject());
55 SaveDataComparison = "BEGIN:VCALENDAR\n"
57 "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
59 "UID;UNIQUEPARAM=CERTAINLY;OKAY=MAYBENOT:b3a16392-ad86-4061-be53-c215af2306e1\n"
60 "DTSTAMP;OTHER=PARAM:20160131T104500Z\n"
61 "CLASS;CHOCOLATE=NONE:PUBLIC\n"
62 "COMPLETED;LYING=NEVER:20160131T110100Z\n"
63 "CREATED;CARAMEL=PLEASE:20160131T080000Z\n"
64 "DESCRIPTION;ALTREP=\"null:nodata\";LANGUAGE=kw;EXAMPLE=TOKEN;MOREDATA=YES:This \n"
65 " is a description of the todo.\n"
66 "DTSTART;VALUE=DATE-TIME;TZID=Europe/Truro;PARAMONE=YES;PARAMTWO=NO:20160131T1\n"
68 "GEO;EXAMPLE=MOOP:20.0;20.0\n"
69 "LAST-MODIFIED;FUTURE=EVEN:20160131T114200Z\n"
70 "LOCATION;ALTREP=\"null:nodata\";LANGUAGE=kw;EXACT=YES:The Crystal Ceiling, Trur\n"
72 "ORGANIZER;CN=ExampleOrganiser;DIR=\"null:nodata\";SENT-BY=\"mailto:organiser.nor\n"
73 " eply@example.com\";LANGUAGE=kw;HAPPY=WEEKS:mailto:organiser@example.com\n"
74 "PERCENT-COMPLETE;DEEP=THOUGHT:42\n"
75 "PRIORITY;STATUS=DEFAULT:5\n"
76 "RECURRENCE-ID;TZID=Europe/Truro;RANGE=THISANDFUTURE;VALUE=DATE;EXAMPLE=DATA:2\n"
83 TestTask2.SaveString(&SaveData);
85 ASSERT_EQ(SaveDataComparison, SaveData);