Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
utf8: Implemented further UTF8 support
[xestiacalendar/.git] / source / tests / xestiacalendar_icaleventsave.h
1 // xestiacalendar_icaleventsave.h - Xestia Calendar iCalendar Event 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/calendarevent/CalendarEvent.h"
21 TEST(iCalendarSaveEvent, SaveEventTests){
23         CalendarEventObject testEvent;
24         CalendarEventObject testEvent2;
25         CalendarEventObject testEvent3;
26         
27         // Load the test event.
28         
29         ASSERT_EQ(CALENDAROBJECTLOAD_OK, testEvent.LoadFile("iCalendarEvent-Load1.vcf"));
30         ASSERT_EQ(CALENDAROBJECTVALID_OK, testEvent.ValidBaseObject());
31         
32         //ASSERT_EQ(CALENDAROBJECTSAVE_MISSING, testEvent.LoadFile("iCalendarEvent-Missing.vcf"));
33         //ASSERT_EQ(CALENDAROBJECTSAVE_CANNOTOPEN, testEvent.LoadFile("iCalendarEvent-InvalidPermissions.vcf"));
34         //ASSERT_EQ(CALENDAROBJECTSAVE_OK, testEvent.LoadFile("iCalendarEvent-Load1.vcf"));
36         ASSERT_EQ(CALENDAROBJECTSAVE_CANNOTOPEN, testEvent.SaveFile("/stupidfilelocation/dontsavehere.ics"));
37         
38         // Save the data to a string and compare the data.
40         // First contact file.
41         
42         std::string saveDataComparison = "BEGIN:VCALENDAR\n"
43         "VERSION:2.0\n"
44         "METHOD;EXAMPLE=DATA:REQUEST\n"
45         "CALSCALE;MORE=YES:GREGORIAN\n"
46         "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
47         "BEGIN:VEVENT\n"
48         "UID:329128-12939123-123123-13\n"
49         "DTSTAMP:20160116T190200Z\n"
50         "DTSTART:20160116T190200Z\n"
51         "DTEND:20160116T190200Z\n"
52         "SUMMARY:Unit Test Event 1 which has to be a really long summary as we don't k\n"
53         " now if multiple line processing is going to work without it. I mean seriousl\n"
54         " y, how annoying can this potentially be?\n"
55         "END:VEVENT\n"
56         "END:VCALENDAR";
57         
58         std::string saveData;
59         
60         testEvent.SaveString(&saveData);
61         
62         ASSERT_EQ(saveDataComparison, saveData);
64         // Process the second calendar item.
66         ASSERT_EQ(CALENDAROBJECTLOAD_OK, testEvent2.LoadFile("iCalendarEvent-Load2.vcf"));
67         ASSERT_EQ(CALENDAROBJECTVALID_OK, testEvent2.ValidBaseObject());
69         saveData.clear();
70         saveDataComparison = "BEGIN:VCALENDAR\n"
71         "VERSION:2.0\n"
72         "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
73         "BEGIN:VEVENT\n"
74         "UID;UNIQUEPARAM=CERTAINLY;OKAY=MAYBENOT:b3a16392-ad86-4061-be53-c215af2306e0\n"
75         "DTSTAMP;OTHER=PARAM:20160122T124100Z\n"
76         "DTSTART;VALUE=DATE-TIME;TZID=Europe/Truro;PARAMONE=YES;PARAMTWO=NO:20160122T1\n"
77         " 83000Z\n"
78         "DTEND;VALUE=DATE-TIME;TZID=Europe/Truro;PARAMFOUR=YES;PARAMTHREE=NO:20160124T\n"
79         " 183000Z\n"
80         "SUMMARY;ALTREP=\"null:nodata\";LANGUAGE=kw;FAVOURITE=TOFU;NOTLIKE=NONE:A summar\n"
81         " y of the event.\n"
82         "CLASS;CHOCOLATE=BAR:PUBLIC\n"
83         "CREATED;CARAMEL=PLEASE:20160123T081100Z\n"
84         "DESCRIPTION;ALTREP=\"null:nodata\";LANGUAGE=kw;EXAMPLE=TOKEN;MOREDATA=YES:This \n"
85         " is a description of the event.\n"
86         "GEO;EXAMPLE=MEEP:5.0;5.0\n"
87         "LAST-MODIFIED;FUTURE=ODD:20160124T093000Z\n"
88         "LOCATION;ALTREP=\"null:nodata\";LANGUAGE=kw;EXACT=NO:The Basement, Truro\n"
89         "ORGANIZER;CN=ExampleOrganiser;DIR=\"null:nodata\";SENT-BY=\"mailto:organiser.nor\n"
90         " eply@example.com\";LANGUAGE=kw;HAPPY=DAYS:mailto:organiser@example.com\n"
91         "PRIORITY;STATUS=DEFAULT:5\n"
92         "SEQUENCE;TEST=YAY:3\n"
93         "STATUS;LANGUAGE=kw;FAVOURITE=RICHTEA;NOTLIKE=UNKNOWN:2.0;Success\n"
94         "TRANSP;OPAQUE=NOTYET:TRANSPARENT\n"
95         "URL;EXTERNAL=YES:http://www.example.com/\n"
96         "RECURRENCE-ID;TZID=Europe/Truro;RANGE=THISANDFUTURE;VALUE=DATE;EXAMPLE=DATA:2\n"
97         " 0160124\n"
98         "RRULE;TEST=DATA:FREQ=DAILY;COUNT=10\n"
99         "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/\n"
100         "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/page2.htm\n"
101         " l\n"
102         "ATTACH;FMTTYPE=text/plain;VALUE=BINARY;ENCODING=BASE64;STUPID=EXAMPLE:VGhpcyB\n"
103         " pcyBhbiBleGFtcGxlIGZpbGU=\n"
104         "ATTENDEE:Attendee One\n"
105         "ATTENDEE;DELEGATED-FROM=\"mailto:delegated.from@example.com\";DELEGATED-TO=\"mai\n"
106         " lto:delegated.to@example.com\";ROLE=CHAIR;RSVP=TRUE:Attendee Two\n"
107         "ATTENDEE;DIR=\"null:nodata\";SENT-BY=\"mailto:sent.by@example.com\";CN=\"Attendee \n"
108         " The Third\";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED;LANGUAGE=kw;EXAMPLE=DATA:Atte\n"
109         " ndee Three\n"
110         "CATEGORIES:CATEGORY ONE, CATEGORY TWO\n"
111         "CATEGORIES;LANGUAGE=en:CATEGORY THREE, CATEGORY FOUR\n"
112         "CATEGORIES;LANGUAGE=en-GB;SAMPLE=TOKEN:CATEGORY FIVE, CATEGORY SIX, CATEGORY \n"
113         " SEVEN\n"
114         "COMMENT:This is the first comment.\n"
115         "COMMENT;ALTREP=\"null:nodata\";LANGUAGE=en:This is the second comment.\n"
116         "COMMENT;ZEBRAS=YES:This is the third comment.\n"
117         "CONTACT:First Contact\n"
118         "CONTACT;ALTREP=\"null:nodata\";LANGUAGE=en-GB:Second Contact\n"
119         "CONTACT;ZEBRAS=NO:Third Contact\n"
120         "EXDATE:20160125T120000Z\n"
121         "EXDATE;TZID=Europe/Truro;VALUE=DATE-TIME:20160125T130000Z\n"
122         "EXDATE;ZOOP=ZIPPO:20160125T133000Z\n"
123         "REQUEST-STATUS:2.0;Success\n"
124         "REQUEST-STATUS;LANGUAGE=en:3.42;Really big irrecoverable error caused by the \n"
125         " user\n"
126         "REQUEST-STATUS;USER=MISSING:3.7;Invalid calendar user\n"
127         "RELATED-TO:person.1@example.com\n"
128         "RELATED-TO;RELTYPE=PARENT:person.2@example.com\n"
129         "RELATED-TO;SCHOOL=MEETING:person.3@example.com\n"
130         "RESOURCES:DMAC RECEIVER\n"
131         "RESOURCES;LANGUAGE=en:PAL-I TELEVISION SET\n"
132         "RESOURCES;ALTREP=\"null:nodata\";STATUS=BROKEN:PAL/SECAM VCR\n"
133         "RDATE:20160120\n"
134         "RDATE;VALUE=DATE;TZID=Europe/Truro:20160121\n"
135         "RDATE;ZILCH=DATA:20160520\n"
136         "BEGIN:VALARM\n"
137         "ACTION;FUNKY=SOUNDS:AUDIO\n"
138         "TRIGGER;RELATED=END;VALUE=DATE-TIME;PUSH=BUTTON:20160220T160000Z\n"
139         "DURATION;FLYING=NO:PT5H\n"
140         "REPEAT;NEVER=SLEEP:PT5M\n"
141         "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/\n"
142         "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/page2.htm\n"
143         " l\n"
144         "ATTACH;FMTTYPE=text/plain;VALUE=BINARY;ENCODING=BASE64;STUPID=EXAMPLE:VGhpcyB\n"
145         " pcyBhbiBleGFtcGxlIGZpbGU=\n"
146         "X-EXAMPLE1;YAY=YES:Example Data 1\n"
147         "X-EXAMPLE2;NOPE=YEP:Example Data 2\n"
148         "X-EXAMPLE3;WORLD=NO:Example Data 3\n"
149         "END:VALARM\n"
150         "BEGIN:VALARM\n"
151         "ACTION;FLASHING=LIGHTS:DISPLAY\n"
152         "TRIGGER;RELATED=END;VALUE=DATE-TIME;PUSH=BUTTON:20160230T110000Z\n"
153         "DURATION;FLYING=YES:PT7H\n"
154         "DESCRIPTION;ALTREP=\"null:nodata\";LANGUAGE=kw;TERRIBLE=TOKEN:This is the secon\n"
155         " d alarm.\n"
156         "REPEAT;SLEEP=ALWAYS:PT3M\n"
157         "X-EXAMPLE1;YAY=YES:Example Data 1\n"
158         "X-EXAMPLE2;NOPE=YEP:Example Data 2\n"
159         "X-EXAMPLE3;WORLD=NO:Example Data 3\n"
160         "END:VALARM\n"
161         "BEGIN:VALARM\n"
162         "ACTION;FLASHING=LIGHTS:EMAIL\n"
163         "TRIGGER;RELATED=END;VALUE=DATE-TIME;PUSH=BUTTON:20160230T120000Z\n"
164         "DURATION;FLYING=YES:PT7H\n"
165         "DESCRIPTION;ALTREP=\"null:nodata\";LANGUAGE=kw;TERRIBLE=TOKEN:This is the third\n"
166         "  alarm.\n"
167         "SUMMARY;ALTREP=\"null:nodata\";LANGUAGE=en;MEEP=MOOP:This is the summary of the\n"
168         "  third alarm.\n"
169         "REPEAT;SLEEP=ALWAYS:PT3M\n"
170         "ATTENDEE:Attendee One\n"
171         "ATTENDEE;DELEGATED-FROM=\"mailto:delegated.from@example.com\";DELEGATED-TO=\"mai\n"
172         " lto:delegated.to@example.com\";ROLE=CHAIR;RSVP=TRUE:Attendee Two\n"
173         "ATTENDEE;DIR=\"null:nodata\";SENT-BY=\"mailto:sent.by@example.com\";CN=\"Attendee \n"
174         " The Third\";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED;LANGUAGE=kw;EXAMPLE=DATA:Atte\n"
175         " ndee Three\n"
176         "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/\n"
177         "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/page2.htm\n"
178         " l\n"
179         "ATTACH;FMTTYPE=text/plain;VALUE=BINARY;ENCODING=BASE64;STUPID=EXAMPLE:VGhpcyB\n"
180         " pcyBhbiBleGFtcGxlIGZpbGU=\n"
181         "X-EXAMPLE1;YAY=YES:Example Data 1\n"
182         "X-EXAMPLE2;NOPE=YEP:Example Data 2\n"
183         "X-EXAMPLE3;WORLD=NO:Example Data 3\n"
184         "END:VALARM\n"
185         "X-EXAMPLE1:Moo\n"
186         "X-EXAMPLE1;ANIMAL=NOPE:Meep\n"
187         "X-EXAMPLE1;ANIMAL=CAT:Meow\n"
188         "X-EXAMPLE2:Dish\n"
189         "X-EXAMPLE2;OBJECT=KITCHEN:Fork\n"
190         "X-EXAMPLE2;OBJECT=LIVINGROOM:Table\n"
191         "X-STATUS;HOLIDAY=YES:Idle\n"
192         "X-TRANSPORT;PUBLIC=NO:Private Hire\n"
193         "X-PHANTOM-STATUS;HELP=NONE:None\n"
194         "END:VEVENT\n"
195         "END:VCALENDAR";
197         testEvent2.SaveString(&saveData);
198         
199         ASSERT_EQ(saveDataComparison, saveData);
200         
201         ASSERT_EQ(CALENDAROBJECTLOAD_OK, testEvent3.LoadFile("iCalendarEvent-Load3.vcf"));
202         ASSERT_EQ(CALENDAROBJECTVALID_OK, testEvent3.ValidBaseObject());
204         saveData.clear();
206         saveDataComparison = "BEGIN:VCALENDAR\n"
207         "VERSION:2.0\n"
208         "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
209         "BEGIN:VEVENT\n"
210         "UID:b3a16392-ad86-4061-be53-c215af2306e1\n"
211         "DTSTAMP:20160127T111200Z\n"
212         "DTSTART:20160122T183000Z\n"
213         "DURATION;TEST=EXAMPLE:PT1H\n"
214         "END:VEVENT\n"
215         "END:VCALENDAR";
217         testEvent3.SaveString(&saveData);
219         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