Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added unit tests for CATEGORIES and COMMENT in iCalendarJournal/ObjectDataTests.
[xestiacalendar/.git] / source / tests / xestiacalendar_icaljournalload.h
1 // xestiacalendar_icaleventload.h - Xestia Calendar iCalendar Journal 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/calendarjournal/CalendarJournal.h"
21 TEST(iCalendarJournal, BasicTests){
23         CalendarJournalObject TestJournal;
24         
25         ASSERT_EQ(CALENDAROBJECTLOAD_MISSING, TestJournal.LoadFile("iCalendarJournal-Missing.vcf"));
26         ASSERT_EQ(CALENDAROBJECTLOAD_CANNOTOPEN, TestJournal.LoadFile("iCalendarJournal-InvalidPermissions.vcf"));
27         ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestJournal.LoadFile("iCalendarJournal-Load1.vcf"));
28         
29 }
31 TEST(iCalendarJournal, ObjectDataTests){
32         
33         CalendarJournalObject TestJournal;
34         ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestJournal.LoadFile("iCalendarJournal-Load2.vcf"));
35         ASSERT_EQ(CALENDAROBJECTVALID_OK, TestJournal.ValidBaseObject());
36         
37         // Tests for DTSTAMP.
38         
39         ASSERT_EQ("20160131T141500Z", TestJournal.DateTimeStampData);
40         ASSERT_EQ("OTHER=PARAM", TestJournal.DateTimeStampTokens);
41         
42         // Tests for UID.
43         
44         ASSERT_EQ("b3a16392-ad86-4061-be53-c215af2306c1", TestJournal.UniqueID);
45         ASSERT_EQ("UNIQUEPARAM=CERTAINLY;OKAY=MAYBENOT", TestJournal.UniqueIDTokens);
46         
47         // Tests for CLASS.
48         
49         ASSERT_EQ("PUBLIC", TestJournal.ClassData);
50         ASSERT_EQ("CHOCOLATE=BAR", TestJournal.ClassDataTokens);
51         
52         // Tests for DTSTART.
53         
54         ASSERT_EQ("20160131T143500Z", TestJournal.DateTimeStartData);
55         ASSERT_EQ("DATE-TIME", TestJournal.DateTimeStartDataValue);
56         ASSERT_EQ("Europe/Truro", TestJournal.DateTimeStartDataTimeZoneID);
57         ASSERT_EQ("PARAMONE=YES;PARAMTWO=NO", TestJournal.DateTimeStartDataTokens);
58         
59         // Tests for LAST-MODIFIED.
60         
61         ASSERT_EQ("20160131T143700Z", TestJournal.LastModifiedData);
62         ASSERT_EQ("FUTURE=YES", TestJournal.LastModifiedTokens);
63         
64         // Tests for ORGANIZER.
65         
66         ASSERT_EQ("mailto:organiser@example.com", TestJournal.OrganiserData);
67         ASSERT_EQ("ExampleOrganiser", TestJournal.OrganiserDataCommonName);
68         ASSERT_EQ("null:nodata", TestJournal.OrganiserDataDirectoryEntry);
69         ASSERT_EQ("mailto:organiser.noreply@example.com", TestJournal.OrganiserDataSentByParam);
70         ASSERT_EQ("kw", TestJournal.OrganiserDataLanguage);
71         ASSERT_EQ("HAPPY=DAYS", TestJournal.OrganiserDataTokens);
72         
73         // Tests for RECURRENCE-ID.
74         
75         ASSERT_EQ("20160131", TestJournal.RecurranceIDData);
76         ASSERT_EQ("Europe/Truro", TestJournal.RecurranceIDDataTimeZoneParam);
77         ASSERT_EQ("THISANDFUTURE", TestJournal.RecurranceIDDataRangeParam);
78         ASSERT_EQ("DATE", TestJournal.RecurranceIDDataValue);
79         ASSERT_EQ("EXAMPLE=DATA", TestJournal.RecurranceIDDataTokens);
80         
81         // Tests for SEQUENCE.
82         
83         ASSERT_EQ(7, TestJournal.SequenceData);
84         ASSERT_EQ("TEST=YAY", TestJournal.SequenceTokens);
85         
86         // Tests for STATUS.
87         
88         ASSERT_EQ("2.0;Success", TestJournal.StatusData);
89         ASSERT_EQ("kw", TestJournal.StatusLanguage);
90         ASSERT_EQ("FAVOURITE=RICHTEA;NOTLIKE=UNKNOWN", TestJournal.StatusTokens);
91         
92         // Tests for SUMMARY.
93         
94         ASSERT_EQ("A summary of the journal entry.", TestJournal.SummaryData);
95         ASSERT_EQ("null:nodata", TestJournal.SummaryDataAltRep);
96         ASSERT_EQ("kw", TestJournal.SummaryDataLanguage);
97         ASSERT_EQ("FAVOURITE=TOFU;NOTLIKE=NONE", TestJournal.SummaryDataTokens);
98         
99         // Tests for URL.
101         ASSERT_EQ("http://www.example.com/", TestJournal.URLData);
102         ASSERT_EQ("EXTERNAL=YES", TestJournal.URLDataTokens);
103         
104         // Tests for RRULE.
105         
106         ASSERT_EQ("FREQ=DAILY;COUNT=10", TestJournal.RecurranceRuleData);
107         ASSERT_EQ("TEST=DATA", TestJournal.RecurranceRuleDataTokens);
108         
109         // Tests for ATTACH. First ATTACH property.
111         std::string AttachData;
112         std::string AttachDataFormatType;
113         std::string AttachDataValue;
114         std::string AttachDataEncoding;
115         std::string AttachDataTokens;
117         if (TestJournal.AttachList.begin() != TestJournal.AttachList.end()){
118                 
119                 AttachData = TestJournal.AttachList[0];
120                 
121         }
122         
123         if (TestJournal.AttachListFormatType.begin() != TestJournal.AttachListFormatType.end()){
124                 
125                 AttachDataFormatType = TestJournal.AttachListFormatType[0];
126                 
127         }
129         ASSERT_EQ("http://www.example.com/", AttachData);
130         ASSERT_EQ("application/internet-shortcut", AttachDataFormatType);
131         
132         // Second ATTACH property.
133         
134         AttachData.clear();
135         AttachDataFormatType.clear();
136         AttachDataValue.clear();
137         AttachDataEncoding.clear();
138         
139         if (TestJournal.AttachList.size() > 1){
140                 
141                 AttachData = TestJournal.AttachList[1];
142                 
143         }
144         
145         if (TestJournal.AttachListFormatType.size() > 1){
146                 
147                 AttachDataFormatType = TestJournal.AttachListFormatType[1];
148                 
149         }
151         ASSERT_EQ("http://www.example.com/page2.html", AttachData);
152         ASSERT_EQ("application/internet-shortcut", AttachDataFormatType);
153         
154         // Third ATTACH property.
156         AttachData.clear();
157         AttachDataFormatType.clear();
158         AttachDataValue.clear();
159         AttachDataEncoding.clear();
160         AttachDataTokens.clear();
161         
162         if (TestJournal.AttachList.size() > 2){
163                 
164                 AttachData = TestJournal.AttachList[2];
165                 
166         }
167         
168         if (TestJournal.AttachListFormatType.size() > 2){
169                 
170                 AttachDataFormatType = TestJournal.AttachListFormatType[2];
171                 
172         }
173         
174         if (TestJournal.AttachListValue.size() > 2){
175                 
176                 AttachDataValue = TestJournal.AttachListValue[2];
177                 
178         }
179         
180         if (TestJournal.AttachListFormatType.size() > 2){
181                 
182                 AttachDataEncoding = TestJournal.AttachListEncoding[2];
183                 
184         }
186         if (TestJournal.AttachListTokens.size() > 2){
187                 
188                 AttachDataTokens = TestJournal.AttachListTokens[2];
189                 
190         }
191         
192         ASSERT_EQ("VGhpcyBpcyBhbiBleGFtcGxlIGZpbGU=", AttachData);
193         ASSERT_EQ("text/plain", AttachDataFormatType);
194         ASSERT_EQ("BASE64", AttachDataEncoding);
195         ASSERT_EQ("BINARY", AttachDataValue);
196         ASSERT_EQ("STUPID=EXAMPLE", AttachDataTokens);
197         
198         // Tests for ATTENDEE. First ATTENDEE property.
200         std::string AttendeeDataMember;
201         std::string AttendeeDataDelegatedFrom;
202         std::string AttendeeDataDelegatedTo;
203         std::string AttendeeDataRole;
204         std::string AttendeeDataRSVP;
205         std::string AttendeeDataDirectoryEntry;
206         std::string AttendeeDataSentBy;
207         std::string AttendeeDataCommonName;
208         std::string AttendeeDataCalendarUserType;
209         std::string AttendeeDataParticipationStatus;
210         std::string AttendeeDataLanguage;
211         std::string AttendeeDataTokens;
212         std::string AttendeeData;
214         if (TestJournal.AttendeeList.begin() != TestJournal.AttendeeList.end()){
215                 
216                 AttendeeData = TestJournal.AttendeeList[0];
217                 
218         }
219         
220         ASSERT_EQ("Attendee One", AttendeeData);
221         
222         // Second ATTENDEE property.
223         
224         AttendeeData.clear();
225         
226         if (TestJournal.AttendeeList.size() > 1){
227                 
228                 AttendeeData = TestJournal.AttendeeList[1];
229                 
230         }
232         if (TestJournal.AttendeeList.size() > 1){
233                 
234                 AttendeeDataDelegatedFrom = TestJournal.AttendeeListDelegatedFrom[1];
235                 
236         }
237         
238         if (TestJournal.AttendeeList.size() > 1){
239                 
240                 AttendeeDataDelegatedTo = TestJournal.AttendeeListDelegatedTo[1];
241                 
242         }
244         if (TestJournal.AttendeeList.size() > 1){
245                 
246                 AttendeeDataRole = TestJournal.AttendeeListRole[1];
247                 
248         }
249         
250         if (TestJournal.AttendeeList.size() > 1){
251                 
252                 AttendeeDataRSVP = TestJournal.AttendeeListRSVP[1];
253                 
254         }
255         
256         ASSERT_EQ("Attendee Two", AttendeeData);
257         ASSERT_EQ("mailto:delegated.from@example.com", AttendeeDataDelegatedFrom);
258         ASSERT_EQ("mailto:delegated.to@example.com", AttendeeDataDelegatedTo);
259         ASSERT_EQ("CHAIR", AttendeeDataRole);
260         ASSERT_EQ("TRUE", AttendeeDataRSVP);
262         // Third ATTENDEE property.
263         
264         AttendeeData.clear();
265         
266         if (TestJournal.AttendeeList.size() > 2){
267                 
268                 AttendeeData = TestJournal.AttendeeList[2];
269                 
270         }
272         if (TestJournal.AttendeeList.size() > 2){
273                 
274                 AttendeeDataDirectoryEntry = TestJournal.AttendeeListDirectoryEntry[2];
275                 
276         }
277         
278         if (TestJournal.AttendeeList.size() > 2){
279                 
280                 AttendeeDataSentBy = TestJournal.AttendeeListSentBy[2];
281                 
282         }
284         if (TestJournal.AttendeeList.size() > 2){
285                 
286                 AttendeeDataCommonName = TestJournal.AttendeeListCommonName[2];
287                 
288         }
289         
290         if (TestJournal.AttendeeList.size() > 2){
291                 
292                 AttendeeDataCalendarUserType = TestJournal.AttendeeListCalendarUserType[2];
293                 
294         }
296         if (TestJournal.AttendeeList.size() > 2){
297                 
298                 AttendeeDataParticipationStatus = TestJournal.AttendeeListParticipationStatus[2];
299                 
300         }
302         if (TestJournal.AttendeeList.size() > 2){
303                 
304                 AttendeeDataLanguage = TestJournal.AttendeeListLanguage[2];
305                 
306         }
307         
308         if (TestJournal.AttendeeList.size() > 2){
309                 
310                 AttendeeDataTokens = TestJournal.AttendeeListTokens[2];
311                 
312         }
313         
314         ASSERT_EQ("Attendee Three", AttendeeData);
315         ASSERT_EQ("null:nodata", AttendeeDataDirectoryEntry);
316         ASSERT_EQ("mailto:sent.by@example.com", AttendeeDataSentBy);
317         ASSERT_EQ("Attendee The Third", AttendeeDataCommonName);
318         ASSERT_EQ("INDIVIDUAL", AttendeeDataCalendarUserType);
319         ASSERT_EQ("ACCEPTED", AttendeeDataParticipationStatus);
320         ASSERT_EQ("kw", AttendeeDataLanguage);
321         ASSERT_EQ("EXAMPLE=DATA", AttendeeDataTokens);
322         
323         // Get the first CATEGORIES.
324         
325         std::string CategoryData;
326         
327         if (TestJournal.CategoriesList.begin() != TestJournal.CategoriesList.end()){
328                 
329                 CategoryData = TestJournal.CategoriesList[0];
330                 
331         }
332         
333         ASSERT_EQ("CATEGORY ONE, CATEGORY TWO", CategoryData);
334         
335         CategoryData.clear();
337         std::string CategoryLanguage;
338         
339         // Get the second CATEGORIES.
340         
341         if (TestJournal.CategoriesList.size() > 1){
342                 
343                 CategoryData = TestJournal.CategoriesList[1];
344                 
345         }
346         
347         if (TestJournal.CategoriesList.size() > 1){
348                 
349                 CategoryLanguage = TestJournal.CategoriesListLanguage[1];
350                 
351         }
352                 
353         ASSERT_EQ("CATEGORY THREE, CATEGORY FOUR", CategoryData);
354         ASSERT_EQ("en", CategoryLanguage);
355         
356         CategoryData.clear();
357         CategoryLanguage.clear();
358         
359         // Get the third CATEGORIES.
360         
361         std::string CategoryTokens;
362         
363         if (TestJournal.CategoriesList.size() > 2){
364                 
365                 CategoryData = TestJournal.CategoriesList[2];
366                 
367         }
368         
369         if (TestJournal.CategoriesList.size() > 2){
370                 
371                 CategoryLanguage = TestJournal.CategoriesListLanguage[2];
372                 
373         }
374         
375         if (TestJournal.CategoriesList.size() > 2){
376                 
377                 CategoryTokens = TestJournal.CategoriesListTokens[2];
378                 
379         }
380                 
381         ASSERT_EQ("CATEGORY FIVE, CATEGORY SIX, CATEGORY SEVEN", CategoryData);
382         ASSERT_EQ("en-GB", CategoryLanguage);
383         ASSERT_EQ("SAMPLE=TOKEN", CategoryTokens);
384         
385         // Get the first COMMENT.
386         
387         std::string CommentData;
388         
389         if (TestJournal.CommentList.begin() != TestJournal.CommentList.end()){
390                 
391                 CommentData = TestJournal.CommentList[0];
392                 
393         }
394         
395         ASSERT_EQ("This is the first comment.", CommentData);
396         
397         // Get the second COMMENT.
398         
399         CommentData.clear();
400         
401         std::string CommentDataAltRep;
402         std::string CommentDataLanguage;
403         
404         if (TestJournal.CommentList.size() > 1){
405                 
406                 CommentData = TestJournal.CommentList[1];
407                 
408         }
409         
410         if (TestJournal.CommentList.size() > 1){
411                 
412                 CommentDataAltRep = TestJournal.CommentListAltRep[1];
413                 
414         }
415         
416         if (TestJournal.CommentList.size() > 1){
417                 
418                 CommentDataLanguage = TestJournal.CommentListLanguage[1];
419                 
420         }
421         
422         ASSERT_EQ("This is the second comment.", CommentData);
423         ASSERT_EQ("null:nodata", CommentDataAltRep);
424         ASSERT_EQ("en", CommentDataLanguage);
425         
426         // Get the third COMMENT.
427         
428         CommentData.clear();
429         
430         std::string CommentDataTokens;
431         
432         if (TestJournal.CommentList.size() > 2){
433                 
434                 CommentData = TestJournal.CommentList[2];
435                 
436         }
437         
438         if (TestJournal.CommentList.size() > 2){
439                 
440                 CommentDataTokens = TestJournal.CommentListTokens[2];
441                 
442         }
443         
444         ASSERT_EQ("This is the third comment.", CommentData);
445         ASSERT_EQ("ZEBRAS=YES", CommentDataTokens);
446         
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