Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
utf8: Implemented further UTF8 support
[xestiacalendar/.git] / source / tests / xestiacalendar_icaltasksave.h
1 // xestiacalendar_icaltasksave.h - Xestia Calendar iCalendar Task Component Save Unit Tests
2 //
3 // (c) 2016-2017 Xestia Software Development.
4 //
5 // This file is part of Xestia Calendar.
6 //
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.
10 //
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.
15 //
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;
26         
27         // Load the test journal information.
28         
29         ASSERT_EQ(CALENDAROBJECTLOAD_OK, testTask.LoadFile("iCalendarTask-Load1.vcf"));
30         ASSERT_EQ(CALENDAROBJECTVALID_OK, testTask.ValidBaseObject());
31         
32         ASSERT_EQ(CALENDAROBJECTSAVE_CANNOTOPEN, testTask.SaveFile("/stupidfilelocation/dontsavehere.ics"));
33         
34         // First task file.
35         
36         std::string saveDataComparison = "BEGIN:VCALENDAR\n"
37         "VERSION:2.0\n"
38         "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
39         "BEGIN:VTODO\n"
40         "UID:00\n"
41         "DTSTAMP:20160131T160000Z\n"
42         "END:VTODO\n"
43         "END:VCALENDAR";
44         
45         std::string saveData;
46         
47         testTask.SaveString(&saveData);
48         
49         ASSERT_EQ(saveDataComparison, saveData);
51         ASSERT_EQ(CALENDAROBJECTLOAD_OK, testTask2.LoadFile("iCalendarTask-Load2.vcf"));
52         ASSERT_EQ(CALENDAROBJECTVALID_OK, testTask2.ValidBaseObject());
53         
54         // Second task file.
55         
56         saveDataComparison = "BEGIN:VCALENDAR\n"
57         "VERSION:2.0\n"
58         "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
59         "BEGIN:VTODO\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"
68         " 03000Z\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"
72         " o\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"
78         " 0160131\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"
82         " y of the todo.\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"
88         " l\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"
96         " ndee Three\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"
100         " SEVEN\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"
112         " user\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"
120         "RDATE:20160120\n"
121         "RDATE;VALUE=DATE;TZID=Europe/Truro:20160121\n"
122         "RDATE;ZILCH=DATA:20160520\n"
123         "BEGIN:VALARM\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"
130         " l\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"
136         "END:VALARM\n"
137         "BEGIN:VALARM\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"
142         " d alarm.\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"
147         "END:VALARM\n"
148         "BEGIN:VALARM\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"
153         "  alarm.\n"
154         "SUMMARY;ALTREP=\"null:nodata\";LANGUAGE=en;MEEP=MOOP:This is the summary of the\n"
155         "  third alarm.\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"
162         " ndee Three\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"
165         " l\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"
171         "END:VALARM\n"
172         "X-EXAMPLE1:Moo\n"
173         "X-EXAMPLE1;ANIMAL=NOPE:Meep\n"
174         "X-EXAMPLE1;ANIMAL=CAT:Meow\n"
175         "X-EXAMPLE2:Dish\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"
181         "END:VTODO\n"
182         "END:VCALENDAR";
183         
184         saveData.clear();
185         
186         testTask2.SaveString(&saveData);
187         
188         ASSERT_EQ(saveDataComparison, saveData);
190         // Third task file.
192         saveDataComparison = "BEGIN:VCALENDAR\n"
193         "VERSION:2.0\n"
194         "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
195         "BEGIN:VTODO\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"
200         "END:VTODO\n"
201         "END:VCALENDAR";
203         ASSERT_EQ(CALENDAROBJECTLOAD_OK, testTask3.LoadFile("iCalendarTask-Load3.vcf"));
204         ASSERT_EQ(CALENDAROBJECTVALID_OK, testTask3.ValidBaseObject());
205         
206         saveData.clear();
207         
208         testTask3.SaveString(&saveData);
209         
210         ASSERT_EQ(saveDataComparison, saveData);
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy