// 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);
}
TEST(ContactLoad, IMTests){
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 IM.
TestFileIter = TestFile.GeneralIMList.find(0);
ASSERT_NE(TestFile.GeneralIMList.end(), TestFileIter);
ASSERT_EQ("moo@example.com", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.GeneralIMListAltID.find(0);
ASSERT_NE(TestFile.GeneralIMListAltID.end(), TestFileIter);
ASSERT_EQ("10", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.GeneralIMListPID.find(0);
ASSERT_NE(TestFile.GeneralIMListPID.end(), TestFileIter);
ASSERT_EQ("20", TestFileIter->second);
// Check the MEDIATYPE section.
TestFileIter = TestFile.GeneralIMListMediatype.find(0);
ASSERT_NE(TestFile.GeneralIMListMediatype.end(), TestFileIter);
ASSERT_EQ("text/plain", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.GeneralIMListPref.find(0);
ASSERT_NE(TestFile.GeneralIMListPref.end(), TestFileIntIter);
ASSERT_EQ(40, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.GeneralIMListTokens.find(0);
ASSERT_NE(TestFile.GeneralIMListTokens.end(), TestFileIter);
ASSERT_EQ("WONDERFUL=Colour", TestFileIter->second);
// Start with the home IM.
TestFileIter = TestFile.HomeIMList.find(1);
ASSERT_NE(TestFile.HomeIMList.end(), TestFileIter);
ASSERT_EQ("moo.home@example.com", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.HomeIMListAltID.find(1);
ASSERT_NE(TestFile.HomeIMListAltID.end(), TestFileIter);
ASSERT_EQ("20", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.HomeIMListPID.find(1);
ASSERT_NE(TestFile.HomeIMListPID.end(), TestFileIter);
ASSERT_EQ("40", TestFileIter->second);
// Check the MEDIATYPE section.
TestFileIter = TestFile.HomeIMListMediatype.find(1);
ASSERT_NE(TestFile.HomeIMListMediatype.end(), TestFileIter);
ASSERT_EQ("text/reallyplain", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.HomeIMListPref.find(1);
ASSERT_NE(TestFile.HomeIMListPref.end(), TestFileIntIter);
ASSERT_EQ(80, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.HomeIMListTokens.find(1);
ASSERT_NE(TestFile.HomeIMListTokens.end(), TestFileIter);
ASSERT_EQ("PEACE=quiet", TestFileIter->second);
// Start with the business IM.
TestFileIter = TestFile.BusinessIMList.find(2);
ASSERT_NE(TestFile.BusinessIMList.end(), TestFileIter);
ASSERT_EQ("moo.business@example.com", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.BusinessIMListAltID.find(2);
ASSERT_NE(TestFile.BusinessIMListAltID.end(), TestFileIter);
ASSERT_EQ("98", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.BusinessIMListPID.find(2);
ASSERT_NE(TestFile.BusinessIMListPID.end(), TestFileIter);
ASSERT_EQ("99", TestFileIter->second);
// Check the MEDIATYPE section.
TestFileIter = TestFile.BusinessIMListMediatype.find(2);
ASSERT_NE(TestFile.BusinessIMListMediatype.end(), TestFileIter);
ASSERT_EQ("text/superplain", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.BusinessIMListPref.find(2);
ASSERT_NE(TestFile.BusinessIMListPref.end(), TestFileIntIter);
ASSERT_EQ(50, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.BusinessIMListTokens.find(2);
ASSERT_NE(TestFile.BusinessIMListTokens.end(), TestFileIter);
ASSERT_EQ("BUSINESS=Money", TestFileIter->second);
}
TEST(ContactLoad, TelephoneTests){
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 Telephone.
TestFileIter = TestFile.GeneralTelephoneList.find(0);
ASSERT_NE(TestFile.GeneralTelephoneList.end(), TestFileIter);
ASSERT_EQ("tel:00000000", TestFileIter->second);
// Check the type section.
TestFileIter = TestFile.GeneralTelephoneListTypeInfo.find(0);
ASSERT_NE(TestFile.GeneralTelephoneListTypeInfo.end(), TestFileIter);
ASSERT_EQ("fax,mobile", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.GeneralTelephoneListAltID.find(0);
ASSERT_NE(TestFile.GeneralTelephoneListAltID.end(), TestFileIter);
ASSERT_EQ("10", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.GeneralTelephoneListPID.find(0);
ASSERT_NE(TestFile.GeneralTelephoneListPID.end(), TestFileIter);
ASSERT_EQ("20", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.GeneralTelephoneListPref.find(0);
ASSERT_NE(TestFile.GeneralTelephoneListPref.end(), TestFileIntIter);
ASSERT_EQ(40, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.GeneralTelephoneListTokens.find(0);
ASSERT_NE(TestFile.GeneralTelephoneListTokens.end(), TestFileIter);
ASSERT_EQ("WONDERFUL=Colour", TestFileIter->second);
// Start with the home Telephone.
TestFileIter = TestFile.HomeTelephoneList.find(1);
ASSERT_NE(TestFile.HomeTelephoneList.end(), TestFileIter);
ASSERT_EQ("tel:00001111", TestFileIter->second);
// Check the type section.
TestFileIter = TestFile.HomeTelephoneListTypeInfo.find(1);
ASSERT_NE(TestFile.HomeTelephoneListTypeInfo.end(), TestFileIter);
ASSERT_EQ("fax", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.HomeTelephoneListAltID.find(1);
ASSERT_NE(TestFile.HomeTelephoneListAltID.end(), TestFileIter);
ASSERT_EQ("10", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.HomeTelephoneListPID.find(1);
ASSERT_NE(TestFile.HomeTelephoneListPID.end(), TestFileIter);
ASSERT_EQ("20", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.HomeTelephoneListPref.find(1);
ASSERT_NE(TestFile.HomeTelephoneListPref.end(), TestFileIntIter);
ASSERT_EQ(40, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.HomeTelephoneListTokens.find(1);
ASSERT_NE(TestFile.HomeTelephoneListTokens.end(), TestFileIter);
ASSERT_EQ("BUSINESS=Money", TestFileIter->second);
// Start with the business Telephone.
TestFileIter = TestFile.BusinessTelephoneList.find(2);
ASSERT_NE(TestFile.BusinessTelephoneList.end(), TestFileIter);
ASSERT_EQ("tel:22221111", TestFileIter->second);
// Check the type section.
TestFileIter = TestFile.BusinessTelephoneListTypeInfo.find(2);
ASSERT_NE(TestFile.BusinessTelephoneListTypeInfo.end(), TestFileIter);
ASSERT_EQ("voice", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.BusinessTelephoneListAltID.find(2);
ASSERT_NE(TestFile.BusinessTelephoneListAltID.end(), TestFileIter);
ASSERT_EQ("25", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.BusinessTelephoneListPID.find(2);
ASSERT_NE(TestFile.BusinessTelephoneListPID.end(), TestFileIter);
ASSERT_EQ("50", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.BusinessTelephoneListPref.find(2);
ASSERT_NE(TestFile.BusinessTelephoneListPref.end(), TestFileIntIter);
ASSERT_EQ(75, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.BusinessTelephoneListTokens.find(2);
ASSERT_NE(TestFile.BusinessTelephoneListTokens.end(), TestFileIter);
ASSERT_EQ("BEEP=Boop", TestFileIter->second);
}
TEST(ContactLoad, LanguageTests){
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 language.
TestFileIter = TestFile.GeneralLanguageList.find(0);
ASSERT_NE(TestFile.GeneralLanguageList.end(), TestFileIter);
ASSERT_EQ("kw", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.GeneralLanguageListAltID.find(0);
ASSERT_NE(TestFile.GeneralLanguageListAltID.end(), TestFileIter);
ASSERT_EQ("20", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.GeneralLanguageListPID.find(0);
ASSERT_NE(TestFile.GeneralLanguageListPID.end(), TestFileIter);
ASSERT_EQ("40", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.GeneralLanguageListPref.find(0);
ASSERT_NE(TestFile.GeneralLanguageListPref.end(), TestFileIntIter);
ASSERT_EQ(80, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.GeneralLanguageListTokens.find(0);
ASSERT_NE(TestFile.GeneralLanguageListTokens.end(), TestFileIter);
ASSERT_EQ("GELFORN=Great", TestFileIter->second);
// Start with the home language.
TestFileIter = TestFile.HomeLanguageList.find(1);
ASSERT_NE(TestFile.HomeLanguageList.end(), TestFileIter);
ASSERT_EQ("en", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.HomeLanguageListAltID.find(1);
ASSERT_NE(TestFile.HomeLanguageListAltID.end(), TestFileIter);
ASSERT_EQ("22", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.HomeLanguageListPID.find(1);
ASSERT_NE(TestFile.HomeLanguageListPID.end(), TestFileIter);
ASSERT_EQ("45", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.HomeLanguageListPref.find(1);
ASSERT_NE(TestFile.HomeLanguageListPref.end(), TestFileIntIter);
ASSERT_EQ(90, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.HomeLanguageListTokens.find(1);
ASSERT_NE(TestFile.HomeLanguageListTokens.end(), TestFileIter);
ASSERT_EQ("LANGUAGE=yes", TestFileIter->second);
// Start with the business language.
TestFileIter = TestFile.BusinessLanguageList.find(2);
ASSERT_NE(TestFile.BusinessLanguageList.end(), TestFileIter);
ASSERT_EQ("cy", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.BusinessLanguageListAltID.find(2);
ASSERT_NE(TestFile.BusinessLanguageListAltID.end(), TestFileIter);
ASSERT_EQ("10", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.BusinessLanguageListPID.find(2);
ASSERT_NE(TestFile.BusinessLanguageListPID.end(), TestFileIter);
ASSERT_EQ("15", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.BusinessLanguageListPref.find(2);
ASSERT_NE(TestFile.BusinessLanguageListPref.end(), TestFileIntIter);
ASSERT_EQ(20, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.BusinessLanguageListTokens.find(2);
ASSERT_NE(TestFile.BusinessLanguageListTokens.end(), TestFileIter);
ASSERT_EQ("FFENSTRI=ie", TestFileIter->second);
}
TEST(ContactLoad, GeographicTests){
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 Geoposition.
TestFileIter = TestFile.GeneralGeographyList.find(0);
ASSERT_NE(TestFile.GeneralGeographyList.end(), TestFileIter);
ASSERT_EQ("geo:3.5,3.5", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.GeneralGeographyListAltID.find(0);
ASSERT_NE(TestFile.GeneralGeographyListAltID.end(), TestFileIter);
ASSERT_EQ("13", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.GeneralGeographyListPID.find(0);
ASSERT_NE(TestFile.GeneralGeographyListPID.end(), TestFileIter);
ASSERT_EQ("26", TestFileIter->second);
// Check the MEDIATYPE section.
TestFileIter = TestFile.GeneralGeographyListMediatype.find(0);
ASSERT_NE(TestFile.GeneralGeographyListMediatype.end(), TestFileIter);
ASSERT_EQ("text/plain", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.GeneralGeographyListPref.find(0);
ASSERT_NE(TestFile.GeneralGeographyListPref.end(), TestFileIntIter);
ASSERT_EQ(39, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.GeneralGeographyListTokens.find(0);
ASSERT_NE(TestFile.GeneralGeographyListTokens.end(), TestFileIter);
ASSERT_EQ("POS=Yep", TestFileIter->second);
// Start with the home Geoposition.
TestFileIter = TestFile.HomeGeographyList.find(1);
ASSERT_NE(TestFile.HomeGeographyList.end(), TestFileIter);
ASSERT_EQ("geo:7.0,7.0", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.HomeGeographyListAltID.find(1);
ASSERT_NE(TestFile.HomeGeographyListAltID.end(), TestFileIter);
ASSERT_EQ("140", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.HomeGeographyListPID.find(1);
ASSERT_NE(TestFile.HomeGeographyListPID.end(), TestFileIter);
ASSERT_EQ("70", TestFileIter->second);
// Check the MEDIATYPE section.
TestFileIter = TestFile.HomeGeographyListMediatype.find(1);
ASSERT_NE(TestFile.HomeGeographyListMediatype.end(), TestFileIter);
ASSERT_EQ("text/ratherplain", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.HomeGeographyListPref.find(1);
ASSERT_NE(TestFile.HomeGeographyListPref.end(), TestFileIntIter);
ASSERT_EQ(1, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.HomeGeographyListTokens.find(1);
ASSERT_NE(TestFile.HomeGeographyListTokens.end(), TestFileIter);
ASSERT_EQ("POS=Nope", TestFileIter->second);
// Start with the business Geoposition.
TestFileIter = TestFile.BusinessGeographyList.find(2);
ASSERT_NE(TestFile.BusinessGeographyList.end(), TestFileIter);
ASSERT_EQ("geo:14.0,14.0", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.BusinessGeographyListAltID.find(2);
ASSERT_NE(TestFile.BusinessGeographyListAltID.end(), TestFileIter);
ASSERT_EQ("75", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.BusinessGeographyListPID.find(2);
ASSERT_NE(TestFile.BusinessGeographyListPID.end(), TestFileIter);
ASSERT_EQ("32", TestFileIter->second);
// Check the MEDIATYPE section.
TestFileIter = TestFile.BusinessGeographyListMediatype.find(2);
ASSERT_NE(TestFile.BusinessGeographyListMediatype.end(), TestFileIter);
ASSERT_EQ("text/greenplain", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.BusinessGeographyListPref.find(2);
ASSERT_NE(TestFile.BusinessGeographyListPref.end(), TestFileIntIter);
ASSERT_EQ(4, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.BusinessGeographyListTokens.find(2);
ASSERT_NE(TestFile.BusinessGeographyListTokens.end(), TestFileIter);
ASSERT_EQ("POS=Money", TestFileIter->second);
}
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);
}
TEST(ContactLoad, TitleTests){
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 title.
TestFileIter = TestFile.GeneralTitleList.find(0);
ASSERT_NE(TestFile.GeneralTitleList.end(), TestFileIter);
ASSERT_EQ("Lord of Light", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.GeneralTitleListAltID.find(0);
ASSERT_NE(TestFile.GeneralTitleListAltID.end(), TestFileIter);
ASSERT_EQ("20", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.GeneralTitleListPID.find(0);
ASSERT_NE(TestFile.GeneralTitleListPID.end(), TestFileIter);
ASSERT_EQ("21", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.GeneralTitleListLanguage.find(0);
ASSERT_NE(TestFile.GeneralTitleListLanguage.end(), TestFileIter);
ASSERT_EQ("text/plain", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.GeneralTitleListPref.find(0);
ASSERT_NE(TestFile.GeneralTitleListPref.end(), TestFileIntIter);
ASSERT_EQ(22, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.GeneralTitleListTokens.find(0);
ASSERT_NE(TestFile.GeneralTitleListTokens.end(), TestFileIter);
ASSERT_EQ("EEP=LIGHT", TestFileIter->second);
// Start with the home title.
TestFileIter = TestFile.HomeTitleList.find(1);
ASSERT_NE(TestFile.HomeTitleList.end(), TestFileIter);
ASSERT_EQ("Lord of Darkness", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.HomeTitleListAltID.find(1);
ASSERT_NE(TestFile.HomeTitleListAltID.end(), TestFileIter);
ASSERT_EQ("30", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.HomeTitleListPID.find(1);
ASSERT_NE(TestFile.HomeTitleListPID.end(), TestFileIter);
ASSERT_EQ("31", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.HomeTitleListLanguage.find(1);
ASSERT_NE(TestFile.HomeTitleListLanguage.end(), TestFileIter);
ASSERT_EQ("grass/dry", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.HomeTitleListPref.find(1);
ASSERT_NE(TestFile.HomeTitleListPref.end(), TestFileIntIter);
ASSERT_EQ(32, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.HomeTitleListTokens.find(1);
ASSERT_NE(TestFile.HomeTitleListTokens.end(), TestFileIter);
ASSERT_EQ("EEP=DARK", TestFileIter->second);
// Start with the business title.
TestFileIter = TestFile.BusinessTitleList.find(2);
ASSERT_NE(TestFile.BusinessTitleList.end(), TestFileIter);
ASSERT_EQ("Master of the Light & Darkness", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.BusinessTitleListAltID.find(2);
ASSERT_NE(TestFile.BusinessTitleListAltID.end(), TestFileIter);
ASSERT_EQ("40", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.BusinessTitleListPID.find(2);
ASSERT_NE(TestFile.BusinessTitleListPID.end(), TestFileIter);
ASSERT_EQ("41", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.BusinessTitleListLanguage.find(2);
ASSERT_NE(TestFile.BusinessTitleListLanguage.end(), TestFileIter);
ASSERT_EQ("moths/eew", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.BusinessTitleListPref.find(2);
ASSERT_NE(TestFile.BusinessTitleListPref.end(), TestFileIntIter);
ASSERT_EQ(42, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.BusinessTitleListTokens.find(2);
ASSERT_NE(TestFile.BusinessTitleListTokens.end(), TestFileIter);
ASSERT_EQ("EEP=BOTH", TestFileIter->second);
}
TEST(ContactLoad, RoleTests){
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 role.
TestFileIter = TestFile.GeneralRoleList.find(0);
ASSERT_NE(TestFile.GeneralRoleList.end(), TestFileIter);
ASSERT_EQ("Ordinary Person", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.GeneralRoleListAltID.find(0);
ASSERT_NE(TestFile.GeneralRoleListAltID.end(), TestFileIter);
ASSERT_EQ("50", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.GeneralRoleListPID.find(0);
ASSERT_NE(TestFile.GeneralRoleListPID.end(), TestFileIter);
ASSERT_EQ("51", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.GeneralRoleListLanguage.find(0);
ASSERT_NE(TestFile.GeneralRoleListLanguage.end(), TestFileIter);
ASSERT_EQ("en", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.GeneralRoleListPref.find(0);
ASSERT_NE(TestFile.GeneralRoleListPref.end(), TestFileIntIter);
ASSERT_EQ(52, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.GeneralRoleListTokens.find(0);
ASSERT_NE(TestFile.GeneralRoleListTokens.end(), TestFileIter);
ASSERT_EQ("ASTERISK=None", TestFileIter->second);
// Start with the home role.
TestFileIter = TestFile.HomeRoleList.find(1);
ASSERT_NE(TestFile.HomeRoleList.end(), TestFileIter);
ASSERT_EQ("Ordinary Lazy Person", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.HomeRoleListAltID.find(1);
ASSERT_NE(TestFile.HomeRoleListAltID.end(), TestFileIter);
ASSERT_EQ("60", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.HomeRoleListPID.find(1);
ASSERT_NE(TestFile.HomeRoleListPID.end(), TestFileIter);
ASSERT_EQ("61", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.HomeRoleListLanguage.find(1);
ASSERT_NE(TestFile.HomeRoleListLanguage.end(), TestFileIter);
ASSERT_EQ("en-GB", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.HomeRoleListPref.find(1);
ASSERT_NE(TestFile.HomeRoleListPref.end(), TestFileIntIter);
ASSERT_EQ(62, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.HomeRoleListTokens.find(1);
ASSERT_NE(TestFile.HomeRoleListTokens.end(), TestFileIter);
ASSERT_EQ("SOMEWHERE=There", TestFileIter->second);
// Start with the business role.
TestFileIter = TestFile.BusinessRoleList.find(2);
ASSERT_NE(TestFile.BusinessRoleList.end(), TestFileIter);
ASSERT_EQ("Company Owner", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.BusinessRoleListAltID.find(2);
ASSERT_NE(TestFile.BusinessRoleListAltID.end(), TestFileIter);
ASSERT_EQ("70", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.BusinessRoleListPID.find(2);
ASSERT_NE(TestFile.BusinessRoleListPID.end(), TestFileIter);
ASSERT_EQ("71", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.BusinessRoleListLanguage.find(2);
ASSERT_NE(TestFile.BusinessRoleListLanguage.end(), TestFileIter);
ASSERT_EQ("en-AU", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.BusinessRoleListPref.find(2);
ASSERT_NE(TestFile.BusinessRoleListPref.end(), TestFileIntIter);
ASSERT_EQ(72, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.BusinessRoleListTokens.find(2);
ASSERT_NE(TestFile.BusinessRoleListTokens.end(), TestFileIter);
ASSERT_EQ("HERE=Nope", TestFileIter->second);
}
TEST(ContactLoad, OrganisationTests){
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 organisation.
TestFileIter = TestFile.GeneralOrganisationsList.find(0);
ASSERT_NE(TestFile.GeneralOrganisationsList.end(), TestFileIter);
ASSERT_EQ("Ordinary Organisation", TestFileIter->second);
// Check the SORT-AS section.
TestFileIter = TestFile.GeneralOrganisationsListSortAs.find(0);
ASSERT_NE(TestFile.GeneralOrganisationsListSortAs.end(), TestFileIter);
ASSERT_EQ("Organisation, Ordinary", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.GeneralOrganisationsListAltID.find(0);
ASSERT_NE(TestFile.GeneralOrganisationsListAltID.end(), TestFileIter);
ASSERT_EQ("50", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.GeneralOrganisationsListPID.find(0);
ASSERT_NE(TestFile.GeneralOrganisationsListPID.end(), TestFileIter);
ASSERT_EQ("51", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.GeneralOrganisationsListLanguage.find(0);
ASSERT_NE(TestFile.GeneralOrganisationsListLanguage.end(), TestFileIter);
ASSERT_EQ("en", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.GeneralOrganisationsListPref.find(0);
ASSERT_NE(TestFile.GeneralOrganisationsListPref.end(), TestFileIntIter);
ASSERT_EQ(52, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.GeneralOrganisationsListTokens.find(0);
ASSERT_NE(TestFile.GeneralOrganisationsListTokens.end(), TestFileIter);
ASSERT_EQ("ASTERISK=None", TestFileIter->second);
// Start with the home Organisation.
TestFileIter = TestFile.HomeOrganisationsList.find(1);
ASSERT_NE(TestFile.HomeOrganisationsList.end(), TestFileIter);
ASSERT_EQ("Ordinary Lazy Person", TestFileIter->second);
// Check the SORT-AS section.
TestFileIter = TestFile.HomeOrganisationsListSortAs.find(1);
ASSERT_NE(TestFile.HomeOrganisationsListSortAs.end(), TestFileIter);
ASSERT_EQ("Person, Ordinary Lazy", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.HomeOrganisationsListAltID.find(1);
ASSERT_NE(TestFile.HomeOrganisationsListAltID.end(), TestFileIter);
ASSERT_EQ("60", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.HomeOrganisationsListPID.find(1);
ASSERT_NE(TestFile.HomeOrganisationsListPID.end(), TestFileIter);
ASSERT_EQ("61", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.HomeOrganisationsListLanguage.find(1);
ASSERT_NE(TestFile.HomeOrganisationsListLanguage.end(), TestFileIter);
ASSERT_EQ("en-GB", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.HomeOrganisationsListPref.find(1);
ASSERT_NE(TestFile.HomeOrganisationsListPref.end(), TestFileIntIter);
ASSERT_EQ(62, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.HomeOrganisationsListTokens.find(1);
ASSERT_NE(TestFile.HomeOrganisationsListTokens.end(), TestFileIter);
ASSERT_EQ("SOMEWHERE=There", TestFileIter->second);
// Start with the business Organisation.
TestFileIter = TestFile.BusinessOrganisationsList.find(2);
ASSERT_NE(TestFile.BusinessOrganisationsList.end(), TestFileIter);
ASSERT_EQ("Company Owner", TestFileIter->second);
// Check the SORT-AS section.
TestFileIter = TestFile.BusinessOrganisationsListSortAs.find(2);
ASSERT_NE(TestFile.BusinessOrganisationsListSortAs.end(), TestFileIter);
ASSERT_EQ("Owner, Company", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.BusinessOrganisationsListAltID.find(2);
ASSERT_NE(TestFile.BusinessOrganisationsListAltID.end(), TestFileIter);
ASSERT_EQ("70", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.BusinessOrganisationsListPID.find(2);
ASSERT_NE(TestFile.BusinessOrganisationsListPID.end(), TestFileIter);
ASSERT_EQ("71", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.BusinessOrganisationsListLanguage.find(2);
ASSERT_NE(TestFile.BusinessOrganisationsListLanguage.end(), TestFileIter);
ASSERT_EQ("en-AU", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.BusinessOrganisationsListPref.find(2);
ASSERT_NE(TestFile.BusinessOrganisationsListPref.end(), TestFileIntIter);
ASSERT_EQ(72, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.BusinessOrganisationsListTokens.find(2);
ASSERT_NE(TestFile.BusinessOrganisationsListTokens.end(), TestFileIter);
ASSERT_EQ("HERE=Nope", TestFileIter->second);
}
TEST(ContactLoad, NoteTests){
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 note.
TestFileIter = TestFile.GeneralNoteList.find(0);
ASSERT_NE(TestFile.GeneralNoteList.end(), TestFileIter);
ASSERT_EQ("Note\n\nLine 3\nLine 4\nLine 5", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.GeneralNoteListAltID.find(0);
ASSERT_NE(TestFile.GeneralNoteListAltID.end(), TestFileIter);
ASSERT_EQ("90", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.GeneralNoteListPID.find(0);
ASSERT_NE(TestFile.GeneralNoteListPID.end(), TestFileIter);
ASSERT_EQ("91", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.GeneralNoteListLanguage.find(0);
ASSERT_NE(TestFile.GeneralNoteListLanguage.end(), TestFileIter);
ASSERT_EQ("en", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.GeneralNoteListPref.find(0);
ASSERT_NE(TestFile.GeneralNoteListPref.end(), TestFileIntIter);
ASSERT_EQ(92, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.GeneralNoteListTokens.find(0);
ASSERT_NE(TestFile.GeneralNoteListTokens.end(), TestFileIter);
ASSERT_EQ("WOO=WOOP", TestFileIter->second);
// Start with the home note.
TestFileIter = TestFile.HomeNoteList.find(1);
ASSERT_NE(TestFile.HomeNoteList.end(), TestFileIter);
ASSERT_EQ("Note\n\n\n\nLine 5\nLine 6\nLine 7", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.HomeNoteListAltID.find(1);
ASSERT_NE(TestFile.HomeNoteListAltID.end(), TestFileIter);
ASSERT_EQ("80", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.HomeNoteListPID.find(1);
ASSERT_NE(TestFile.HomeNoteListPID.end(), TestFileIter);
ASSERT_EQ("81", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.HomeNoteListLanguage.find(1);
ASSERT_NE(TestFile.HomeNoteListLanguage.end(), TestFileIter);
ASSERT_EQ("kw", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.HomeNoteListPref.find(1);
ASSERT_NE(TestFile.HomeNoteListPref.end(), TestFileIntIter);
ASSERT_EQ(82, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.HomeNoteListTokens.find(1);
ASSERT_NE(TestFile.HomeNoteListTokens.end(), TestFileIter);
ASSERT_EQ("MOO=MEEP", TestFileIter->second);
// Start with the business note.
TestFileIter = TestFile.BusinessNoteList.find(2);
ASSERT_NE(TestFile.BusinessNoteList.end(), TestFileIter);
ASSERT_EQ("Note\n\n\n\nLine 8\nLine 9\nLine 10", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.BusinessNoteListAltID.find(2);
ASSERT_NE(TestFile.BusinessNoteListAltID.end(), TestFileIter);
ASSERT_EQ("70", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.BusinessNoteListPID.find(2);
ASSERT_NE(TestFile.BusinessNoteListPID.end(), TestFileIter);
ASSERT_EQ("71", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.BusinessNoteListLanguage.find(2);
ASSERT_NE(TestFile.BusinessNoteListLanguage.end(), TestFileIter);
ASSERT_EQ("fr", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.BusinessNoteListPref.find(2);
ASSERT_NE(TestFile.BusinessNoteListPref.end(), TestFileIntIter);
ASSERT_EQ(72, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.BusinessNoteListTokens.find(2);
ASSERT_NE(TestFile.BusinessNoteListTokens.end(), TestFileIter);
ASSERT_EQ("BOING=BOOP", TestFileIter->second);
}
TEST(ContactLoad, CategoryTests){
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 category.
TestFileIter = TestFile.CategoriesList.find(0);
ASSERT_NE(TestFile.CategoriesList.end(), TestFileIter);
ASSERT_EQ("Category One", TestFileIter->second);
// Check the TYPE section.
TestFileIter = TestFile.CategoriesListType.find(0);
ASSERT_EQ(TestFile.CategoriesListType.end(), TestFileIter);
// Check the ALTID section.
TestFileIter = TestFile.CategoriesListAltID.find(0);
ASSERT_NE(TestFile.CategoriesListAltID.end(), TestFileIter);
ASSERT_EQ("40", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.CategoriesListPID.find(0);
ASSERT_NE(TestFile.CategoriesListPID.end(), TestFileIter);
ASSERT_EQ("41", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.CategoriesListLanguage.find(0);
ASSERT_NE(TestFile.CategoriesListLanguage.end(), TestFileIter);
ASSERT_EQ("en", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.CategoriesListPref.find(0);
ASSERT_NE(TestFile.CategoriesListPref.end(), TestFileIntIter);
ASSERT_EQ(42, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.CategoriesListTokens.find(0);
ASSERT_NE(TestFile.CategoriesListTokens.end(), TestFileIter);
ASSERT_EQ("CAT=TAC", TestFileIter->second);
// Start with the second & third category.
// (Category Two, Category Three).
TestFileIter = TestFile.CategoriesList.find(1);
ASSERT_NE(TestFile.CategoriesList.end(), TestFileIter);
ASSERT_EQ("Category Two", TestFileIter->second);
TestFileIter = TestFile.CategoriesList.find(2);
ASSERT_NE(TestFile.CategoriesList.end(), TestFileIter);
ASSERT_EQ("Category Three", TestFileIter->second);
// Check the TYPE section.
TestFileIter = TestFile.CategoriesListType.find(1);
ASSERT_NE(TestFile.CategoriesListType.end(), TestFileIter);
ASSERT_EQ("home", TestFileIter->second);
TestFileIter = TestFile.CategoriesListType.find(2);
ASSERT_NE(TestFile.CategoriesListType.end(), TestFileIter);
ASSERT_EQ("home", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.CategoriesListAltID.find(1);
ASSERT_NE(TestFile.CategoriesListAltID.end(), TestFileIter);
ASSERT_EQ("44", TestFileIter->second);
TestFileIter = TestFile.CategoriesListAltID.find(2);
ASSERT_NE(TestFile.CategoriesListAltID.end(), TestFileIter);
ASSERT_EQ("44", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.CategoriesListPID.find(1);
ASSERT_NE(TestFile.CategoriesListPID.end(), TestFileIter);
ASSERT_EQ("46", TestFileIter->second);
TestFileIter = TestFile.CategoriesListPID.find(2);
ASSERT_NE(TestFile.CategoriesListPID.end(), TestFileIter);
ASSERT_EQ("46", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.CategoriesListLanguage.find(1);
ASSERT_NE(TestFile.CategoriesListLanguage.end(), TestFileIter);
ASSERT_EQ("kw", TestFileIter->second);
TestFileIter = TestFile.CategoriesListLanguage.find(2);
ASSERT_NE(TestFile.CategoriesListLanguage.end(), TestFileIter);
ASSERT_EQ("kw", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.CategoriesListPref.find(1);
ASSERT_NE(TestFile.CategoriesListPref.end(), TestFileIntIter);
ASSERT_EQ(48, TestFileIntIter->second);
TestFileIntIter = TestFile.CategoriesListPref.find(2);
ASSERT_NE(TestFile.CategoriesListPref.end(), TestFileIntIter);
ASSERT_EQ(48, TestFileIntIter->second);
// Check the extra tokens.
TestFileIter = TestFile.CategoriesListTokens.find(1);
ASSERT_NE(TestFile.CategoriesListTokens.end(), TestFileIter);
ASSERT_EQ("TAC=CAT", TestFileIter->second);
TestFileIter = TestFile.CategoriesListTokens.find(2);
ASSERT_NE(TestFile.CategoriesListTokens.end(), TestFileIter);
ASSERT_EQ("TAC=CAT", TestFileIter->second);
// Start with the third, fourth & fifth category.
// (Category Three,Category Four,Category Five).
TestFileIter = TestFile.CategoriesList.find(3);
ASSERT_NE(TestFile.CategoriesList.end(), TestFileIter);
ASSERT_EQ("Category Four", TestFileIter->second.ToStdString());
TestFileIter = TestFile.CategoriesList.find(4);
ASSERT_NE(TestFile.CategoriesList.end(), TestFileIter);
ASSERT_EQ("Category Five", TestFileIter->second.ToStdString());
TestFileIter = TestFile.CategoriesList.find(5);
ASSERT_NE(TestFile.CategoriesList.end(), TestFileIter);
ASSERT_EQ("Category Six", TestFileIter->second);
// Check the TYPE section.
/*TestFileIter = TestFile.CategoriesListType.find(1);
ASSERT_NE(TestFile.CategoriesListType.end(), TestFileIter);
ASSERT_EQ("home", TestFileIter->second);
TestFileIter = TestFile.CategoriesListType.find(2);
ASSERT_NE(TestFile.CategoriesListType.end(), TestFileIter);
ASSERT_EQ("home", TestFileIter->second);
// Check the ALTID section.
TestFileIter = TestFile.CategoriesListAltID.find(1);
ASSERT_NE(TestFile.CategoriesListAltID.end(), TestFileIter);
ASSERT_EQ("44", TestFileIter->second);
TestFileIter = TestFile.CategoriesListAltID.find(2);
ASSERT_NE(TestFile.CategoriesListAltID.end(), TestFileIter);
ASSERT_EQ("44", TestFileIter->second);
// Check the PID section.
TestFileIter = TestFile.CategoriesListPID.find(1);
ASSERT_NE(TestFile.CategoriesListPID.end(), TestFileIter);
ASSERT_EQ("46", TestFileIter->second);
TestFileIter = TestFile.CategoriesListPID.find(2);
ASSERT_NE(TestFile.CategoriesListPID.end(), TestFileIter);
ASSERT_EQ("46", TestFileIter->second);
// Check the LANGUAGE section.
TestFileIter = TestFile.CategoriesListLanguage.find(1);
ASSERT_NE(TestFile.CategoriesListLanguage.end(), TestFileIter);
ASSERT_EQ("kw", TestFileIter->second);
TestFileIter = TestFile.CategoriesListLanguage.find(2);
ASSERT_NE(TestFile.CategoriesListLanguage.end(), TestFileIter);
ASSERT_EQ("kw", TestFileIter->second);
// Check the PREF section.
TestFileIntIter = TestFile.CategoriesListPref.find(1);
ASSERT_NE(TestFile.CategoriesListPref.end(), TestFileIntIter);
ASSERT_EQ(48, TestFileIntIter->second);
TestFileIntIter = TestFile.CategoriesListPref.find(2);
ASSERT_NE(TestFile.CategoriesListPref.end(), TestFileIntIter);
ASSERT_EQ(48, TestFileIntIter->second);*/
// Check the extra tokens.
TestFileIter = TestFile.CategoriesListTokens.find(1);
ASSERT_NE(TestFile.CategoriesListTokens.end(), TestFileIter);
ASSERT_EQ("TAC=CAT", TestFileIter->second);
TestFileIter = TestFile.CategoriesListTokens.find(2);
ASSERT_NE(TestFile.CategoriesListTokens.end(), TestFileIter);
ASSERT_EQ("TAC=CAT", TestFileIter->second);
}
// TODO: Add tests for the Contact Loading process.