From: Steve Brokenshire Date: Sun, 20 Dec 2015 17:16:03 +0000 (+0000) Subject: Added source code, headers and unit tests for the RELATED and URL vCard Properties... X-Git-Tag: release-0.09~226 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=5d618c0c96ee88769cc63b0a6fe03679cf68bd18;p=xestiaab%2F.git Added source code, headers and unit tests for the RELATED and URL vCard Properties for ContactDataObject. --- diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index f7a7e91..13c869f 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -90,6 +90,8 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ int TelephoneCount = 0; int LanguageCount = 0; int GeographicCount = 0; + int RelatedCount = 0; + int URLCount = 0; wxString ContactLine; wxString PropertyLine; wxString PropertySeg1; @@ -266,6 +268,20 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount); GeographicCount++; + } else if (Property == wxT("RELATED")){ + + // See fromContactEditor-LoadRelated.cpp + + ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount); + RelatedCount++; + + } else if (Property == wxT("URL")){ + + // See frmContactEditor-LoadURL.cpp + + ProcessURL(PropertySeg1, PropertySeg2, &URLCount); + URLCount++; + } } @@ -2560,6 +2576,413 @@ void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString Proper } +void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){ + + size_t intPropertyLen = PropertySeg1.Len(); + std::map SplitPoints; + std::map SplitLength; + std::map::iterator SLiter; + wxString PropertyData; + wxString PropertyName; + wxString PropertyValue; + wxString PropertyTokens; + wxString RelatedType; + wxString RelatedTypeOriginal; + wxString RelatedName; + bool FirstToken = TRUE; + int intSplitsFound = 0; + int intSplitSize = 0; + int intPrevValue = 9; + int intPref = 0; + long ListCtrlIndex; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 8; + + // Look for type before continuing. + + for (std::map::iterator intiter = SplitPoints.begin(); + intiter != SplitPoints.end(); ++intiter){ + + SLiter = SplitLength.find(intiter->first); + + PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second)); + + wxStringTokenizer PropertyElement (PropertyData, wxT("=")); + PropertyName = PropertyElement.GetNextToken(); + PropertyValue = PropertyElement.GetNextToken(); + + intPrevValue = intiter->second; + + // Process these. + + RelatedTypeOriginal = PropertyValue; + + if (PropertyName == wxT("TYPE")){ + + if (PropertyValue == wxT("contact")){ + + RelatedType = _("Contact"); + + } else if (PropertyValue == wxT("acquaintance")){ + + RelatedType = _("Acquaintance"); + + } else if (PropertyValue == wxT("friend")){ + + RelatedType = _("Friend"); + + } else if (PropertyValue == wxT("met")){ + + RelatedType = _("Met"); + + } else if (PropertyValue == wxT("co-worker")){ + + RelatedType = _("Co-worker"); + + } else if (PropertyValue == wxT("colleague")){ + + RelatedType = _("Colleague"); + + } else if (PropertyValue == wxT("co-resident")){ + + RelatedType = _("Co-resident"); + + } else if (PropertyValue == wxT("neighbor")){ + + RelatedType = _("Neighbour"); + + } else if (PropertyValue == wxT("child")){ + + RelatedType = _("Child"); + + } else if (PropertyValue == wxT("parent")){ + + RelatedType = _("Parent"); + + } else if (PropertyValue == wxT("sibling")){ + + RelatedType = _("Sibling"); + + } else if (PropertyValue == wxT("spouse")){ + + RelatedType = _("Spouse"); + + } else if (PropertyValue == wxT("kin")){ + + RelatedType = _("Kin"); + + } else if (PropertyValue == wxT("muse")){ + + RelatedType = _("Muse"); + + } else if (PropertyValue == wxT("crush")){ + + RelatedType = _("Crush"); + + } else if (PropertyValue == wxT("date")){ + + RelatedType = _("Date"); + + } else if (PropertyValue == wxT("sweetheart")){ + + RelatedType = _("Sweetheart"); + + } else if (PropertyValue == wxT("me")){ + + RelatedType = _("Me"); + + } else if (PropertyValue == wxT("agent")){ + + RelatedType = _("Agent"); + + } else if (PropertyValue == wxT("emergency")){ + + RelatedType = _("Emergency"); + + } else { + + RelatedType = PropertyValue; + + } + + } + + } + + intPrevValue = 8; + + for (std::map::iterator intiter = SplitPoints.begin(); + intiter != SplitPoints.end(); ++intiter){ + + SLiter = SplitLength.find(intiter->first); + + PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second)); + + wxStringTokenizer PropertyElement (PropertyData, wxT("=")); + PropertyName = PropertyElement.GetNextToken(); + PropertyValue = PropertyElement.GetNextToken(); + + intPrevValue = intiter->second; + + // Process properties. + + size_t intPropertyValueLen = PropertyValue.Len(); + + if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){ + + PropertyValue.Trim(); + PropertyValue.RemoveLast(); + + } + + if (PropertyValue.Mid(0, 1) == wxT("\"")){ + + PropertyValue.Remove(0, 1); + + } + + CaptureString(&PropertyValue, FALSE); + + if (PropertyName == wxT("ALTID")){ + + GeneralRelatedListAltID.erase(*RelatedCount); + GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue)); + + } else if (PropertyName == wxT("PID")){ + + GeneralRelatedListPID.erase(*RelatedCount); + GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue)); + + } else if (PropertyName == wxT("PREF")){ + + intPref = wxAtoi(PropertyValue); + + if (intPref > 0 && intPref < 101){ + + GeneralRelatedListPref.erase(*RelatedCount); + GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, intPref)); + + + } + + } else if (PropertyName == wxT("LANGUAGE")){ + + GeneralRelatedListLanguage.erase(*RelatedCount); + GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue)); + + } else if (PropertyName != wxT("TYPE")) { + + // Something else we don't know about so append + // to the tokens variable. + + if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){ + + if (FirstToken == TRUE){ + + PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue); + FirstToken = FALSE; + + } else { + + PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue); + + } + + } + + } + + } + + // Add the data to the General/Home/Work address variables. + + GeneralRelatedList.erase(*RelatedCount); + GeneralRelatedListRelType.erase(*RelatedCount); + GeneralRelatedListType.erase(*RelatedCount); + GeneralRelatedListTokens.erase(*RelatedCount); + GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2)); + GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType)); + GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType)); + GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens)); + +} + +void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){ + + std::map SplitPoints; + std::map SplitLength; + std::map::iterator SLiter; + wxString PropertyData; + wxString PropertyName; + wxString PropertyValue; + wxString PropertyTokens; + bool FirstToken = TRUE; + int intPrevValue = 5; + int intPref = 0; + int intType = 0; + long ListCtrlIndex; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 4; + + PropertyType PropType = PROPERTY_NONE; + + // Look for type before continuing. + + CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType); + + // Setup the pointers. + + std::map *WebsiteList = NULL; + std::map *WebsiteListAltID = NULL; + std::map *WebsiteListPID = NULL; + std::map *WebsiteListType = NULL; + std::map *WebsiteListTokens = NULL; + std::map *WebsiteListMediatype = NULL; + std::map *WebsiteListPref = NULL; + + // Setup blank lines for later on. + + switch(PropType){ + case PROPERTY_NONE: + WebsiteList = &GeneralWebsiteList; + WebsiteListType = &GeneralWebsiteListType; + WebsiteListAltID = &GeneralWebsiteListAltID; + WebsiteListPID = &GeneralWebsiteListPID; + WebsiteListTokens = &GeneralWebsiteListTokens; + WebsiteListMediatype = &GeneralWebsiteListMediatype; + WebsiteListPref = &GeneralWebsiteListPref; + break; + case PROPERTY_HOME: + WebsiteList = &HomeWebsiteList; + WebsiteListType = &HomeWebsiteListType; + WebsiteListAltID = &HomeWebsiteListAltID; + WebsiteListPID = &HomeWebsiteListPID; + WebsiteListTokens = &HomeWebsiteListTokens; + WebsiteListMediatype = &HomeWebsiteListMediatype; + WebsiteListPref = &HomeWebsiteListPref; + break; + case PROPERTY_WORK: + WebsiteList = &BusinessWebsiteList; + WebsiteListType = &BusinessWebsiteListType; + WebsiteListAltID = &BusinessWebsiteListAltID; + WebsiteListPID = &BusinessWebsiteListPID; + WebsiteListTokens = &BusinessWebsiteListTokens; + WebsiteListMediatype = &BusinessWebsiteListMediatype; + WebsiteListPref = &BusinessWebsiteListPref; + break; + } + + intPrevValue = 4; + + for (std::map::iterator intiter = SplitPoints.begin(); + intiter != SplitPoints.end(); ++intiter){ + + SLiter = SplitLength.find(intiter->first); + + PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second)); + + wxStringTokenizer PropertyElement (PropertyData, wxT("=")); + PropertyName = PropertyElement.GetNextToken(); + PropertyValue = PropertyElement.GetNextToken(); + + intPrevValue = intiter->second; + + // Process properties. + + size_t intPropertyValueLen = PropertyValue.Len(); + + if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){ + + PropertyValue.Trim(); + PropertyValue.RemoveLast(); + + } + + if (PropertyValue.Mid(0, 1) == wxT("\"")){ + + PropertyValue.Remove(0, 1); + + } + + CaptureString(&PropertyValue, FALSE); + + if (PropertyName == wxT("ALTID")){ + + WebsiteListAltID->erase(*URLCount); + WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue)); + + } else if (PropertyName == wxT("PID")){ + + WebsiteListPID->erase(*URLCount); + WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue)); + + } else if (PropertyName == wxT("PREF")){ + + int PriorityNumber = 0; + bool ValidNumber = TRUE; + + try{ + PriorityNumber = std::stoi(PropertyValue.ToStdString()); + } + + catch(std::invalid_argument &e){ + ValidNumber = FALSE; + } + + if (ValidNumber == TRUE){ + + WebsiteListPref->erase(*URLCount); + WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber)); + + } + + } else if (PropertyName == wxT("MEDIATYPE")){ + + WebsiteListMediatype->erase(*URLCount); + WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue)); + + } else { + + // Something else we don't know about so append + // to the tokens variable. + + if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){ + + if (FirstToken == TRUE){ + + PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue); + FirstToken = FALSE; + + } else { + + PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue); + + } + + } + + } + + } + + // Add the data to the General/Home/Work address variables. + + CaptureString(&PropertySeg2, FALSE); + + WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2)); + + if (!PropertyTokens.IsEmpty()){ + + WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens)); + + } + +} + void SplitValues(wxString *PropertyLine, std::map *SplitPoints, std::map *SplitLength, diff --git a/source/contacteditor/ContactDataObject.h b/source/contacteditor/ContactDataObject.h index fad1f00..02b6820 100644 --- a/source/contacteditor/ContactDataObject.h +++ b/source/contacteditor/ContactDataObject.h @@ -52,6 +52,26 @@ enum PropertyType{ class ContactDataObject{ + private: + + void ProcessKind(wxString KindData); + void ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount); + void ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount); + void ProcessN(wxString PropertySeg1, wxString PropertySeg2); + void ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount); + void ProcessGender(wxString PropertySeg1, wxString PropertySeg2); + void ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2); + void ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2); + void ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount); + void ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount); + void ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount); + void ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount); + void ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount); + void ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount); + void ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount); + void ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount); + void ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount); + public: ContactKindType ContactKind = CONTACTKIND_NONE; @@ -290,15 +310,6 @@ class ContactDataObject{ std::map HomeGeographyListMediatype; std::map HomeGeographyListPref; - std::map HomeRelatedList; - std::map HomeRelatedListRelType; - std::map HomeRelatedListLanguage; - std::map HomeRelatedListAltID; - std::map HomeRelatedListPID; - std::map HomeRelatedListType; - std::map HomeRelatedListTokens; - std::map HomeRelatedListPref; - std::map HomeWebsiteList; std::map HomeWebsiteListAltID; std::map HomeWebsiteListPID; @@ -410,16 +421,7 @@ class ContactDataObject{ std::map BusinessGeographyListType; std::map BusinessGeographyListTokens; std::map BusinessGeographyListMediatype; - std::map BusinessGeographyListPref; - - std::map BusinessRelatedList; - std::map BusinessRelatedListRelType; - std::map BusinessRelatedListLanguage; - std::map BusinessRelatedListAltID; - std::map BusinessRelatedListPID; - std::map BusinessRelatedListType; - std::map BusinessRelatedListTokens; - std::map BusinessRelatedListPref; + std::map BusinessGeographyListPref; std::map BusinessWebsiteList; std::map BusinessWebsiteListAltID; @@ -567,21 +569,6 @@ class ContactDataObject{ // Subroutines. ContactLoadStatus LoadFile(wxString Filename); - void ProcessKind(wxString KindData); - void ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount); - void ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount); - void ProcessN(wxString PropertySeg1, wxString PropertySeg2); - void ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount); - void ProcessGender(wxString PropertySeg1, wxString PropertySeg2); - void ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2); - void ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2); - void ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount); - void ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount); - void ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount); - void ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount); - void ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount); - void ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount); - void ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount); }; diff --git a/source/tests/LoadCheck-Load4.vcf b/source/tests/LoadCheck-Load4.vcf index 207287e..64651dc 100644 --- a/source/tests/LoadCheck-Load4.vcf +++ b/source/tests/LoadCheck-Load4.vcf @@ -52,4 +52,12 @@ GEO;TYPE=home;ALTID=140;MEDIATYPE=text/ratherplain;PID=70;PREF=1;POS=Nope:ge o:7.0,7.0 GEO;TYPE=work;ALTID=75;PID=32;TYPE=text/greenplain;PREF=4;POS=Money;MEDIATYP E=text/greenplain:geo:14.0,14.0 +RELATED;TYPE=Kin;ALTID=5;PID=10;PREF=20;OPTION=Yes:Friend Test +RELATED;TYPE=spouse;ALTID=1;PID=2;PREF=3;OPTION=No:Friend Test Two +RELATED;TYPE=muse;ALTID=4;PID=5;PREF=6;OPTION=Maybe:Friend Test Three +URL;ALTID=0;PID=1;PREF=2;MEDIATYPE=text/plain;MEEP=Moo:http://example.com/ +URL;TYPE=home;ALTID=10;PID=11;PREF=12;MEDIATYPE=grass/soggy;BON=Bon:http://e + xample.com/home/ +URL;TYPE=work;ALTID=20;PID=21;PREF=22;MEDIATYPE=chocolate/yummy;YES=No:http: + //example.com/business/ END:VCARD diff --git a/source/tests/xestiaab_contactload.h b/source/tests/xestiaab_contactload.h index f4be7fb..fc7a48c 100644 --- a/source/tests/xestiaab_contactload.h +++ b/source/tests/xestiaab_contactload.h @@ -1336,4 +1336,246 @@ TEST(ContactLoad, GeographicTests){ } +TEST(ContactLoad, RelatedTests){ + + ContactDataObject TestFile; + + // Check that the vCard 4.0 file loads OK. + + ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf")); + + std::map::iterator TestFileIter; + std::map::iterator TestFileIntIter; + + // Start with the first relation. + + TestFileIter = TestFile.GeneralRelatedList.find(0); + ASSERT_NE(TestFile.GeneralRelatedList.end(), TestFileIter); + ASSERT_EQ("Friend Test", TestFileIter->second); + + // Check the TYPE section. + + TestFileIter = TestFile.GeneralRelatedListType.find(0); + ASSERT_NE(TestFile.GeneralRelatedListType.end(), TestFileIter); + ASSERT_EQ("Kin", TestFileIter->second); + + // Check the ALTID section. + + TestFileIter = TestFile.GeneralRelatedListAltID.find(0); + ASSERT_NE(TestFile.GeneralRelatedListAltID.end(), TestFileIter); + ASSERT_EQ("5", TestFileIter->second); + + // Check the PID section. + + TestFileIter = TestFile.GeneralRelatedListPID.find(0); + ASSERT_NE(TestFile.GeneralRelatedListPID.end(), TestFileIter); + ASSERT_EQ("10", TestFileIter->second); + + // Check the PREF section. + + TestFileIntIter = TestFile.GeneralRelatedListPref.find(0); + ASSERT_NE(TestFile.GeneralRelatedListPref.end(), TestFileIntIter); + ASSERT_EQ(20, TestFileIntIter->second); + + // Check the extra tokens. + + TestFileIter = TestFile.GeneralRelatedListTokens.find(0); + ASSERT_NE(TestFile.GeneralRelatedListTokens.end(), TestFileIter); + ASSERT_EQ("OPTION=Yes", TestFileIter->second); + + // Start with the second relation. + + TestFileIter = TestFile.GeneralRelatedList.find(1); + ASSERT_NE(TestFile.GeneralRelatedList.end(), TestFileIter); + ASSERT_EQ("Friend Test Two", TestFileIter->second); + + // Check the TYPE section. + + TestFileIter = TestFile.GeneralRelatedListType.find(1); + ASSERT_NE(TestFile.GeneralRelatedListType.end(), TestFileIter); + ASSERT_EQ("Spouse", TestFileIter->second); + + // Check the ALTID section. + + TestFileIter = TestFile.GeneralRelatedListAltID.find(1); + ASSERT_NE(TestFile.GeneralRelatedListAltID.end(), TestFileIter); + ASSERT_EQ("1", TestFileIter->second); + + // Check the PID section. + + TestFileIter = TestFile.GeneralRelatedListPID.find(1); + ASSERT_NE(TestFile.GeneralRelatedListPID.end(), TestFileIter); + ASSERT_EQ("2", TestFileIter->second); + + // Check the PREF section. + + TestFileIntIter = TestFile.GeneralRelatedListPref.find(1); + ASSERT_NE(TestFile.GeneralRelatedListPref.end(), TestFileIntIter); + ASSERT_EQ(3, TestFileIntIter->second); + + // Check the extra tokens. + + TestFileIter = TestFile.GeneralRelatedListTokens.find(1); + ASSERT_NE(TestFile.GeneralRelatedListTokens.end(), TestFileIter); + ASSERT_EQ("OPTION=No", TestFileIter->second); + + // Start with the second relation. + + TestFileIter = TestFile.GeneralRelatedList.find(2); + ASSERT_NE(TestFile.GeneralRelatedList.end(), TestFileIter); + ASSERT_EQ("Friend Test Three", TestFileIter->second); + + // Check the TYPE section. + + TestFileIter = TestFile.GeneralRelatedListType.find(2); + ASSERT_NE(TestFile.GeneralRelatedListType.end(), TestFileIter); + ASSERT_EQ("Muse", TestFileIter->second); + + // Check the ALTID section. + + TestFileIter = TestFile.GeneralRelatedListAltID.find(2); + ASSERT_NE(TestFile.GeneralRelatedListAltID.end(), TestFileIter); + ASSERT_EQ("4", TestFileIter->second); + + // Check the PID section. + + TestFileIter = TestFile.GeneralRelatedListPID.find(2); + ASSERT_NE(TestFile.GeneralRelatedListPID.end(), TestFileIter); + ASSERT_EQ("5", TestFileIter->second); + + // Check the PREF section. + + TestFileIntIter = TestFile.GeneralRelatedListPref.find(2); + ASSERT_NE(TestFile.GeneralRelatedListPref.end(), TestFileIntIter); + ASSERT_EQ(6, TestFileIntIter->second); + + // Check the extra tokens. + + TestFileIter = TestFile.GeneralRelatedListTokens.find(2); + ASSERT_NE(TestFile.GeneralRelatedListTokens.end(), TestFileIter); + ASSERT_EQ("OPTION=Maybe", TestFileIter->second); + +} + +TEST(ContactLoad, URLTests){ + + ContactDataObject TestFile; + + // Check that the vCard 4.0 file loads OK. + + ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf")); + + std::map::iterator TestFileIter; + std::map::iterator TestFileIntIter; + + // Start with the general URL. + + TestFileIter = TestFile.GeneralWebsiteList.find(0); + ASSERT_NE(TestFile.GeneralWebsiteList.end(), TestFileIter); + ASSERT_EQ("http://example.com/", TestFileIter->second); + + // Check the ALTID section. + + TestFileIter = TestFile.GeneralWebsiteListAltID.find(0); + ASSERT_NE(TestFile.GeneralWebsiteListAltID.end(), TestFileIter); + ASSERT_EQ("0", TestFileIter->second); + + // Check the PID section. + + TestFileIter = TestFile.GeneralWebsiteListPID.find(0); + ASSERT_NE(TestFile.GeneralWebsiteListPID.end(), TestFileIter); + ASSERT_EQ("1", TestFileIter->second); + + // Check the MEDIATYPE section. + + TestFileIter = TestFile.GeneralWebsiteListMediatype.find(0); + ASSERT_NE(TestFile.GeneralWebsiteListMediatype.end(), TestFileIter); + ASSERT_EQ("text/plain", TestFileIter->second); + + // Check the PREF section. + + TestFileIntIter = TestFile.GeneralWebsiteListPref.find(0); + ASSERT_NE(TestFile.GeneralWebsiteListPref.end(), TestFileIntIter); + ASSERT_EQ(2, TestFileIntIter->second); + + // Check the extra tokens. + + TestFileIter = TestFile.GeneralWebsiteListTokens.find(0); + ASSERT_NE(TestFile.GeneralWebsiteListTokens.end(), TestFileIter); + ASSERT_EQ("MEEP=Moo", TestFileIter->second); + + // Start with the home URL. + + TestFileIter = TestFile.HomeWebsiteList.find(1); + ASSERT_NE(TestFile.HomeWebsiteList.end(), TestFileIter); + ASSERT_EQ("http://example.com/home/", TestFileIter->second); + + // Check the ALTID section. + + TestFileIter = TestFile.HomeWebsiteListAltID.find(1); + ASSERT_NE(TestFile.HomeWebsiteListAltID.end(), TestFileIter); + ASSERT_EQ("10", TestFileIter->second); + + // Check the PID section. + + TestFileIter = TestFile.HomeWebsiteListPID.find(1); + ASSERT_NE(TestFile.HomeWebsiteListPID.end(), TestFileIter); + ASSERT_EQ("11", TestFileIter->second); + + // Check the MEDIATYPE section. + + TestFileIter = TestFile.HomeWebsiteListMediatype.find(1); + ASSERT_NE(TestFile.HomeWebsiteListMediatype.end(), TestFileIter); + ASSERT_EQ("grass/soggy", TestFileIter->second); + + // Check the PREF section. + + TestFileIntIter = TestFile.HomeWebsiteListPref.find(1); + ASSERT_NE(TestFile.HomeWebsiteListPref.end(), TestFileIntIter); + ASSERT_EQ(12, TestFileIntIter->second); + + // Check the extra tokens. + + TestFileIter = TestFile.HomeWebsiteListTokens.find(1); + ASSERT_NE(TestFile.HomeWebsiteListTokens.end(), TestFileIter); + ASSERT_EQ("BON=Bon", TestFileIter->second); + + // Start with the business URL. + + TestFileIter = TestFile.BusinessWebsiteList.find(2); + ASSERT_NE(TestFile.BusinessWebsiteList.end(), TestFileIter); + ASSERT_EQ("http://example.com/business/", TestFileIter->second); + + // Check the ALTID section. + + TestFileIter = TestFile.BusinessWebsiteListAltID.find(2); + ASSERT_NE(TestFile.BusinessWebsiteListAltID.end(), TestFileIter); + ASSERT_EQ("20", TestFileIter->second); + + // Check the PID section. + + TestFileIter = TestFile.BusinessWebsiteListPID.find(2); + ASSERT_NE(TestFile.BusinessWebsiteListPID.end(), TestFileIter); + ASSERT_EQ("21", TestFileIter->second); + + // Check the MEDIATYPE section. + + TestFileIter = TestFile.BusinessWebsiteListMediatype.find(2); + ASSERT_NE(TestFile.BusinessWebsiteListMediatype.end(), TestFileIter); + ASSERT_EQ("chocolate/yummy", TestFileIter->second); + + // Check the PREF section. + + TestFileIntIter = TestFile.BusinessWebsiteListPref.find(2); + ASSERT_NE(TestFile.BusinessWebsiteListPref.end(), TestFileIntIter); + ASSERT_EQ(22, TestFileIntIter->second); + + // Check the extra tokens. + + TestFileIter = TestFile.BusinessWebsiteListTokens.find(2); + ASSERT_NE(TestFile.BusinessWebsiteListTokens.end(), TestFileIter); + ASSERT_EQ("YES=No", TestFileIter->second); + +} + // TODO: Add tests for the Contact Loading process. \ No newline at end of file