// xestiaab_contactload.h - Xestia Address Book Contact Load Unit Tests.
//
// (c) 2012-2015 Xestia Software Development.
//
// This file is part of Xestia Address Book.
//
// 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 Address Book. If not, see
#include
#include "../contacteditor/ContactDataObject.h"
TEST(ContactLoad, ContactLoadTests){
ContactDataObject TestFile;
// Check that the file given is not missing.
ASSERT_EQ(CONTACTLOAD_FILEMISSING, TestFile.LoadFile("MissingFile.vcf"));
// Check that the file given does not have an error when attempting to
// open it.
ASSERT_EQ(CONTACTLOAD_FILEERROR, TestFile.LoadFile("InvalidPermissions.vcf"));
// Check that the file is a valid vCard 4.0 file.
ASSERT_EQ(CONTACTLOAD_FILEINVALIDFORMAT, TestFile.LoadFile("LoadCheck-Load1-v3.vcf"));
// Check that the vCard 4.0 file meets the base specification.
ASSERT_EQ(CONTACTLOAD_FILEBASESPECFAIL, TestFile.LoadFile("LoadCheck-Load3.vcf"));
// Check that the vCard 4.0 file loads OK.
ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf"));
// Check that the kind status has been set. (KIND).
ASSERT_NE(CONTACTKIND_NONE, TestFile.ContactKind);
ASSERT_EQ(CONTACTKIND_INDIVIDUAL, TestFile.ContactKind);
// Check that the groups have been read (MEMBER).
std::map::iterator TestFileIter;
std::map::iterator TestFileIntIter;
TestFileIter = TestFile.GroupsList.find(0);
ASSERT_NE(TestFile.GroupsList.end(), TestFileIter);
ASSERT_EQ("7a2af44d-6431-4797-a55f-d86d56304fda", TestFileIter->second);
// Check the ALTID parameter.
TestFileIter = TestFile.GroupsListAltID.find(0);
ASSERT_NE(TestFile.GroupsListAltID.end(), TestFileIter);
ASSERT_EQ("35", TestFileIter->second);
// Check the PID parameter.
TestFileIter = TestFile.GroupsListPID.find(0);
ASSERT_NE(TestFile.GroupsListPID.end(), TestFileIter);
ASSERT_EQ("40", TestFileIter->second);
// Check the PREF parameter.
TestFileIntIter = TestFile.GroupsListPref.find(0);
ASSERT_NE(TestFile.GroupsListPref.end(), TestFileIntIter);
ASSERT_EQ(45, TestFileIntIter->second);
// Check the MEDIATYPE parameter.
TestFileIter = TestFile.GroupsListMediaType.find(0);
ASSERT_NE(TestFile.GroupsListMediaType.end(), TestFileIter);
ASSERT_EQ("text/plain", TestFileIter->second);
// Check the extra tokens parameter.
TestFileIter = TestFile.GroupsListTokens.find(0);
ASSERT_NE(TestFile.GroupsListTokens.end(), TestFileIter);
ASSERT_EQ("EXAMPLE=Meep", TestFileIter->second);
// Check that the formatted name has been read (FN).
TestFileIter = TestFile.FullNamesList.find(0);
ASSERT_NE(TestFile.FullNamesList.end(), TestFileIter);
ASSERT_EQ("Test Contact", TestFileIter->second);
// Check the TYPE parameter.
TestFileIter = TestFile.FullNamesListType.find(0);
ASSERT_NE(TestFile.FullNamesListType.end(), TestFileIter);
ASSERT_EQ("work", TestFileIter->second);
// Check the LANGUAGE parameter.
TestFileIter = TestFile.FullNamesListLanguage.find(0);
ASSERT_NE(TestFile.FullNamesListLanguage.end(), TestFileIter);
ASSERT_EQ("kw", TestFileIter->second);
// Check the ALTID parameter.
TestFileIter = TestFile.FullNamesListAltID.find(0);
ASSERT_NE(TestFile.FullNamesListAltID.end(), TestFileIter);
ASSERT_EQ("500", TestFileIter->second);
// Check the PID parameter.
TestFileIter = TestFile.FullNamesListPID.find(0);
ASSERT_NE(TestFile.FullNamesListPID.end(), TestFileIter);
ASSERT_EQ("40", TestFileIter->second);
// Check the PREF parameter.
TestFileIntIter = TestFile.FullNamesListPref.find(0);
ASSERT_NE(TestFile.FullNamesListPref.end(), TestFileIntIter);
ASSERT_EQ(45, TestFileIntIter->second);
// Check for the extra tokens parameter.
TestFileIter = TestFile.FullNamesListTokens.find(0);
ASSERT_NE(TestFile.FullNamesListTokens.end(), TestFileIter);
ASSERT_EQ("EXAMPLE=Baaa", TestFileIter->second);
// Check that the name has been read (N).
ASSERT_EQ("Contact", TestFile.NameSurname);
ASSERT_EQ("Test", TestFile.NameForename);
ASSERT_EQ("Example", TestFile.NameOtherNames);
ASSERT_EQ("Robot", TestFile.NameTitle);
ASSERT_EQ("LOONY", TestFile.NameSuffix);
// Check the ALTID parameter.
ASSERT_EQ("3", TestFile.NameAltID);
// Check the LANGUAGE parameter.
ASSERT_EQ("kw", TestFile.NameLanguage);
// Check the SORT-AS parameter.
ASSERT_EQ("Contact,Test", TestFile.NameDisplayAs);
// Check the extra tokens parameter.
ASSERT_EQ("TEST=Yes", TestFile.NameTokens);
}
TEST(ContactLoad, NicknameTests){
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;
// Check that the nickname has been read (NICKNAME). General.
TestFileIter = TestFile.GeneralNicknamesList.find(0);
ASSERT_NE(TestFile.GeneralNicknamesList.end(), TestFileIter);
ASSERT_EQ("Tester", TestFileIter->second);
// Check the ALTID parameter.
TestFileIter = TestFile.GeneralNicknamesListAltID.find(0);
ASSERT_NE(TestFile.GeneralNicknamesListAltID.end(), TestFileIter);
ASSERT_EQ("35", TestFileIter->second);
// Check the PID parameter.
TestFileIter = TestFile.GeneralNicknamesListPID.find(0);
ASSERT_NE(TestFile.GeneralNicknamesListPID.end(), TestFileIter);
ASSERT_EQ("50", TestFileIter->second);
// Check the PREF parameter.
TestFileIntIter = TestFile.GeneralNicknamesListPref.find(0);
ASSERT_NE(TestFile.GeneralNicknamesListPref.end(), TestFileIntIter);
ASSERT_EQ(40, TestFileIntIter->second);
// Check the LANGUAGE parameter.
TestFileIter = TestFile.GeneralNicknamesListLanguage.find(0);
ASSERT_NE(TestFile.GeneralNicknamesListLanguage.end(), TestFileIter);
ASSERT_EQ("kw", TestFileIter->second);
// Check the extra tokens parameter.
TestFileIter = TestFile.GeneralNicknamesListTokens.find(0);
ASSERT_NE(TestFile.GeneralNicknamesListTokens.end(), TestFileIter);
ASSERT_EQ("YAY=Nope;Beep=Boop", TestFileIter->second);
// Repeat for the home type.
TestFileIter = TestFile.HomeNicknamesList.find(1);
ASSERT_NE(TestFile.HomeNicknamesList.end(), TestFileIter);
ASSERT_EQ("Testy", TestFileIter->second);
// Check the ALTID parameter.
TestFileIter = TestFile.HomeNicknamesListAltID.find(1);
ASSERT_NE(TestFile.HomeNicknamesListAltID.end(), TestFileIter);
ASSERT_EQ("17", TestFileIter->second);
// Check the PID parameter.
TestFileIter = TestFile.HomeNicknamesListPID.find(1);
ASSERT_NE(TestFile.HomeNicknamesListPID.end(), TestFileIter);
ASSERT_EQ("39", TestFileIter->second);
// Check the PREF parameter.
TestFileIntIter = TestFile.HomeNicknamesListPref.find(1);
ASSERT_NE(TestFile.HomeNicknamesListPref.end(), TestFileIntIter);
ASSERT_EQ(78, TestFileIntIter->second);
// Check the LANGUAGE parameter.
TestFileIter = TestFile.HomeNicknamesListLanguage.find(1);
ASSERT_NE(TestFile.HomeNicknamesListLanguage.end(), TestFileIter);
ASSERT_EQ("en", TestFileIter->second);
// Check the extra tokens parameter.
TestFileIter = TestFile.HomeNicknamesListTokens.find(1);
ASSERT_NE(TestFile.HomeNicknamesListTokens.end(), TestFileIter);
ASSERT_EQ("YAY=Yep;Beep=Boop", TestFileIter->second);
// Repeat for the work type.
TestFileIter = TestFile.BusinessNicknamesList.find(2);
ASSERT_NE(TestFile.BusinessNicknamesList.end(), TestFileIter);
ASSERT_EQ("The Testing One", TestFileIter->second);
// Check the ALTID parameter.
TestFileIter = TestFile.BusinessNicknamesListAltID.find(2);
ASSERT_NE(TestFile.BusinessNicknamesListAltID.end(), TestFileIter);
ASSERT_EQ("99", TestFileIter->second);
// Check the PID parameter.
TestFileIter = TestFile.BusinessNicknamesListPID.find(2);
ASSERT_NE(TestFile.BusinessNicknamesListPID.end(), TestFileIter);
ASSERT_EQ("10", TestFileIter->second);
// Check the PREF parameter.
TestFileIntIter = TestFile.BusinessNicknamesListPref.find(2);
ASSERT_NE(TestFile.BusinessNicknamesListPref.end(), TestFileIntIter);
ASSERT_EQ(1, TestFileIntIter->second);
// Check the LANGUAGE parameter.
TestFileIter = TestFile.BusinessNicknamesListLanguage.find(2);
ASSERT_NE(TestFile.BusinessNicknamesListLanguage.end(), TestFileIter);
ASSERT_EQ("en-GB", TestFileIter->second);
// Check the extra tokens parameter.
TestFileIter = TestFile.BusinessNicknamesListTokens.find(2);
ASSERT_NE(TestFile.BusinessNicknamesListTokens.end(), TestFileIter);
ASSERT_EQ("YAY=Maybe;Boop=Boing", TestFileIter->second);
}
TEST(ContactLoad, GenderTests){
// Check that the gender has been read.
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;
ASSERT_NE("", TestFile.Gender);
ASSERT_EQ("F", TestFile.Gender);
ASSERT_EQ("Example Text", TestFile.GenderDetails);
ASSERT_EQ("BEEP=Boop", TestFile.GenderTokens);
}
TEST(ContactLoad, BirthdayTests){
// Check that the birthday has been read.
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;
ASSERT_NE("", TestFile.Birthday);
ASSERT_EQ("20040101", TestFile.Birthday);
// Check the ALTID parameter.
ASSERT_EQ("35", TestFile.BirthdayAltID);
// Check the CALSCALE parameter.
ASSERT_EQ("georgian", TestFile.BirthdayCalScale);
// Check the extra tokens parameter.
ASSERT_EQ("HAPPY=Days", TestFile.BirthdayTokens);
// Check the VALUE parameter. (Note have to use a different file
// due to the *1 rule in RFC6350.
ContactDataObject TestFileValue;
ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4-BDayValue.vcf"));
ASSERT_EQ("Circa 2000s", TestFile.Birthday);
}
TEST(ContactLoad, AnniversaryTests){
// Check that the anniversary has been read.
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;
ASSERT_NE("", TestFile.Anniversary);
ASSERT_EQ("20200516", TestFile.Anniversary);
// Check the ALTID parameter.
ASSERT_EQ("70", TestFile.AnniversaryAltID);
// Check the CALSCALE parameter.
ASSERT_EQ("georgian", TestFile.AnniversaryCalScale);
// Check the extra tokens parameter.
ASSERT_EQ("WONDERFUL=Day", TestFile.AnniversaryTokens);
// Check the VALUE parameter. (Note have to use a different file
// due to the *1 rule in RFC6350.
ContactDataObject TestFileValue;
ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4-BDayValue.vcf"));
ASSERT_EQ("Circa 2020s", TestFile.Anniversary);
}
TEST(ContactLoad, TimeZoneTests){
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;
// Check that the timezone has been read (TZ). General.
TestFileIter = TestFile.GeneralTZList.find(0);
ASSERT_NE(TestFile.GeneralTZList.end(), TestFileIter);
ASSERT_EQ("Europe/Truro", TestFileIter->second);
// Check the ALTID parameter.
TestFileIter = TestFile.GeneralTZListAltID.find(0);
ASSERT_NE(TestFile.GeneralTZListAltID.end(), TestFileIter);
ASSERT_EQ("35", TestFileIter->second);
// Check the PID parameter.
TestFileIter = TestFile.GeneralTZListPID.find(0);
ASSERT_NE(TestFile.GeneralTZListPID.end(), TestFileIter);
ASSERT_EQ("60", TestFileIter->second);
// Check the PREF parameter.
TestFileIntIter = TestFile.GeneralTZListPref.find(0);
ASSERT_NE(TestFile.GeneralTZListPref.end(), TestFileIntIter);
ASSERT_EQ(20, TestFileIntIter->second);
// Check the LANGUAGE parameter.
TestFileIter = TestFile.GeneralTZListMediatype.find(0);
ASSERT_NE(TestFile.GeneralTZListMediatype.end(), TestFileIter);
ASSERT_EQ("text/plain", TestFileIter->second);
// Check the extra tokens parameter.
TestFileIter = TestFile.GeneralTZListTokens.find(0);
ASSERT_NE(TestFile.GeneralTZListTokens.end(), TestFileIter);
ASSERT_EQ("WHATS=This;A=Potato", TestFileIter->second);
// Check that the timezone has been read (TZ). Home.
TestFileIter = TestFile.HomeTZList.find(1);
ASSERT_NE(TestFile.HomeTZList.end(), TestFileIter);
ASSERT_EQ("Europe/Penzance", TestFileIter->second);
// Check the ALTID parameter.
TestFileIter = TestFile.HomeTZListAltID.find(1);
ASSERT_NE(TestFile.HomeTZListAltID.end(), TestFileIter);
ASSERT_EQ("15", TestFileIter->second);
// Check the PID parameter.
TestFileIter = TestFile.HomeTZListPID.find(1);
ASSERT_NE(TestFile.HomeTZListPID.end(), TestFileIter);
ASSERT_EQ("20", TestFileIter->second);
// Check the PREF parameter.
TestFileIntIter = TestFile.HomeTZListPref.find(1);
ASSERT_NE(TestFile.HomeTZListPref.end(), TestFileIntIter);
ASSERT_EQ(40, TestFileIntIter->second);
// Check the LANGUAGE parameter.
TestFileIter = TestFile.HomeTZListMediatype.find(1);
ASSERT_NE(TestFile.HomeTZListMediatype.end(), TestFileIter);
ASSERT_EQ("text/plain", TestFileIter->second);
// Check the extra tokens parameter.
TestFileIter = TestFile.HomeTZListTokens.find(1);
ASSERT_NE(TestFile.HomeTZListTokens.end(), TestFileIter);
ASSERT_EQ("MAYBE=not", TestFileIter->second);
// Check that the timezone has been read (TZ). Business.
TestFileIter = TestFile.BusinessTZList.find(2);
ASSERT_NE(TestFile.BusinessTZList.end(), TestFileIter);
ASSERT_EQ("Europe/St Austell", TestFileIter->second);
// Check the ALTID parameter.
TestFileIter = TestFile.BusinessTZListAltID.find(2);
ASSERT_NE(TestFile.BusinessTZListAltID.end(), TestFileIter);
ASSERT_EQ("45", TestFileIter->second);
// Check the PID parameter.
TestFileIter = TestFile.BusinessTZListPID.find(2);
ASSERT_NE(TestFile.BusinessTZListPID.end(), TestFileIter);
ASSERT_EQ("70", TestFileIter->second);
// Check the PREF parameter.
TestFileIntIter = TestFile.BusinessTZListPref.find(2);
ASSERT_NE(TestFile.BusinessTZListPref.end(), TestFileIntIter);
ASSERT_EQ(80, TestFileIntIter->second);
// Check the LANGUAGE parameter.
TestFileIter = TestFile.BusinessTZListMediatype.find(2);
ASSERT_NE(TestFile.BusinessTZListMediatype.end(), TestFileIter);
ASSERT_EQ("text/plain", TestFileIter->second);
// Check the extra tokens parameter.
TestFileIter = TestFile.BusinessTZListTokens.find(2);
ASSERT_NE(TestFile.BusinessTZListTokens.end(), TestFileIter);
ASSERT_EQ("MAYBE=yes", TestFileIter->second);
}
TEST(ContactLoad, AddressTests){
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 address.
// Check the address street section.
TestFileIter = TestFile.GeneralAddressList.find(0);
ASSERT_NE(TestFile.GeneralAddressList.end(), TestFileIter);
ASSERT_EQ("1 Lovely Lane", TestFileIter->second);
// Check the address town section.
TestFileIter = TestFile.GeneralAddressListTown.find(0);
ASSERT_NE(TestFile.GeneralAddressListTown.end(), TestFileIter);
ASSERT_EQ("Rodney", TestFileIter->second);
// Check the address county section.
TestFileIter = TestFile.GeneralAddressListCounty.find(0);
ASSERT_NE(TestFile.GeneralAddressListCounty.end(), TestFileIter);
ASSERT_EQ("Cornwall", TestFileIter->second);
// Check the address post code section.
TestFileIter = TestFile.GeneralAddressListPostCode.find(0);
ASSERT_NE(TestFile.GeneralAddressListPostCode.end(), TestFileIter);
ASSERT_EQ("PL99 1AA", TestFileIter->second);
// Check the address country section.
TestFileIter = TestFile.GeneralAddressListCountry.find(0);
ASSERT_NE(TestFile.GeneralAddressListCountry.end(), TestFileIter);
ASSERT_EQ("United Kingdom", TestFileIter->second);
// Check the LABEL section.
TestFileIter = TestFile.GeneralAddressListLabel.find(0);
ASSERT_NE(TestFile.GeneralAddressListLabel.end(), TestFileIter);
ASSERT_EQ("\"1 Lovely Lane\nRodney\nCornwall\nPL99 1AA\nCornwall\nUnited Kingdom\"", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.GeneralAddressListLang.find(0);
ASSERT_NE(TestFile.GeneralAddressListLang.end(), TestFileIter);
ASSERT_EQ("kw", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.GeneralAddressListAltID.find(0);
ASSERT_NE(TestFile.GeneralAddressListAltID.end(), TestFileIter);
ASSERT_EQ("15", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.GeneralAddressListPID.find(0);
ASSERT_NE(TestFile.GeneralAddressListPID.end(), TestFileIter);
ASSERT_EQ("81", TestFileIter->second);
// Check the GEO section.
TestFileIter = TestFile.GeneralAddressListGeo.find(0);
ASSERT_NE(TestFile.GeneralAddressListGeo.end(), TestFileIter);
ASSERT_EQ("\"geo:1.0, 1.0\"", TestFileIter->second);
// Check the TZ section.
TestFileIter = TestFile.GeneralAddressListTimezone.find(0);
ASSERT_NE(TestFile.GeneralAddressListTimezone.end(), TestFileIter);
ASSERT_EQ("Europe/Truro", TestFileIter->second);
// Check the MEDIATYPE section.
TestFileIter = TestFile.GeneralAddressListMediatype.find(0);
ASSERT_NE(TestFile.GeneralAddressListMediatype.end(), TestFileIter);
ASSERT_EQ("text/plain", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.GeneralAddressListPref.find(0);
ASSERT_NE(TestFile.GeneralAddressListPref.end(), TestFileIntIter);
ASSERT_EQ(98, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.GeneralAddressListTokens.find(0);
ASSERT_NE(TestFile.GeneralAddressListTokens.end(), TestFileIter);
ASSERT_EQ("MAKES=Moo;ANIMAL=Cow", TestFileIter->second);
// Process the home address
// Check the address street section.
TestFileIter = TestFile.HomeAddressList.find(1);
ASSERT_NE(TestFile.HomeAddressList.end(), TestFileIter);
ASSERT_EQ("3 Working Plaice", TestFileIter->second);
// Check the address town section.
TestFileIter = TestFile.HomeAddressListTown.find(1);
ASSERT_NE(TestFile.HomeAddressListTown.end(), TestFileIter);
ASSERT_EQ("Roger", TestFileIter->second);
// Check the address county section.
TestFileIter = TestFile.HomeAddressListCounty.find(1);
ASSERT_NE(TestFile.HomeAddressListCounty.end(), TestFileIter);
ASSERT_EQ("Cornwall", TestFileIter->second);
// Check the address post code section.
TestFileIter = TestFile.HomeAddressListPostCode.find(1);
ASSERT_NE(TestFile.HomeAddressListPostCode.end(), TestFileIter);
ASSERT_EQ("PL75 4ZZ", TestFileIter->second);
// Check the address country section.
TestFileIter = TestFile.HomeAddressListCountry.find(1);
ASSERT_NE(TestFile.HomeAddressListCountry.end(), TestFileIter);
ASSERT_EQ("United Kingdom", TestFileIter->second);
// Check the LABEL section.
TestFileIter = TestFile.HomeAddressListLabel.find(1);
ASSERT_NE(TestFile.HomeAddressListLabel.end(), TestFileIter);
ASSERT_EQ("\"3 Working Plaice\nRoger\nCornwall\nPL75 4ZZ\nCornwall\nUnited Kingdom\"", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.HomeAddressListLang.find(1);
ASSERT_NE(TestFile.HomeAddressListLang.end(), TestFileIter);
ASSERT_EQ("en", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.HomeAddressListAltID.find(1);
ASSERT_NE(TestFile.HomeAddressListAltID.end(), TestFileIter);
ASSERT_EQ("40", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.HomeAddressListPID.find(1);
ASSERT_NE(TestFile.HomeAddressListPID.end(), TestFileIter);
ASSERT_EQ("13", TestFileIter->second);
// Check the GEO section.
TestFileIter = TestFile.HomeAddressListGeo.find(1);
ASSERT_NE(TestFile.HomeAddressListGeo.end(), TestFileIter);
ASSERT_EQ("\"geo:4.0, 4.0\"", TestFileIter->second);
// Check the TZ section.
TestFileIter = TestFile.HomeAddressListTimezone.find(1);
ASSERT_NE(TestFile.HomeAddressListTimezone.end(), TestFileIter);
ASSERT_EQ("Europe/St Ives", TestFileIter->second);
// Check the MEDIATYPE section.
TestFileIter = TestFile.HomeAddressListMediatype.find(1);
ASSERT_NE(TestFile.HomeAddressListMediatype.end(), TestFileIter);
ASSERT_EQ("text/plain", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.HomeAddressListPref.find(1);
ASSERT_NE(TestFile.HomeAddressListPref.end(), TestFileIntIter);
ASSERT_EQ(10, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.HomeAddressListTokens.find(1);
ASSERT_NE(TestFile.HomeAddressListTokens.end(), TestFileIter);
ASSERT_EQ("TOAST=Butter", TestFileIter->second);
// Process the business address.
// Check the address street section.
TestFileIter = TestFile.BusinessAddressList.find(2);
ASSERT_NE(TestFile.BusinessAddressList.end(), TestFileIter);
ASSERT_EQ("7 Flyby Drive", TestFileIter->second);
// Check the address town section.
TestFileIter = TestFile.BusinessAddressListTown.find(2);
ASSERT_NE(TestFile.BusinessAddressListTown.end(), TestFileIter);
ASSERT_EQ("Elaine", TestFileIter->second);
// Check the address county section.
TestFileIter = TestFile.BusinessAddressListCounty.find(2);
ASSERT_NE(TestFile.BusinessAddressListCounty.end(), TestFileIter);
ASSERT_EQ("Cornwall", TestFileIter->second);
// Check the address post code section.
TestFileIter = TestFile.BusinessAddressListPostCode.find(2);
ASSERT_NE(TestFile.BusinessAddressListPostCode.end(), TestFileIter);
ASSERT_EQ("PL84 9YE", TestFileIter->second);
// Check the address country section.
TestFileIter = TestFile.BusinessAddressListCountry.find(2);
ASSERT_NE(TestFile.BusinessAddressListCountry.end(), TestFileIter);
ASSERT_EQ("United Kingdom", TestFileIter->second);
// Check the LABEL section.
TestFileIter = TestFile.BusinessAddressListLabel.find(2);
ASSERT_NE(TestFile.BusinessAddressListLabel.end(), TestFileIter);
ASSERT_EQ("\"7 Flyby Drive\nElaine\nCornwall\nPL84 9YE\nCornwall\nUnited Kingdom\"", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.BusinessAddressListLang.find(2);
ASSERT_NE(TestFile.BusinessAddressListLang.end(), TestFileIter);
ASSERT_EQ("en-GB", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.BusinessAddressListAltID.find(2);
ASSERT_NE(TestFile.BusinessAddressListAltID.end(), TestFileIter);
ASSERT_EQ("45", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.BusinessAddressListPID.find(2);
ASSERT_NE(TestFile.BusinessAddressListPID.end(), TestFileIter);
ASSERT_EQ("28", TestFileIter->second);
// Check the GEO section.
TestFileIter = TestFile.BusinessAddressListGeo.find(2);
ASSERT_NE(TestFile.BusinessAddressListGeo.end(), TestFileIter);
ASSERT_EQ("\"geo:7.0, 7.0\"", TestFileIter->second);
// Check the TZ section.
TestFileIter = TestFile.BusinessAddressListTimezone.find(2);
ASSERT_NE(TestFile.BusinessAddressListTimezone.end(), TestFileIter);
ASSERT_EQ("Europe/Newquay", TestFileIter->second);
// Check the MEDIATYPE section.
TestFileIter = TestFile.BusinessAddressListMediatype.find(2);
ASSERT_NE(TestFile.BusinessAddressListMediatype.end(), TestFileIter);
ASSERT_EQ("text/plain", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.BusinessAddressListPref.find(2);
ASSERT_NE(TestFile.BusinessAddressListPref.end(), TestFileIntIter);
ASSERT_EQ(10, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.BusinessAddressListTokens.find(2);
ASSERT_NE(TestFile.BusinessAddressListTokens.end(), TestFileIter);
ASSERT_EQ("JAM=Red", TestFileIter->second);
}
TEST(ContactLoad, EmailTests){
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 email.
TestFileIter = TestFile.GeneralEmailList.find(0);
ASSERT_NE(TestFile.GeneralEmailList.end(), TestFileIter);
ASSERT_EQ("moo@example.com", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.GeneralEmailListAltID.find(0);
ASSERT_NE(TestFile.GeneralEmailListAltID.end(), TestFileIter);
ASSERT_EQ("10", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.GeneralEmailListPID.find(0);
ASSERT_NE(TestFile.GeneralEmailListPID.end(), TestFileIter);
ASSERT_EQ("20", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.GeneralEmailListPref.find(0);
ASSERT_NE(TestFile.GeneralEmailListPref.end(), TestFileIntIter);
ASSERT_EQ(40, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.GeneralEmailListTokens.find(0);
ASSERT_NE(TestFile.GeneralEmailListTokens.end(), TestFileIter);
ASSERT_EQ("WONDERFUL=Colour", TestFileIter->second);
// Start with the home email.
TestFileIter = TestFile.HomeEmailList.find(1);
ASSERT_NE(TestFile.HomeEmailList.end(), TestFileIter);
ASSERT_EQ("moo.home@example.com", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.HomeEmailListAltID.find(1);
ASSERT_NE(TestFile.HomeEmailListAltID.end(), TestFileIter);
ASSERT_EQ("5", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.HomeEmailListPID.find(1);
ASSERT_NE(TestFile.HomeEmailListPID.end(), TestFileIter);
ASSERT_EQ("10", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.HomeEmailListPref.find(1);
ASSERT_NE(TestFile.HomeEmailListPref.end(), TestFileIntIter);
ASSERT_EQ(20, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.HomeEmailListTokens.find(1);
ASSERT_NE(TestFile.HomeEmailListTokens.end(), TestFileIter);
ASSERT_EQ("PEACE=quiet", TestFileIter->second);
// Start with the business email.
TestFileIter = TestFile.BusinessEmailList.find(2);
ASSERT_NE(TestFile.BusinessEmailList.end(), TestFileIter);
ASSERT_EQ("moo.business@example.com", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.BusinessEmailListAltID.find(2);
ASSERT_NE(TestFile.BusinessEmailListAltID.end(), TestFileIter);
ASSERT_EQ("1", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.BusinessEmailListPID.find(2);
ASSERT_NE(TestFile.BusinessEmailListPID.end(), TestFileIter);
ASSERT_EQ("2", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.BusinessEmailListPref.find(2);
ASSERT_NE(TestFile.BusinessEmailListPref.end(), TestFileIntIter);
ASSERT_EQ(3, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.BusinessEmailListTokens.find(2);
ASSERT_NE(TestFile.BusinessEmailListTokens.end(), TestFileIter);
ASSERT_EQ("BUSINESS=Money", TestFileIter->second);
}
// TODO: Add tests for the Contact Loading process.