Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added menu option for unit testing the CalDAV Object.
[xestiacalendar/.git] / source / tests / xestiacalendar_commonfunctions.h
index 62a8aee..a332228 100644 (file)
@@ -14,8 +14,7 @@ TEST(CommonFunctions, ProcessTextVectorsTests){
        
        vector<string> TextPropertiesExample1;
        vector<string> TextValueExample1;
-       //multimap<string, string> TextExample1Results;
-       multimap<string, string> TextExample1TestResult1;
+       multimap<string, string> TextExample1TestResult;
        
        TextPropertiesExample1.push_back("ATTENDEE");
        TextValueExample1.push_back("Example Attendee 1");
@@ -25,11 +24,159 @@ TEST(CommonFunctions, ProcessTextVectorsTests){
        
        TextPropertiesExample1.push_back("ATTENDEE");
        TextValueExample1.push_back("Example Attendee 3");
+       
+       TextPropertiesExample1.push_back("CATEGORIES");
+       TextValueExample1.push_back("CATEGORY 1");
+
+       TextPropertiesExample1.push_back("CATEGORIES");
+       TextValueExample1.push_back("CATEGORY 2");
+       
+       TextPropertiesExample1.push_back("CATEGORIES");
+       TextValueExample1.push_back("CATEGORY 3");
+
+       TextPropertiesExample1.push_back("COMMENT");
+       TextValueExample1.push_back("This is the first comment.");
+
+       TextPropertiesExample1.push_back("COMMENT");
+       TextValueExample1.push_back("This is the second comment.");
+       
+       TextPropertiesExample1.push_back("COMMENT");
+       TextValueExample1.push_back("This is the third comment.");
+
+       TextPropertiesExample1.push_back("CONTACT;TEST=VALUE");
+       TextValueExample1.push_back("First Contact");
+
+       TextPropertiesExample1.push_back("CONTACT;LAZY=NOPE");
+       TextValueExample1.push_back("Second Contact");
+
+       TextPropertiesExample1.push_back("CONTACT;SETUP=NO");
+       TextValueExample1.push_back("Third Contact");
+       
+       TextPropertiesExample1.push_back("RESOURCES;ROOM=YES");
+       TextValueExample1.push_back("First Resource Widget");
+
+       TextPropertiesExample1.push_back("RESOURCES;ROOM=NO");
+       TextValueExample1.push_back("Second Resource Widget");
+
+       TextPropertiesExample1.push_back("RESOURCES;ROOM=UNKNOWN");
+       TextValueExample1.push_back("Third Resource Widget");
+
+       TextPropertiesExample1.push_back("RELATED;RELATION=NO");
+       TextValueExample1.push_back("First Relation");
+
+       TextPropertiesExample1.push_back("RELATED;RELATION=YES");
+       TextValueExample1.push_back("Second Relation");
 
-       TextExample1TestResult1.insert(make_pair("ATTENDEE", "Example Attendee 1"));
-       TextExample1TestResult1.insert(make_pair("ATTENDEE", "Example Attendee 2"));
-       TextExample1TestResult1.insert(make_pair("ATTENDEE", "Example Attendee 3"));
+       TextPropertiesExample1.push_back("RELATED;RELATION=MAYBE");
+       TextValueExample1.push_back("Third Relation");
+
+       // Examples 1 & 2: ATTENDEE
+
+       TextExample1TestResult.insert(make_pair("ATTENDEE", "Example Attendee 1"));
+       TextExample1TestResult.insert(make_pair("ATTENDEE", "Example Attendee 2"));
+       TextExample1TestResult.insert(make_pair("ATTENDEE", "Example Attendee 3"));
+       
+       ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, true, "ATTENDEE"));
+
+       TextExample1TestResult.clear();
+       TextExample1TestResult.insert(make_pair("ATTENDEE", "Example Attendee 1"));
+
+       ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, false, "ATTENDEE"));
+
+       // Examples 3 & 4: CATEGORIES
+
+       TextExample1TestResult.clear();
+       TextExample1TestResult.insert(make_pair("CATEGORIES", "CATEGORY 1"));
+       TextExample1TestResult.insert(make_pair("CATEGORIES", "CATEGORY 2"));
+       TextExample1TestResult.insert(make_pair("CATEGORIES", "CATEGORY 3"));
+
+       ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, true, "CATEGORIES"));
+
+       TextExample1TestResult.clear();
+       TextExample1TestResult.insert(make_pair("CATEGORIES", "CATEGORY 1"));
+
+       // Examples 5 & 6: COMMENT
+
+       ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, false, "CATEGORIES"));
+
+       TextExample1TestResult.clear();
+       TextExample1TestResult.insert(make_pair("COMMENT", "This is the first comment."));
+       TextExample1TestResult.insert(make_pair("COMMENT", "This is the second comment."));
+       TextExample1TestResult.insert(make_pair("COMMENT", "This is the third comment."));
        
