X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;ds=inline;f=source%2Ftests%2Fxestiacalendar_commonfunctions.h;h=85ef33e164ac1776d13607438e5ca3331d75684e;hb=f3908f3b7bf98079d82fde9d2180c337f565d8c6;hp=22ea5d4655b6477ff5340596bfa4bcf1f41412ba;hpb=c79fde81cd023afb49757695c34b56ff594b5e2d;p=xestiacalendar%2F.git
diff --git a/source/tests/xestiacalendar_commonfunctions.h b/source/tests/xestiacalendar_commonfunctions.h
index 22ea5d4..85ef33e 100644
--- a/source/tests/xestiacalendar_commonfunctions.h
+++ b/source/tests/xestiacalendar_commonfunctions.h
@@ -1,3 +1,21 @@
+// xestiacalendar_commonfunctions.h - Xestia Calendar Common Functions Unit Tests
+//
+// (c) 2016 Xestia Software Development.
+//
+// This file is part of Xestia Calendar.
+//
+// Xestia Address Book is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by the
+// Free Software Foundation, version 3 of the license.
+//
+// Xestia Address Book is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with Xestia Calendar. If not, see
+
#include "../common/file.h"
#include "../common/text.h"
@@ -70,6 +88,8 @@ TEST(CommonFunctions, ProcessTextVectorsTests){
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"));
@@ -81,6 +101,8 @@ TEST(CommonFunctions, ProcessTextVectorsTests){
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"));
@@ -91,6 +113,8 @@ TEST(CommonFunctions, ProcessTextVectorsTests){
TextExample1TestResult.clear();
TextExample1TestResult.insert(make_pair("CATEGORIES", "CATEGORY 1"));
+ // Examples 5 & 6: COMMENT
+
ASSERT_EQ(TextExample1TestResult, ProcessTextVectors(&TextPropertiesExample1, &TextValueExample1, false, "CATEGORIES"));
TextExample1TestResult.clear();
@@ -100,6 +124,13 @@ TEST(CommonFunctions, ProcessTextVectorsTests){
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"));
@@ -107,6 +138,13 @@ TEST(CommonFunctions, ProcessTextVectorsTests){
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"));
@@ -114,6 +152,13 @@ TEST(CommonFunctions, ProcessTextVectorsTests){
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"));
@@ -121,4 +166,35 @@ TEST(CommonFunctions, ProcessTextVectorsTests){
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 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