Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
utf8: Implemented further UTF8 support
[xestiacalendar/.git] / source / tests / xestiacalendar_icaljournalsave.h
1 // xestiacalendar_icaljournalsave.h - Xestia Calendar iCalendar Journal 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/calendarjournal/CalendarJournal.h"
21 TEST(iCalendarSaveJournal, SaveEventTests){
23         CalendarJournalObject testJournal;
24         CalendarJournalObject testJournal2;
25         
26         // Load the test journal information.
27         
28         ASSERT_EQ(CALENDAROBJECTLOAD_OK, testJournal.LoadFile("iCalendarJournal-Load1.vcf"));
29         ASSERT_EQ(CALENDAROBJECTVALID_OK, testJournal.ValidBaseObject());
30         
31         ASSERT_EQ(CALENDAROBJECTSAVE_CANNOTOPEN, testJournal.SaveFile("/stupidfilelocation/dontsavehere.ics"));
32         
33         // Save the data to a string and compare the data.
35         // First journal file.
36         
37         std::string saveDataComparison = "BEGIN:VCALENDAR\n"
38         "VERSION:2.0\n"
39         "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
40         "BEGIN:VJOURNAL\n"
41         "UID:329128-12939123-123123-13\n"
42         "DTSTAMP:20160116T190200Z\n"
43         "SUMMARY:Unit Test Event 1 which has to be a really long summary as we don't k\n"
44         " now if multiple line processing is going to work without it. I mean seriousl\n"
45         " y, how annoying can this potentially be?\n"
46         "END:VJOURNAL\n"
47         "END:VCALENDAR";
48         
49         std::string saveData;
50         
51         testJournal.SaveString(&saveData);
52         
53         ASSERT_EQ(saveDataComparison, saveData);
54         
55         saveData.clear();
57         ASSERT_EQ(CALENDAROBJECTLOAD_OK, testJournal2.LoadFile("iCalendarJournal-Load2.vcf"));
58         ASSERT_EQ(CALENDAROBJECTVALID_OK, testJournal2.ValidBaseObject());
60         testJournal2.SaveString(&saveData);
61         
62         saveDataComparison = "BEGIN:VCALENDAR\n"
63         "VERSION:2.0\n"
64         "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
65         "BEGIN:VJOURNAL\n"
66         "UID;UNIQUEPARAM=CERTAINLY;OKAY=MAYBENOT:b3a16392-ad86-4061-be53-c215af2306c1\n"
67         "DTSTAMP;OTHER=PARAM:20160131T141500Z\n"
68         "SUMMARY;ALTREP=\"null:nodata\";LANGUAGE=kw;FAVOURITE=TOFU;NOTLIKE=NONE:A summar\n"
69         " y of the journal entry.\n"
70         "CLASS;CHOCOLATE=BAR:PUBLIC\n"
71         "DTSTART;VALUE=DATE-TIME;TZID=Europe/Truro;PARAMONE=YES;PARAMTWO=NO:20160131T1\n"
72         " 43500Z\n"
73         "LAST-MODIFIED;FUTURE=YES:20160131T143700Z\n"
74         "ORGANIZER;CN=ExampleOrganiser;DIR=\"null:nodata\";SENT-BY=\"mailto:organiser.nor\n"
75         " eply@example.com\";LANGUAGE=kw;HAPPY=DAYS:mailto:organiser@example.com\n"
76         "RECURRENCE-ID;TZID=Europe/Truro;RANGE=THISANDFUTURE;VALUE=DATE;EXAMPLE=DATA:2\n"
77         " 0160131\n"
78         "SEQUENCE;TEST=YAY:7\n"
79         "STATUS;LANGUAGE=kw;FAVOURITE=RICHTEA;NOTLIKE=UNKNOWN:2.0;Success\n"
80         "URL;EXTERNAL=YES:http://www.example.com/\n"
81         "RRULE;TEST=DATA:FREQ=DAILY;COUNT=10\n"
82         "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/\n"
83         "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/page2.htm\n"
84         " l\n"
85         "ATTACH;FMTTYPE=text/plain;VALUE=BINARY;ENCODING=BASE64;STUPID=EXAMPLE:VGhpcyB\n"
86         " pcyBhbiBleGFtcGxlIGZpbGU=\n"
87         "ATTENDEE:Attendee One\n"
88         "ATTENDEE;DELEGATED-FROM=\"mailto:delegated.from@example.com\";DELEGATED-TO=\"mai\n"
89         " lto:delegated.to@example.com\";ROLE=CHAIR;RSVP=TRUE:Attendee Two\n"
90         "ATTENDEE;DIR=\"null:nodata\";SENT-BY=\"mailto:sent.by@example.com\";CN=\"Attendee \n"
91         " The Third\";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED;LANGUAGE=kw;EXAMPLE=DATA:Atte\n"
92         " ndee Three\n"
93         "CATEGORIES:CATEGORY ONE, CATEGORY TWO\n"
94         "CATEGORIES;LANGUAGE=en:CATEGORY THREE, CATEGORY FOUR\n"
95         "CATEGORIES;LANGUAGE=en-GB;SAMPLE=TOKEN:CATEGORY FIVE, CATEGORY SIX, CATEGORY \n"
96         " SEVEN\n"
97         "COMMENT:This is the first comment.\n"
98         "COMMENT;ALTREP=\"null:nodata\";LANGUAGE=en:This is the second comment.\n"
99         "COMMENT;ZEBRAS=YES:This is the third comment.\n"
100         "CONTACT:First Contact\n"
101         "CONTACT;ALTREP=\"null:nodata\";LANGUAGE=en-GB:Second Contact\n"
102         "CONTACT;ZEBRAS=NO:Third Contact\n"
103         "DESCRIPTION:First Journal Entry Description\n"
104         "DESCRIPTION;ALTREP=\"null:nodata\";LANGUAGE=en-GB:This is the second journal de\n"
105         " scription.\n"
106         "DESCRIPTION;ZEBRAS=NO:This is the third journal description.\n"
107         "EXDATE:20160125T120000Z\n"
108         "EXDATE;TZID=Europe/Truro;VALUE=DATE-TIME:20160125T130000Z\n"
109         "EXDATE;ZOOP=ZIPPO:20160125T133000Z\n"
110         "RELATED-TO:person.1@example.com\n"
111         "RELATED-TO;RELTYPE=PARENT:person.2@example.com\n"
112         "RELATED-TO;SCHOOL=MEETING:person.3@example.com\n"
113         "RDATE:20160120\n"
114         "RDATE;VALUE=DATE;TZID=Europe/Truro:20160121\n"
115         "RDATE;ZILCH=DATA:20160520\n"
116         "REQUEST-STATUS:2.0;Success\n"
117         "REQUEST-STATUS;LANGUAGE=en:3.42;Really big irrecoverable error caused by the \n"
118         " user\n"
119         "REQUEST-STATUS;USER=MISSING:3.7;Invalid calendar user\n"
120         "X-EXAMPLE1:Moo\n"
121         "X-EXAMPLE1;ANIMAL=NOPE:Meep\n"
122         "X-EXAMPLE1;ANIMAL=CAT:Meow\n"
123         "X-EXAMPLE2:Dish\n"
124         "X-EXAMPLE2;OBJECT=KITCHEN:Fork\n"
125         "X-EXAMPLE2;OBJECT=LIVINGROOM:Table\n"
126         "X-STATUS;HOLIDAY=YES:Idle\n"
127         "X-TRANSPORT;PUBLIC=NO:Private Hire\n"
128         "X-PHANTOM-STATUS;HELP=NONE:None\n"
129         "END:VJOURNAL\n"
130         "END:VCALENDAR";
131         
132         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