X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Ftests%2Fxestiaab_contactload.h;h=dea51d36d9838121c0c66dfa561fd97da358fca8;hb=78a23a10b1ff0a041ab18891290a160b41d94530;hp=8f0f75270199cb50524985a87df538d9bcc37ec2;hpb=c1f0c1c8b56a8304a894dea7f361bda8cbc8d11a;p=xestiaab%2F.git diff --git a/source/tests/xestiaab_contactload.h b/source/tests/xestiaab_contactload.h index 8f0f752..dea51d3 100644 --- a/source/tests/xestiaab_contactload.h +++ b/source/tests/xestiaab_contactload.h @@ -2080,4 +2080,389 @@ TEST(ContactLoad, NoteTests){ } +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(3); + ASSERT_NE(TestFile.CategoriesListType.end(), TestFileIter); + ASSERT_EQ("work", TestFileIter->second); + + TestFileIter = TestFile.CategoriesListType.find(4); + ASSERT_NE(TestFile.CategoriesListType.end(), TestFileIter); + ASSERT_EQ("work", TestFileIter->second); + + TestFileIter = TestFile.CategoriesListType.find(5); + ASSERT_NE(TestFile.CategoriesListType.end(), TestFileIter); + ASSERT_EQ("work", TestFileIter->second); + + // Check the ALTID section. + + TestFileIter = TestFile.CategoriesListAltID.find(3); + ASSERT_NE(TestFile.CategoriesListAltID.end(), TestFileIter); + ASSERT_EQ("84", TestFileIter->second); + + TestFileIter = TestFile.CategoriesListAltID.find(4); + ASSERT_NE(TestFile.CategoriesListAltID.end(), TestFileIter); + ASSERT_EQ("84", TestFileIter->second); + + TestFileIter = TestFile.CategoriesListAltID.find(5); + ASSERT_NE(TestFile.CategoriesListAltID.end(), TestFileIter); + ASSERT_EQ("84", TestFileIter->second); + + // Check the PID section. + + TestFileIter = TestFile.CategoriesListPID.find(3); + ASSERT_NE(TestFile.CategoriesListPID.end(), TestFileIter); + ASSERT_EQ("86", TestFileIter->second); + + TestFileIter = TestFile.CategoriesListPID.find(4); + ASSERT_NE(TestFile.CategoriesListPID.end(), TestFileIter); + ASSERT_EQ("86", TestFileIter->second); + + TestFileIter = TestFile.CategoriesListPID.find(5); + ASSERT_NE(TestFile.CategoriesListPID.end(), TestFileIter); + ASSERT_EQ("86", TestFileIter->second); + + // Check the LANGUAGE section. + + TestFileIter = TestFile.CategoriesListLanguage.find(3); + ASSERT_NE(TestFile.CategoriesListLanguage.end(), TestFileIter); + ASSERT_EQ("kw", TestFileIter->second); + + TestFileIter = TestFile.CategoriesListLanguage.find(4); + ASSERT_NE(TestFile.CategoriesListLanguage.end(), TestFileIter); + ASSERT_EQ("kw", TestFileIter->second); + + TestFileIter = TestFile.CategoriesListLanguage.find(5); + ASSERT_NE(TestFile.CategoriesListLanguage.end(), TestFileIter); + ASSERT_EQ("kw", TestFileIter->second); + + // Check the PREF section. + + TestFileIntIter = TestFile.CategoriesListPref.find(3); + ASSERT_NE(TestFile.CategoriesListPref.end(), TestFileIntIter); + ASSERT_EQ(88, TestFileIntIter->second); + + TestFileIntIter = TestFile.CategoriesListPref.find(4); + ASSERT_NE(TestFile.CategoriesListPref.end(), TestFileIntIter); + ASSERT_EQ(88, TestFileIntIter->second); + + TestFileIntIter = TestFile.CategoriesListPref.find(5); + ASSERT_NE(TestFile.CategoriesListPref.end(), TestFileIntIter); + ASSERT_EQ(88, TestFileIntIter->second); + + // Check the extra tokens. + + TestFileIter = TestFile.CategoriesListTokens.find(3); + ASSERT_NE(TestFile.CategoriesListTokens.end(), TestFileIter); + ASSERT_EQ("AAA=BBB", TestFileIter->second); + + TestFileIter = TestFile.CategoriesListTokens.find(4); + ASSERT_NE(TestFile.CategoriesListTokens.end(), TestFileIter); + ASSERT_EQ("AAA=BBB", TestFileIter->second); + + TestFileIter = TestFile.CategoriesListTokens.find(4); + ASSERT_NE(TestFile.CategoriesListTokens.end(), TestFileIter); + ASSERT_EQ("AAA=BBB", TestFileIter->second); + +} + +TEST(ContactLoad, PhotoTests){ + + ContactDataObject TestFile; + + // Check that the vCard 4.0 file loads OK. + + ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf")); + + std::map::iterator TestStrIter; + std::map::iterator TestFileIter; + std::map::iterator TestFileIntIter; + + // Start with the first photo. + + TestStrIter = TestFile.PicturesList.find(0); + ASSERT_NE(TestFile.PicturesList.end(), TestStrIter); + ASSERT_EQ("iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAIAAADdHiL1AAAAJUlEQVQoz2NkwAb+//8PYTAyMmLKMjGQDuilhxHudBrbM8zCDQCxHQkPeaUvawAAAABJRU5ErkJggg==", + TestStrIter->second); + + // Check that it has the correct encoding. + + TestFileIter = TestFile.PicturesListPicEncType.find(0); + ASSERT_NE(TestFile.PicturesListPicEncType.end(), TestFileIter); + ASSERT_EQ("base64", TestFileIter->second); + + // Check that it has the correct image type. + + TestFileIter = TestFile.PicturesListPictureType.find(0); + ASSERT_NE(TestFile.PicturesListPictureType.end(), TestFileIter); + ASSERT_EQ("image/png", TestFileIter->second); + + // Check the ALTID section. + + TestFileIter = TestFile.PicturesListAltID.find(0); + ASSERT_NE(TestFile.PicturesListAltID.end(), TestFileIter); + ASSERT_EQ("70", TestFileIter->second); + + // Check the PID section. + + TestFileIter = TestFile.PicturesListPID.find(0); + ASSERT_NE(TestFile.PicturesListPID.end(), TestFileIter); + ASSERT_EQ("71", TestFileIter->second); + + // Check the MEDIATYPE section. + + TestFileIter = TestFile.PicturesListMediatype.find(0); + ASSERT_NE(TestFile.PicturesListMediatype.end(), TestFileIter); + ASSERT_EQ("image/png", TestFileIter->second); + + // Check the PREF section. + + TestFileIntIter = TestFile.PicturesListPref.find(0); + ASSERT_NE(TestFile.PicturesListPref.end(), TestFileIntIter); + ASSERT_EQ(72, TestFileIntIter->second); + + // Check the extra tokens. + + TestFileIter = TestFile.PicturesListTokens.find(0); + ASSERT_NE(TestFile.PicturesListTokens.end(), TestFileIter); + ASSERT_EQ("MEEP=MOO", TestFileIter->second); + + // Start with the second photo. + + TestStrIter = TestFile.PicturesList.find(1); + ASSERT_NE(TestFile.PicturesList.end(), TestStrIter); + ASSERT_EQ("iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAIAAADdHiL1AAAAHklEQVQoz2NkYPjPgAr+owkwMqIpYGIgHYzqGdx6AAKNAxMN5P6+AAAAAElFTkSuQmCC", + TestStrIter->second); + + // Check that it has the correct encoding. + + TestFileIter = TestFile.PicturesListPicEncType.find(1); + ASSERT_NE(TestFile.PicturesListPicEncType.end(), TestFileIter); + ASSERT_EQ("base64", TestFileIter->second); + + // Check that it has the correct image type. + + TestFileIter = TestFile.PicturesListPictureType.find(1); + ASSERT_NE(TestFile.PicturesListPictureType.end(), TestFileIter); + ASSERT_EQ("image/png", TestFileIter->second); + + // Check the ALTID section. + + TestFileIter = TestFile.PicturesListAltID.find(1); + ASSERT_NE(TestFile.PicturesListAltID.end(), TestFileIter); + ASSERT_EQ("20", TestFileIter->second); + + // Check the PID section. + + TestFileIter = TestFile.PicturesListPID.find(1); + ASSERT_NE(TestFile.PicturesListPID.end(), TestFileIter); + ASSERT_EQ("21", TestFileIter->second); + + // Check the MEDIATYPE section. + + TestFileIter = TestFile.PicturesListMediatype.find(1); + ASSERT_NE(TestFile.PicturesListMediatype.end(), TestFileIter); + ASSERT_EQ("image/png", TestFileIter->second); + + // Check the PREF section. + + TestFileIntIter = TestFile.PicturesListPref.find(1); + ASSERT_NE(TestFile.PicturesListPref.end(), TestFileIntIter); + ASSERT_EQ(22, TestFileIntIter->second); + + // Check the extra tokens. + + TestFileIter = TestFile.PicturesListTokens.find(1); + ASSERT_NE(TestFile.PicturesListTokens.end(), TestFileIter); + ASSERT_EQ("BEEP=BOOP", TestFileIter->second); + + // Start with the second photo. + + TestStrIter = TestFile.PicturesList.find(2); + ASSERT_NE(TestFile.PicturesList.end(), TestStrIter); + ASSERT_EQ("iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAIAAADdHiL1AAAAIElEQVQoz2MUm53EgApepsxF4XfaoylgYiAdjOoZ3HoAeuQD2WdxRzcAAAAASUVORK5CYII=", + TestStrIter->second); + + // Check that it has the correct encoding. + + TestFileIter = TestFile.PicturesListPicEncType.find(2); + ASSERT_NE(TestFile.PicturesListPicEncType.end(), TestFileIter); + ASSERT_EQ("base64", TestFileIter->second); + + // Check that it has the correct image type. + + TestFileIter = TestFile.PicturesListPictureType.find(2); + ASSERT_NE(TestFile.PicturesListPictureType.end(), TestFileIter); + ASSERT_EQ("image/png", TestFileIter->second); + + // Check the ALTID section. + + TestFileIter = TestFile.PicturesListAltID.find(2); + ASSERT_NE(TestFile.PicturesListAltID.end(), TestFileIter); + ASSERT_EQ("90", TestFileIter->second); + + // Check the PID section. + + TestFileIter = TestFile.PicturesListPID.find(2); + ASSERT_NE(TestFile.PicturesListPID.end(), TestFileIter); + ASSERT_EQ("91", TestFileIter->second); + + // Check the MEDIATYPE section. + + TestFileIter = TestFile.PicturesListMediatype.find(2); + ASSERT_NE(TestFile.PicturesListMediatype.end(), TestFileIter); + ASSERT_EQ("image/png", TestFileIter->second); + + // Check the PREF section. + + TestFileIntIter = TestFile.PicturesListPref.find(2); + ASSERT_NE(TestFile.PicturesListPref.end(), TestFileIntIter); + ASSERT_EQ(92, TestFileIntIter->second); + + // Check the extra tokens. + + TestFileIter = TestFile.PicturesListTokens.find(2); + ASSERT_NE(TestFile.PicturesListTokens.end(), TestFileIter); + ASSERT_EQ("PHOTO=YUP", TestFileIter->second); + +} + // TODO: Add tests for the Contact Loading process. \ No newline at end of file