-       ASSERT_EQ(TextExample1TestResult1, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, true, "ATTENDEE"));
+       ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, true, "COMMENT"));
+
+       TextExample1TestResult.clear();
+       TextExample1TestResult.insert(make_pair("COMMENT", "This is the first comment."));
+
+       // Examples 7 & 8: CONTACT;(properties)
 
+       ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, false, "COMMENT"));
+
+       TextExample1TestResult.clear();
+       TextExample1TestResult.insert(make_pair("CONTACT;TEST=VALUE", "First Contact"));
+       TextExample1TestResult.insert(make_pair("CONTACT;LAZY=NOPE", "Second Contact"));
+       TextExample1TestResult.insert(make_pair("CONTACT;SETUP=NO", "Third Contact"));
+       
+       ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, true, "CONTACT"));
+
+       TextExample1TestResult.clear();
+       TextExample1TestResult.insert(make_pair("CONTACT;TEST=VALUE", "First Contact"));
+
+       // Examples 9 & 10: RESOURCES;(properties)
+
+       ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, false, "CONTACT"));
+
+       TextExample1TestResult.clear();
+       TextExample1TestResult.insert(make_pair("RESOURCES;ROOM=YES", "First Resource Widget"));
+       TextExample1TestResult.insert(make_pair("RESOURCES;ROOM=NO", "Second Resource Widget"));
+       TextExample1TestResult.insert(make_pair("RESOURCES;ROOM=UNKNOWN", "Third Resource Widget"));
+
+       ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, true, "RESOURCES"));
+
+       TextExample1TestResult.clear();
+       TextExample1TestResult.insert(make_pair("RESOURCES;ROOM=YES", "First Resource Widget"));
+
+       ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, false, "RESOURCES"));
+
+       // Examples 11 & 12: RELATED;(properties)
+
+       TextExample1TestResult.clear();
+       TextExample1TestResult.insert(make_pair("RELATED;RELATION=NO", "First Relation"));
+       TextExample1TestResult.insert(make_pair("RELATED;RELATION=YES", "Second Relation"));
+       TextExample1TestResult.insert(make_pair("RELATED;RELATION=MAYBE", "Third Relation"));
+
+       ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, true, "RELATED"));
+
+       TextExample1TestResult.clear();
+       TextExample1TestResult.insert(make_pair("RELATED;RELATION=NO", "First Relation"));
+
+       ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, false, "RELATED"));
+
+}
+
+TEST(CommonFunctions, SplitValuesTests){
+       
+       map<string, string> TextExample1TestResult;
+       
+       TextExample1TestResult.insert(make_pair("RELATION", "NO"));
+       TextExample1TestResult.insert(make_pair("TEST", "YES"));
+       TextExample1TestResult.insert(make_pair("DATA", "SOMEDATA"));
+       
+       ASSERT_EQ(TextExample1TestResult, SplitValues("TEST;RELATION=NO;TEST=YES;DATA=SOMEDATA"));
+       
+}
+
+TEST(CommonFunctions, SplitNameValueTests){
+       
+       PropertyNameValue NameValueResult;
+               
+       NameValueResult = SplitNameValue("TEST=OK");
+       
+       string PropertyName = NameValueResult.Name;
+       string PropertyValue = NameValueResult.Value;
+       
+       ASSERT_EQ(PropertyName, "TEST");
+       ASSERT_EQ(PropertyValue, "OK");
+       
 }
\ No newline at end of file
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