Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
unit-test: Refactor unit testing building/running/info collecting for build server
[xestiacalendar/.git] / source / tests / iCalendarTaskTests / iCalendarTaskSave.cpp
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"
20 #include <gtest/gtest.h>
22 class iCalendarTaskSaveTests : public ::testing::Test
23 {
24 private:
25     virtual void SetUp()
26     {
27     }
28     
29     virtual void TearDown()
30     {
31     }
32 };
34 TEST_F(iCalendarTaskSaveTests, SaveTaskTests){
36         CalendarTaskObject testTask;
37         CalendarTaskObject testTask2;
38         CalendarTaskObject testTask3;
39         
40         // Load the test journal information.
41         
42         ASSERT_EQ(CALENDAROBJECTLOAD_OK, testTask.LoadFile("iCalendarTask-Load1.vcf"));
43         ASSERT_EQ(CALENDAROBJECTVALID_OK, testTask.ValidBaseObject());
44         
45         ASSERT_EQ(CALENDAROBJECTSAVE_CANNOTOPEN, testTask.SaveFile("/stupidfilelocation/dontsavehere.ics"));
46         
47         // First task file.
48         
49         std::string saveDataComparison = "BEGIN:VCALENDAR\n"
50         "VERSION:2.0\n"
51         "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
52         "BEGIN:VTODO\n"
53         "UID:00\n"
54         "DTSTAMP:20160131T160000Z\n"
55         "END:VTODO\n"
56         "END:VCALENDAR";
57         
58         std::string saveData;
59         
60         testTask.SaveString(&saveData);
61         
62         ASSERT_EQ(saveDataComparison, saveData);
64         ASSERT_EQ(CALENDAROBJECTLOAD_OK, testTask2.LoadFile("iCalendarTask-Load2.vcf"));
65         ASSERT_EQ(CALENDAROBJECTVALID_OK, testTask2.ValidBaseObject());
66         
67         // Second task file.
68         
69         saveDataComparison = "BEGIN:VCALENDAR\n"
70         "VERSION:2.0\n"
71         "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
72         "BEGIN:VTODO\n"
73         "UID;UNIQUEPARAM=CERTAINLY;OKAY=MAYBENOT:b3a16392-ad86-4061-be53-c215af2306e1\n"
74         "DTSTAMP;OTHER=PARAM:20160131T104500Z\n"
75         "CLASS;CHOCOLATE=NONE:PUBLIC\n"
76         "COMPLETED;LYING=NEVER:20160131T110100Z\n"
77         "CREATED;CARAMEL=PLEASE:20160131T080000Z\n"
78         "DESCRIPTION;ALTREP=\"null:nodata\";LANGUAGE=kw;EXAMPLE=TOKEN;MOREDATA=YES:This \n"
79         " is a description of the todo.\n"
80         "DTSTART;VALUE=DATE-TIME;TZID=Europe/Truro;PARAMONE=YES;PARAMTWO=NO:20160131T1\n"
81         " 03000Z\n"
82         "GEO;EXAMPLE=MOOP:20.0;20.0\n"
83         "LAST-MODIFIED;FUTURE=EVEN:20160131T114200Z\n"
84         "LOCATION;ALTREP=\"null:nodata\";LANGUAGE=kw;EXACT=YES:The Crystal Ceiling, Trur\n"
85         " o\n"
86         "ORGANIZER;CN=ExampleOrganiser;DIR=\"null:nodata\";SENT-BY=\"mailto:organiser.nor\n"
87         " eply@example.com\";LANGUAGE=kw;HAPPY=WEEKS:mailto:organiser@example.com\n"
88         "PERCENT-COMPLETE;DEEP=THOUGHT:42\n"
89         "PRIORITY;STATUS=DEFAULT:5\n"
90         "RECURRENCE-ID;TZID=Europe/Truro;RANGE=THISANDFUTURE;VALUE=DATE;EXAMPLE=DATA:2\n"
91         " 0160131\n"
92         "SEQUENCE;TEST=YAY:3\n"
93         "STATUS;LANGUAGE=kw;FAVOURITE=BEANS;NOTLIKE=UNKNOWN:2.0;Success\n"
94         "SUMMARY;ALTREP=\"null:nodata\";LANGUAGE=kw;FAVOURITE=TOFU;NOTLIKE=NONE:A summar\n"
95         " y of the todo.\n"
96         "URL;EXTERNAL=YES:http://www.example.com/\n"
97         "RRULE;TEST=DATA:FREQ=DAILY;COUNT=10\n"
98         "DUE;TZID=Europe/Truro;VALUE=DATE-TIME;TEST=YES:20160131T150000Z\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:VTODO\n"
195         "END:VCALENDAR";
196         
197         saveData.clear();
198         
199         testTask2.SaveString(&saveData);
200         
201         ASSERT_EQ(saveDataComparison, saveData);
203         // Third task file.
205         saveDataComparison = "BEGIN:VCALENDAR\n"
206         "VERSION:2.0\n"
207         "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
208         "BEGIN:VTODO\n"
209         "UID:b3a16392-ad86-4061-be53-c215af2306df\n"
210         "DTSTAMP;OTHER=PARAM:20160131T104500Z\n"
211         "DTSTART:20160131T103000Z\n"
212         "DURATION;TEST=YES:PT15M\n"
213         "END:VTODO\n"
214         "END:VCALENDAR";
216         ASSERT_EQ(CALENDAROBJECTLOAD_OK, testTask3.LoadFile("iCalendarTask-Load3.vcf"));
217         ASSERT_EQ(CALENDAROBJECTVALID_OK, testTask3.ValidBaseObject());
218         
219         saveData.clear();
220         
221         testTask3.SaveString(&saveData);
222         
223         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