Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added iCalendar Alarm Component Load unit test to the menu.
[xestiacalendar/.git] / source / tests / xestiacalendar_commonfunctions.h
1 #include "../common/file.h"
2 #include "../common/text.h"
4 TEST(CommonFunctions, FileTests){
5         
6         ASSERT_EQ(false, FileExists("iCalendarEvent-Missing.vcf"));
7         ASSERT_EQ(true, FileExists("iCalendarEvent-InvalidPermissions.vcf"));
8         
9 }
11 TEST(CommonFunctions, ProcessTextVectorsTests){
12         
13         // Setup the objects to be used for processing.
14         
15         vector<string> TextPropertiesExample1;
16         vector<string> TextValueExample1;
17         multimap<string, string> TextExample1TestResult;
18         
19         TextPropertiesExample1.push_back("ATTENDEE");
20         TextValueExample1.push_back("Example Attendee 1");
22         TextPropertiesExample1.push_back("ATTENDEE");
23         TextValueExample1.push_back("Example Attendee 2");
24         
25         TextPropertiesExample1.push_back("ATTENDEE");
26         TextValueExample1.push_back("Example Attendee 3");
27         
28         TextPropertiesExample1.push_back("CATEGORIES");
29         TextValueExample1.push_back("CATEGORY 1");
31         TextPropertiesExample1.push_back("CATEGORIES");
32         TextValueExample1.push_back("CATEGORY 2");
33         
34         TextPropertiesExample1.push_back("CATEGORIES");
35         TextValueExample1.push_back("CATEGORY 3");
37         TextPropertiesExample1.push_back("COMMENT");
38         TextValueExample1.push_back("This is the first comment.");
40         TextPropertiesExample1.push_back("COMMENT");
41         TextValueExample1.push_back("This is the second comment.");
42         
43         TextPropertiesExample1.push_back("COMMENT");
44         TextValueExample1.push_back("This is the third comment.");
46         TextPropertiesExample1.push_back("CONTACT;TEST=VALUE");
47         TextValueExample1.push_back("First Contact");
49         TextPropertiesExample1.push_back("CONTACT;LAZY=NOPE");
50         TextValueExample1.push_back("Second Contact");
52         TextPropertiesExample1.push_back("CONTACT;SETUP=NO");
53         TextValueExample1.push_back("Third Contact");
54         
55         TextPropertiesExample1.push_back("RESOURCES;ROOM=YES");
56         TextValueExample1.push_back("First Resource Widget");
58         TextPropertiesExample1.push_back("RESOURCES;ROOM=NO");
59         TextValueExample1.push_back("Second Resource Widget");
61         TextPropertiesExample1.push_back("RESOURCES;ROOM=UNKNOWN");
62         TextValueExample1.push_back("Third Resource Widget");
64         TextPropertiesExample1.push_back("RELATED;RELATION=NO");
65         TextValueExample1.push_back("First Relation");
67         TextPropertiesExample1.push_back("RELATED;RELATION=YES");
68         TextValueExample1.push_back("Second Relation");
70         TextPropertiesExample1.push_back("RELATED;RELATION=MAYBE");
71         TextValueExample1.push_back("Third Relation");
73         // Examples 1 & 2: ATTENDEE
75         TextExample1TestResult.insert(make_pair("ATTENDEE", "Example Attendee 1"));
76         TextExample1TestResult.insert(make_pair("ATTENDEE", "Example Attendee 2"));
77         TextExample1TestResult.insert(make_pair("ATTENDEE", "Example Attendee 3"));
78         
79         ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, true, "ATTENDEE"));
81         TextExample1TestResult.clear();
82         TextExample1TestResult.insert(make_pair("ATTENDEE", "Example Attendee 1"));
84         ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, false, "ATTENDEE"));
86         // Examples 3 & 4: CATEGORIES
88         TextExample1TestResult.clear();
89         TextExample1TestResult.insert(make_pair("CATEGORIES", "CATEGORY 1"));
90         TextExample1TestResult.insert(make_pair("CATEGORIES", "CATEGORY 2"));
91         TextExample1TestResult.insert(make_pair("CATEGORIES", "CATEGORY 3"));
93         ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, true, "CATEGORIES"));
95         TextExample1TestResult.clear();
96         TextExample1TestResult.insert(make_pair("CATEGORIES", "CATEGORY 1"));
98         // Examples 5 & 6: COMMENT
100         ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, false, "CATEGORIES"));
102         TextExample1TestResult.clear();
103         TextExample1TestResult.insert(make_pair("COMMENT", "This is the first comment."));
104         TextExample1TestResult.insert(make_pair("COMMENT", "This is the second comment."));
105         TextExample1TestResult.insert(make_pair("COMMENT", "This is the third comment."));
106         
107         ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, true, "COMMENT"));
109         TextExample1TestResult.clear();
110         TextExample1TestResult.insert(make_pair("COMMENT", "This is the first comment."));
112         // Examples 7 & 8: CONTACT;(properties)
114         ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, false, "COMMENT"));
116         TextExample1TestResult.clear();
117         TextExample1TestResult.insert(make_pair("CONTACT;TEST=VALUE", "First Contact"));
118         TextExample1TestResult.insert(make_pair("CONTACT;LAZY=NOPE", "Second Contact"));
119         TextExample1TestResult.insert(make_pair("CONTACT;SETUP=NO", "Third Contact"));
120         
121         ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, true, "CONTACT"));
123         TextExample1TestResult.clear();
124         TextExample1TestResult.insert(make_pair("CONTACT;TEST=VALUE", "First Contact"));
126         // Examples 9 & 10: RESOURCES;(properties)
128         ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, false, "CONTACT"));
130         TextExample1TestResult.clear();
131         TextExample1TestResult.insert(make_pair("RESOURCES;ROOM=YES", "First Resource Widget"));
132         TextExample1TestResult.insert(make_pair("RESOURCES;ROOM=NO", "Second Resource Widget"));
133         TextExample1TestResult.insert(make_pair("RESOURCES;ROOM=UNKNOWN", "Third Resource Widget"));
135         ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, true, "RESOURCES"));
137         TextExample1TestResult.clear();
138         TextExample1TestResult.insert(make_pair("RESOURCES;ROOM=YES", "First Resource Widget"));
140         ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, false, "RESOURCES"));
142         // Examples 11 & 12: RELATED;(properties)
144         TextExample1TestResult.clear();
145         TextExample1TestResult.insert(make_pair("RELATED;RELATION=NO", "First Relation"));
146         TextExample1TestResult.insert(make_pair("RELATED;RELATION=YES", "Second Relation"));
147         TextExample1TestResult.insert(make_pair("RELATED;RELATION=MAYBE", "Third Relation"));
149         ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, true, "RELATED"));
151         TextExample1TestResult.clear();
152         TextExample1TestResult.insert(make_pair("RELATED;RELATION=NO", "First Relation"));
154         ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, false, "RELATED"));
158 TEST(CommonFunctions, SplitValuesTests){
159         
160         map<string, string> TextExample1TestResult;
161         
162         TextExample1TestResult.insert(make_pair("RELATION", "NO"));
163         TextExample1TestResult.insert(make_pair("TEST", "YES"));
164         TextExample1TestResult.insert(make_pair("DATA", "SOMEDATA"));
165         
166         ASSERT_EQ(TextExample1TestResult, SplitValues("TEST;RELATION=NO;TEST=YES;DATA=SOMEDATA"));
167         
170 TEST(CommonFunctions, SplitNameValueTests){
171         
172         PropertyNameValue NameValueResult;
173                 
174         NameValueResult = SplitNameValue("TEST=OK");
175         
176         string PropertyName = NameValueResult.Name;
177         string PropertyValue = NameValueResult.Value;
178         
179         ASSERT_EQ(PropertyName, "TEST");
180         ASSERT_EQ(PropertyValue, "OK");
181         
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