1 // xestiacalendar_icaltasksave.h - Xestia Calendar iCalendar Task 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 "../objects/calendartask/CalendarTask.h"
21 TEST(iCalendarSaveTask, SaveTaskTests){
23 CalendarTaskObject testTask;
24 CalendarTaskObject testTask2;
25 CalendarTaskObject testTask3;
27 // Load the test journal information.
29 ASSERT_EQ(CALENDAROBJECTLOAD_OK, testTask.LoadFile("iCalendarTask-Load1.vcf"));
30 ASSERT_EQ(CALENDAROBJECTVALID_OK, testTask.ValidBaseObject());
32 ASSERT_EQ(CALENDAROBJECTSAVE_CANNOTOPEN, testTask.SaveFile("/stupidfilelocation/dontsavehere.ics"));
36 std::string saveDataComparison = "BEGIN:VCALENDAR\n"
38 "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
41 "DTSTAMP:20160131T160000Z\n"
47 testTask.SaveString(&saveData);
49 ASSERT_EQ(saveDataComparison, saveData);
51 ASSERT_EQ(CALENDAROBJECTLOAD_OK, testTask2.LoadFile("iCalendarTask-Load2.vcf"));
52 ASSERT_EQ(CALENDAROBJECTVALID_OK, testTask2.ValidBaseObject());
56 saveDataComparison = "BEGIN:VCALENDAR\n"
58 "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
60 "UID;UNIQUEPARAM=CERTAINLY;OKAY=MAYBENOT:b3a16392-ad86-4061-be53-c215af2306e1\n"
61 "DTSTAMP;OTHER=PARAM:20160131T104500Z\n"
62 "CLASS;CHOCOLATE=NONE:PUBLIC\n"
63 "COMPLETED;LYING=NEVER:20160131T110100Z\n"
64 "CREATED;CARAMEL=PLEASE:20160131T080000Z\n"
65 "DESCRIPTION;ALTREP=\"null:nodata\";LANGUAGE=kw;EXAMPLE=TOKEN;MOREDATA=YES:This \n"
66 " is a description of the todo.\n"
67 "DTSTART;VALUE=DATE-TIME;TZID=Europe/Truro;PARAMONE=YES;PARAMTWO=NO:20160131T1\n"
69 "GEO;EXAMPLE=MOOP:20.0;20.0\n"
70 "LAST-MODIFIED;FUTURE=EVEN:20160131T114200Z\n"
71 "LOCATION;ALTREP=\"null:nodata\";LANGUAGE=kw;EXACT=YES:The Crystal Ceiling, Trur\n"
73 "ORGANIZER;CN=ExampleOrganiser;DIR=\"null:nodata\";SENT-BY=\"mailto:organiser.nor\n"
74 " eply@example.com\";LANGUAGE=kw;HAPPY=WEEKS:mailto:organiser@example.com\n"
75 "PERCENT-COMPLETE;DEEP=THOUGHT:42\n"
76 "PRIORITY;STATUS=DEFAULT:5\n"
77 "RECURRENCE-ID;TZID=Europe/Truro;RANGE=THISANDFUTURE;VALUE=DATE;EXAMPLE=DATA:2\n"
79 "SEQUENCE;TEST=YAY:3\n"
80 "STATUS;LANGUAGE=kw;FAVOURITE=BEANS;NOTLIKE=UNKNOWN:2.0;Success\n"
81 "SUMMARY;ALTREP=\"null:nodata\";LANGUAGE=kw;FAVOURITE=TOFU;NOTLIKE=NONE:A summar\n"
83 "URL;EXTERNAL=YES:http://www.example.com/\n"
84 "RRULE;TEST=DATA:FREQ=DAILY;COUNT=10\n"
85 "DUE;TZID=Europe/Truro;VALUE=DATE-TIME;TEST=YES:20160131T150000Z\n"
86 "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/\n"
87 "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/page2.htm\n"
89 "ATTACH;FMTTYPE=text/plain;VALUE=BINARY;ENCODING=BASE64;STUPID=EXAMPLE:VGhpcyB\n"
90 " pcyBhbiBleGFtcGxlIGZpbGU=\n"
91 "ATTENDEE:Attendee One\n"
92 "ATTENDEE;DELEGATED-FROM=\"mailto:delegated.from@example.com\";DELEGATED-TO=\"mai\n"
93 " lto:delegated.to@example.com\";ROLE=CHAIR;RSVP=TRUE:Attendee Two\n"
94 "ATTENDEE;DIR=\"null:nodata\";SENT-BY=\"mailto:sent.by@example.com\";CN=\"Attendee \n"
95 " The Third\";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED;LANGUAGE=kw;EXAMPLE=DATA:Atte\n"
97 "CATEGORIES:CATEGORY ONE, CATEGORY TWO\n"
98 "CATEGORIES;LANGUAGE=en:CATEGORY THREE, CATEGORY FOUR\n"
99 "CATEGORIES;LANGUAGE=en-GB;SAMPLE=TOKEN:CATEGORY FIVE, CATEGORY SIX, CATEGORY \n"
101 "COMMENT:This is the first comment.\n"
102 "COMMENT;ALTREP=\"null:nodata\";LANGUAGE=en:This is the second comment.\n"
103 "COMMENT;ZEBRAS=YES:This is the third comment.\n"
104 "CONTACT:First Contact\n"
105 "CONTACT;ALTREP=\"null:nodata\";LANGUAGE=en-GB:Second Contact\n"
106 "CONTACT;ZEBRAS=NO:Third Contact\n"
107 "EXDATE:20160125T120000Z\n"
108 "EXDATE;TZID=Europe/Truro;VALUE=DATE-TIME:20160125T130000Z\n"
109 "EXDATE;ZOOP=ZIPPO:20160125T133000Z\n"
110 "REQUEST-STATUS:2.0;Success\n"
111 "REQUEST-STATUS;LANGUAGE=en:3.42;Really big irrecoverable error caused by the \n"
113 "REQUEST-STATUS;USER=MISSING:3.7;Invalid calendar user\n"
114 "RELATED-TO:person.1@example.com\n"
115 "RELATED-TO;RELTYPE=PARENT:person.2@example.com\n"
116 "RELATED-TO;SCHOOL=MEETING:person.3@example.com\n"
117 "RESOURCES:DMAC RECEIVER\n"
118 "RESOURCES;LANGUAGE=en:PAL-I TELEVISION SET\n"
119 "RESOURCES;ALTREP=\"null:nodata\";STATUS=BROKEN:PAL/SECAM VCR\n"
121 "RDATE;VALUE=DATE;TZID=Europe/Truro:20160121\n"
122 "RDATE;ZILCH=DATA:20160520\n"
124 "ACTION;FUNKY=SOUNDS:AUDIO\n"
125 "TRIGGER;RELATED=END;VALUE=DATE-TIME;PUSH=BUTTON:20160220T160000Z\n"
126 "DURATION;FLYING=NO:PT5H\n"
127 "REPEAT;NEVER=SLEEP:PT5M\n"
128 "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/\n"
129 "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/page2.htm\n"
131 "ATTACH;FMTTYPE=text/plain;VALUE=BINARY;ENCODING=BASE64;STUPID=EXAMPLE:VGhpcyB\n"
132 " pcyBhbiBleGFtcGxlIGZpbGU=\n"
133 "X-EXAMPLE1;YAY=YES:Example Data 1\n"
134 "X-EXAMPLE2;NOPE=YEP:Example Data 2\n"
135 "X-EXAMPLE3;WORLD=NO:Example Data 3\n"
138 "ACTION;FLASHING=LIGHTS:DISPLAY\n"
139 "TRIGGER;RELATED=END;VALUE=DATE-TIME;PUSH=BUTTON:20160230T110000Z\n"
140 "DURATION;FLYING=YES:PT7H\n"
141 "DESCRIPTION;ALTREP=\"null:nodata\";LANGUAGE=kw;TERRIBLE=TOKEN:This is the secon\n"
143 "REPEAT;SLEEP=ALWAYS:PT3M\n"
144 "X-EXAMPLE1;YAY=YES:Example Data 1\n"
145 "X-EXAMPLE2;NOPE=YEP:Example Data 2\n"
146 "X-EXAMPLE3;WORLD=NO:Example Data 3\n"
149 "ACTION;FLASHING=LIGHTS:EMAIL\n"
150 "TRIGGER;RELATED=END;VALUE=DATE-TIME;PUSH=BUTTON:20160230T120000Z\n"
151 "DURATION;FLYING=YES:PT7H\n"
152 "DESCRIPTION;ALTREP=\"null:nodata\";LANGUAGE=kw;TERRIBLE=TOKEN:This is the third\n"
154 "SUMMARY;ALTREP=\"null:nodata\";LANGUAGE=en;MEEP=MOOP:This is the summary of the\n"
156 "REPEAT;SLEEP=ALWAYS:PT3M\n"
157 "ATTENDEE:Attendee One\n"
158 "ATTENDEE;DELEGATED-FROM=\"mailto:delegated.from@example.com\";DELEGATED-TO=\"mai\n"
159 " lto:delegated.to@example.com\";ROLE=CHAIR;RSVP=TRUE:Attendee Two\n"
160 "ATTENDEE;DIR=\"null:nodata\";SENT-BY=\"mailto:sent.by@example.com\";CN=\"Attendee \n"
161 " The Third\";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED;LANGUAGE=kw;EXAMPLE=DATA:Atte\n"
163 "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/\n"
164 "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/page2.htm\n"
166 "ATTACH;FMTTYPE=text/plain;VALUE=BINARY;ENCODING=BASE64;STUPID=EXAMPLE:VGhpcyB\n"
167 " pcyBhbiBleGFtcGxlIGZpbGU=\n"
168 "X-EXAMPLE1;YAY=YES:Example Data 1\n"
169 "X-EXAMPLE2;NOPE=YEP:Example Data 2\n"
170 "X-EXAMPLE3;WORLD=NO:Example Data 3\n"
173 "X-EXAMPLE1;ANIMAL=NOPE:Meep\n"
174 "X-EXAMPLE1;ANIMAL=CAT:Meow\n"
176 "X-EXAMPLE2;OBJECT=KITCHEN:Fork\n"
177 "X-EXAMPLE2;OBJECT=LIVINGROOM:Table\n"
178 "X-STATUS;HOLIDAY=YES:Idle\n"
179 "X-TRANSPORT;PUBLIC=NO:Private Hire\n"
180 "X-PHANTOM-STATUS;HELP=NONE:None\n"
186 testTask2.SaveString(&saveData);
188 ASSERT_EQ(saveDataComparison, saveData);
192 saveDataComparison = "BEGIN:VCALENDAR\n"
194 "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
196 "UID:b3a16392-ad86-4061-be53-c215af2306df\n"
197 "DTSTAMP;OTHER=PARAM:20160131T104500Z\n"
198 "DTSTART:20160131T103000Z\n"
199 "DURATION;TEST=YES:PT15M\n"
203 ASSERT_EQ(CALENDAROBJECTLOAD_OK, testTask3.LoadFile("iCalendarTask-Load3.vcf"));
204 ASSERT_EQ(CALENDAROBJECTVALID_OK, testTask3.ValidBaseObject());
208 testTask3.SaveString(&saveData);
210 ASSERT_EQ(saveDataComparison, saveData);