Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added unit tests for CATEGORIES and COMMENT in iCalendarTask/ObjectDataTests.
[xestiacalendar/.git] / source / tests / xestiacalendar_icaltaskload.h
1 // xestiacalendar_icaleventload.h - Xestia Calendar iCalendar Task Component Unit Tests
2 //
3 // (c) 2016 Xestia Software Development.
4 //
5 // This file is part of Xestia Calendar.
6 //
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.
10 //
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.
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(iCalendarTask, BasicTests){
23         CalendarTaskObject TestTask;
24         
25         ASSERT_EQ(CALENDAROBJECTLOAD_MISSING, TestTask.LoadFile("iCalendarTask-Missing.vcf"));
26         ASSERT_EQ(CALENDAROBJECTLOAD_CANNOTOPEN, TestTask.LoadFile("iCalendarTask-InvalidPermissions.vcf"));
27         ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestTask.LoadFile("iCalendarTask-Load1.vcf"));
28         
29 }
31 TEST(iCalendarTask, ObjectDataTests){
33         CalendarTaskObject TestTask;
34         ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestTask.LoadFile("iCalendarTask-Load2.vcf"));
35         ASSERT_EQ(CALENDAROBJECTVALID_OK, TestTask.ValidBaseObject());
36         
37         // Tests for DTSTAMP.
38         
39         ASSERT_EQ("20160131T104500Z", TestTask.DateTimeStampData);
40         ASSERT_EQ("OTHER=PARAM", TestTask.DateTimeStampTokens);
41         
42         // Tests for UID.
43         
44         ASSERT_EQ("b3a16392-ad86-4061-be53-c215af2306e1", TestTask.UniqueID);
45         ASSERT_EQ("UNIQUEPARAM=CERTAINLY;OKAY=MAYBENOT", TestTask.UniqueIDTokens);
46         
47         // Tests for CLASS.
48         
49         ASSERT_EQ("PUBLIC", TestTask.ClassData);
50         ASSERT_EQ("CHOCOLATE=NONE", TestTask.ClassDataTokens);
51         
52         // Tests for COMPLETED.
53         
54         ASSERT_EQ("20160131T110100Z", TestTask.CompletedData);
55         ASSERT_EQ("LYING=NEVER", TestTask.CompletedDataTokens);
56         
57         // Tests for CREATED.
59         ASSERT_EQ("20160131T080000Z", TestTask.DateTimeCreatedData);
60         ASSERT_EQ("CARAMEL=PLEASE", TestTask.DateTimeCreatedTokens);
61         
62         // Tests for DESCRIPTION.
63         
64         std::string DescriptionData;
65         std::string DescriptionAltRep;
66         std::string DescriptionLanguage;
67         std::string DescriptionTokens;
68         
69         if (TestTask.DescriptionList.begin() != TestTask.DescriptionList.end()){
70                 DescriptionData = TestTask.DescriptionList[0];
71         }
73         if (TestTask.DescriptionListAltRep.begin() != TestTask.DescriptionListAltRep.end()){
74                 DescriptionAltRep = TestTask.DescriptionListAltRep[0];
75         }
77         if (TestTask.DescriptionListLanguage.begin() != TestTask.DescriptionListLanguage.end()){
78                 DescriptionLanguage = TestTask.DescriptionListLanguage[0];
79         }
81         if (TestTask.DescriptionListTokens.begin() != TestTask.DescriptionListTokens.end()){
82                 DescriptionTokens = TestTask.DescriptionListTokens[0];
83         }
84         
85         ASSERT_EQ("This is a description of the todo.", DescriptionData);
86         ASSERT_EQ("null:nodata", DescriptionAltRep);
87         ASSERT_EQ("kw", DescriptionLanguage);
88         ASSERT_EQ("EXAMPLE=TOKEN;MOREDATA=YES", DescriptionTokens);
89         
90         // Tests for DTSTART.
91         
92         ASSERT_EQ("20160131T103000Z", TestTask.DateTimeStartData);
93         ASSERT_EQ("DATE-TIME", TestTask.DateTimeStartDataValue);
94         ASSERT_EQ("Europe/Truro", TestTask.DateTimeStartDataTimeZoneID);
95         ASSERT_EQ("PARAMONE=YES;PARAMTWO=NO", TestTask.DateTimeStartDataTokens);
96         
97         // Tests for GEO.
98         
99         ASSERT_EQ("20.0;20.0", TestTask.GeographicData);
100         ASSERT_EQ("EXAMPLE=MOOP", TestTask.GeographicTokens);
101         
102         // Tests for LAST-MODIFIED.
103         
104         ASSERT_EQ("20160131T114200Z", TestTask.LastModifiedData);
105         ASSERT_EQ("FUTURE=EVEN", TestTask.LastModifiedTokens);
106         
107         // Tests for LOCATION.
109         ASSERT_EQ("The Crystal Ceiling, Truro", TestTask.LocationData);
110         ASSERT_EQ("null:nodata", TestTask.LocationDataAltRep);
111         ASSERT_EQ("kw", TestTask.LocationDataLanguage);
112         ASSERT_EQ("EXACT=YES", TestTask.LocationDataTokens);
113         
114         // Tests for ORGANIZER.
115         
116         ASSERT_EQ("mailto:organiser@example.com", TestTask.OrganiserData);
117         ASSERT_EQ("ExampleOrganiser", TestTask.OrganiserDataCommonName);
118         ASSERT_EQ("null:nodata", TestTask.OrganiserDataDirectoryEntry);
119         ASSERT_EQ("mailto:organiser.noreply@example.com", TestTask.OrganiserDataSentByParam);
120         ASSERT_EQ("kw", TestTask.OrganiserDataLanguage);
121         ASSERT_EQ("HAPPY=WEEKS", TestTask.OrganiserDataTokens);
122         
123         // Tests for PERCENT-COMPLETE.
124         
125         ASSERT_EQ("42", TestTask.PercentCompleteData);
126         ASSERT_EQ("DEEP=THOUGHT", TestTask.PercentCompleteTokens);
127         
128         // Tests for PRIORITY.
129         
130         ASSERT_EQ(5, TestTask.PriorityData);
131         ASSERT_EQ("STATUS=DEFAULT", TestTask.PriorityTokens);
132         
133         // Tests for RECURRENCE-ID.
134         
135         ASSERT_EQ("20160131", TestTask.RecurranceIDData);
136         ASSERT_EQ("Europe/Truro", TestTask.RecurranceIDDataTimeZoneParam);
137         ASSERT_EQ("THISANDFUTURE", TestTask.RecurranceIDDataRangeParam);
138         ASSERT_EQ("DATE", TestTask.RecurranceIDDataValue);
139         ASSERT_EQ("EXAMPLE=DATA", TestTask.RecurranceIDDataTokens);
140         
141         // Tests for SEQUENCE.
142         
143         ASSERT_EQ(3, TestTask.SequenceData);
144         ASSERT_EQ("TEST=YAY", TestTask.SequenceTokens);
145         
146         // Tests for STATUS.
147         
148         ASSERT_EQ("2.0;Success", TestTask.StatusData);
149         ASSERT_EQ("kw", TestTask.StatusLanguage);
150         ASSERT_EQ("FAVOURITE=BEANS;NOTLIKE=UNKNOWN", TestTask.StatusTokens);
151         
152         // Tests for SUMMARY.
153         
154         ASSERT_EQ("A summary of the todo.", TestTask.SummaryData);
155         ASSERT_EQ("null:nodata", TestTask.SummaryDataAltRep);
156         ASSERT_EQ("kw", TestTask.SummaryDataLanguage);
157         ASSERT_EQ("FAVOURITE=TOFU;NOTLIKE=NONE", TestTask.SummaryDataTokens);
158         
159         // Tests for URL.
161         ASSERT_EQ("http://www.example.com/", TestTask.URLData);
162         ASSERT_EQ("EXTERNAL=YES", TestTask.URLDataTokens);
163         
164         // Tests for RRULE.
165         
166         ASSERT_EQ("FREQ=DAILY;COUNT=10", TestTask.RecurranceRuleData);
167         ASSERT_EQ("TEST=DATA", TestTask.RecurranceRuleDataTokens);
168         
169         // Tests for DUE.
170         
171         ASSERT_EQ("20160131T150000Z", TestTask.DueData);
172         ASSERT_EQ("Europe/Truro", TestTask.DueDataTimeZoneID);
173         ASSERT_EQ("DATE-TIME", TestTask.DueDataValue);
174         ASSERT_EQ("TEST=YES", TestTask.DueDataTokens);
175         
176         // Tests for DURATION.
177         
178         CalendarTaskObject TestTask2;
179         ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestTask2.LoadFile("iCalendarTask-Load3.vcf"));
180         ASSERT_EQ(CALENDAROBJECTVALID_OK, TestTask2.ValidBaseObject());
181         
182         ASSERT_EQ("PT15M", TestTask2.DurationData);
183         ASSERT_EQ("TEST=YES", TestTask2.DurationDataTokens);
184         
185         // Tests for ATTACH. First ATTACH property.
187         std::string AttachData;
188         std::string AttachDataFormatType;
189         std::string AttachDataValue;
190         std::string AttachDataEncoding;
191         std::string AttachDataTokens;
193         if (TestTask.AttachList.begin() != TestTask.AttachList.end()){
194                 
195                 AttachData = TestTask.AttachList[0];
196                 
197         }
198         
199         if (TestTask.AttachListFormatType.begin() != TestTask.AttachListFormatType.end()){
200                 
201                 AttachDataFormatType = TestTask.AttachListFormatType[0];
202                 
203         }
205         ASSERT_EQ("http://www.example.com/", AttachData);
206         ASSERT_EQ("application/internet-shortcut", AttachDataFormatType);
207         
208         // Second ATTACH property.
209         
210         AttachData.clear();
211         AttachDataFormatType.clear();
212         AttachDataValue.clear();
213         AttachDataEncoding.clear();
214         
215         if (TestTask.AttachList.size() > 1){
216                 
217                 AttachData = TestTask.AttachList[1];
218                 
219         }
220         
221         if (TestTask.AttachListFormatType.size() > 1){
222                 
223                 AttachDataFormatType = TestTask.AttachListFormatType[1];
224                 
225         }
227         ASSERT_EQ("http://www.example.com/page2.html", AttachData);
228         ASSERT_EQ("application/internet-shortcut", AttachDataFormatType);
229         
230         // Third ATTACH property.
232         AttachData.clear();
233         AttachDataFormatType.clear();
234         AttachDataValue.clear();
235         AttachDataEncoding.clear();
236         AttachDataTokens.clear();
237         
238         if (TestTask.AttachList.size() > 2){
239                 
240                 AttachData = TestTask.AttachList[2];
241                 
242         }
243         
244         if (TestTask.AttachListFormatType.size() > 2){
245                 
246                 AttachDataFormatType = TestTask.AttachListFormatType[2];
247                 
248         }
249         
250         if (TestTask.AttachListValue.size() > 2){
251                 
252                 AttachDataValue = TestTask.AttachListValue[2];
253                 
254         }
255         
256         if (TestTask.AttachListFormatType.size() > 2){
257                 
258                 AttachDataEncoding = TestTask.AttachListEncoding[2];
259                 
260         }
262         if (TestTask.AttachListTokens.size() > 2){
263                 
264                 AttachDataTokens = TestTask.AttachListTokens[2];
265                 
266         }
267         
268         ASSERT_EQ("VGhpcyBpcyBhbiBleGFtcGxlIGZpbGU=", AttachData);
269         ASSERT_EQ("text/plain", AttachDataFormatType);
270         ASSERT_EQ("BASE64", AttachDataEncoding);
271         ASSERT_EQ("BINARY", AttachDataValue);
272         ASSERT_EQ("STUPID=EXAMPLE", AttachDataTokens);
273         
274         // Tests for ATTENDEE. First ATTENDEE property.
276         std::string AttendeeDataMember;
277         std::string AttendeeDataDelegatedFrom;
278         std::string AttendeeDataDelegatedTo;
279         std::string AttendeeDataRole;
280         std::string AttendeeDataRSVP;
281         std::string AttendeeDataDirectoryEntry;
282         std::string AttendeeDataSentBy;
283         std::string AttendeeDataCommonName;
284         std::string AttendeeDataCalendarUserType;
285         std::string AttendeeDataParticipationStatus;
286         std::string AttendeeDataLanguage;
287         std::string AttendeeDataTokens;
288         std::string AttendeeData;
290         if (TestTask.AttendeeList.begin() != TestTask.AttendeeList.end()){
291                 
292                 AttendeeData = TestTask.AttendeeList[0];
293                 
294         }
295         
296         ASSERT_EQ("Attendee One", AttendeeData);
297         
298         // Second ATTENDEE property.
299         
300         AttendeeData.clear();
301         
302         if (TestTask.AttendeeList.size() > 1){
303                 
304                 AttendeeData = TestTask.AttendeeList[1];
305                 
306         }
308         if (TestTask.AttendeeList.size() > 1){
309                 
310                 AttendeeDataDelegatedFrom = TestTask.AttendeeListDelegatedFrom[1];
311                 
312         }
313         
314         if (TestTask.AttendeeList.size() > 1){
315                 
316                 AttendeeDataDelegatedTo = TestTask.AttendeeListDelegatedTo[1];
317                 
318         }
320         if (TestTask.AttendeeList.size() > 1){
321                 
322                 AttendeeDataRole = TestTask.AttendeeListRole[1];
323                 
324         }
325         
326         if (TestTask.AttendeeList.size() > 1){
327                 
328                 AttendeeDataRSVP = TestTask.AttendeeListRSVP[1];
329                 
330         }
331         
332         ASSERT_EQ("Attendee Two", AttendeeData);
333         ASSERT_EQ("mailto:delegated.from@example.com", AttendeeDataDelegatedFrom);
334         ASSERT_EQ("mailto:delegated.to@example.com", AttendeeDataDelegatedTo);
335         ASSERT_EQ("CHAIR", AttendeeDataRole);
336         ASSERT_EQ("TRUE", AttendeeDataRSVP);
338         // Third ATTENDEE property.
339         
340         AttendeeData.clear();
341         
342         if (TestTask.AttendeeList.size() > 2){
343                 
344                 AttendeeData = TestTask.AttendeeList[2];
345                 
346         }
348         if (TestTask.AttendeeList.size() > 2){
349                 
350                 AttendeeDataDirectoryEntry = TestTask.AttendeeListDirectoryEntry[2];
351                 
352         }
353         
354         if (TestTask.AttendeeList.size() > 2){
355                 
356                 AttendeeDataSentBy = TestTask.AttendeeListSentBy[2];
357                 
358         }
360         if (TestTask.AttendeeList.size() > 2){
361                 
362                 AttendeeDataCommonName = TestTask.AttendeeListCommonName[2];
363                 
364         }
365         
366         if (TestTask.AttendeeList.size() > 2){
367                 
368                 AttendeeDataCalendarUserType = TestTask.AttendeeListCalendarUserType[2];
369                 
370         }
372         if (TestTask.AttendeeList.size() > 2){
373                 
374                 AttendeeDataParticipationStatus = TestTask.AttendeeListParticipationStatus[2];
375                 
376         }
378         if (TestTask.AttendeeList.size() > 2){
379                 
380                 AttendeeDataLanguage = TestTask.AttendeeListLanguage[2];
381                 
382         }
383         
384         if (TestTask.AttendeeList.size() > 2){
385                 
386                 AttendeeDataTokens = TestTask.AttendeeListTokens[2];
387                 
388         }
389         
390         ASSERT_EQ("Attendee Three", AttendeeData);
391         ASSERT_EQ("null:nodata", AttendeeDataDirectoryEntry);
392         ASSERT_EQ("mailto:sent.by@example.com", AttendeeDataSentBy);
393         ASSERT_EQ("Attendee The Third", AttendeeDataCommonName);
394         ASSERT_EQ("INDIVIDUAL", AttendeeDataCalendarUserType);
395         ASSERT_EQ("ACCEPTED", AttendeeDataParticipationStatus);
396         ASSERT_EQ("kw", AttendeeDataLanguage);
397         ASSERT_EQ("EXAMPLE=DATA", AttendeeDataTokens);
398         
399         // Get the first CATEGORIES.
400         
401         std::string CategoryData;
402         
403         if (TestTask.CategoriesList.begin() != TestTask.CategoriesList.end()){
404                 
405                 CategoryData = TestTask.CategoriesList[0];
406                 
407         }
408         
409         ASSERT_EQ("CATEGORY ONE, CATEGORY TWO", CategoryData);
410         
411         CategoryData.clear();
413         std::string CategoryLanguage;
414         
415         // Get the second CATEGORIES.
416         
417         if (TestTask.CategoriesList.size() > 1){
418                 
419                 CategoryData = TestTask.CategoriesList[1];
420                 
421         }
422         
423         if (TestTask.CategoriesList.size() > 1){
424                 
425                 CategoryLanguage = TestTask.CategoriesListLanguage[1];
426                 
427         }
428                 
429         ASSERT_EQ("CATEGORY THREE, CATEGORY FOUR", CategoryData);
430         ASSERT_EQ("en", CategoryLanguage);
431         
432         CategoryData.clear();
433         CategoryLanguage.clear();
434         
435         // Get the third CATEGORIES.
436         
437         std::string CategoryTokens;
438         
439         if (TestTask.CategoriesList.size() > 2){
440                 
441                 CategoryData = TestTask.CategoriesList[2];
442                 
443         }
444         
445         if (TestTask.CategoriesList.size() > 2){
446                 
447                 CategoryLanguage = TestTask.CategoriesListLanguage[2];
448                 
449         }
450         
451         if (TestTask.CategoriesList.size() > 2){
452                 
453                 CategoryTokens = TestTask.CategoriesListTokens[2];
454                 
455         }
456                 
457         ASSERT_EQ("CATEGORY FIVE, CATEGORY SIX, CATEGORY SEVEN", CategoryData);
458         ASSERT_EQ("en-GB", CategoryLanguage);
459         ASSERT_EQ("SAMPLE=TOKEN", CategoryTokens);
460         
461         // Get the first COMMENT.
462         
463         std::string CommentData;
464         
465         if (TestTask.CommentList.begin() != TestTask.CommentList.end()){
466                 
467                 CommentData = TestTask.CommentList[0];
468                 
469         }
470         
471         ASSERT_EQ("This is the first comment.", CommentData);
472         
473         // Get the second COMMENT.
474         
475         CommentData.clear();
476         
477         std::string CommentDataAltRep;
478         std::string CommentDataLanguage;
479         
480         if (TestTask.CommentList.size() > 1){
481                 
482                 CommentData = TestTask.CommentList[1];
483                 
484         }
485         
486         if (TestTask.CommentList.size() > 1){
487                 
488                 CommentDataAltRep = TestTask.CommentListAltRep[1];
489                 
490         }
491         
492         if (TestTask.CommentList.size() > 1){
493                 
494                 CommentDataLanguage = TestTask.CommentListLanguage[1];
495                 
496         }
497         
498         ASSERT_EQ("This is the second comment.", CommentData);
499         ASSERT_EQ("null:nodata", CommentDataAltRep);
500         ASSERT_EQ("en", CommentDataLanguage);
501         
502         // Get the third COMMENT.
503         
504         CommentData.clear();
505         
506         std::string CommentDataTokens;
507         
508         if (TestTask.CommentList.size() > 2){
509                 
510                 CommentData = TestTask.CommentList[2];
511                 
512         }
513         
514         if (TestTask.CommentList.size() > 2){
515                 
516                 CommentDataTokens = TestTask.CommentListTokens[2];
517                 
518         }
519         
520         ASSERT_EQ("This is the third comment.", CommentData);
521         ASSERT_EQ("ZEBRAS=YES", CommentDataTokens);
522         
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