From 4417b88a03989fadac9099843cbcb107e66ffa0a Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 26 Jun 2016 23:33:21 +0100 Subject: [PATCH] Setup unit test for testing the LoadCheck-Load1.vcf file --- .../cdo/ContactDataObject-Save.cpp | 45 +++++++++++++++++++ source/tests/xestiaab_contactsave.h | 8 ++++ 2 files changed, 53 insertions(+) diff --git a/source/contacteditor/cdo/ContactDataObject-Save.cpp b/source/contacteditor/cdo/ContactDataObject-Save.cpp index 3b13b4d..8a0f2b7 100644 --- a/source/contacteditor/cdo/ContactDataObject-Save.cpp +++ b/source/contacteditor/cdo/ContactDataObject-Save.cpp @@ -23,7 +23,52 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){ ContactSaveStatus SaveDataStatus = CONTACTSAVE_UNITTESTFAIL; + // Write the header for the vCard data file. + SaveData->Append("BEGIN:VCARD\n"); + SaveData->Append("VERSION:4.0\n"); + + // Write the product ID. + +#ifdef XAB_UNITTEST + + SaveData->Append("PRODID:-//Xestia//Address Book Unit Testing//KW\n"); + +#else + + SaveData->Append(wxT("-//Xestia//Address Book Version ")); + SaveData->Append(wxT(XSDAB_VERSION)); + SaveData->Append(wxT("//KW\n")); + +#endif + + // Process FN. + + for (std::map::iterator FNIter = FullNamesList.begin(); + FNIter != FullNamesList.end(); FNIter++){ + + SaveData->Append("FN:"); + SaveData->Append(FNIter->second); + SaveData->Append("\n"); + + } + + // Process TITLE. + + for (std::map::iterator TitleIter = GeneralTitleList.begin(); + TitleIter != GeneralTitleList.end(); TitleIter++){ + + SaveData->Append("TITLE:"); + SaveData->Append(TitleIter->second); + SaveData->Append("\n"); + + } + + // Write the end part of the vCard data file. + + SaveData->Append("END:VCARD"); + + SaveDataStatus = CONTACTSAVE_OK; return SaveDataStatus; diff --git a/source/tests/xestiaab_contactsave.h b/source/tests/xestiaab_contactsave.h index 46608f2..b8834b8 100644 --- a/source/tests/xestiaab_contactsave.h +++ b/source/tests/xestiaab_contactsave.h @@ -24,9 +24,17 @@ TEST(ContactSave, ContactSaveTests){ ContactDataObject TestFile1; wxString SaveData; + wxString SaveDataCompare = "BEGIN:VCARD\n" + "VERSION:4.0\n" + "PRODID:-//Xestia//Address Book Unit Testing//KW\n" + "FN:Test vCard\n" + "TITLE:Knight of the Tests\n" + "TITLE:The Tester of Cornwall\n" + "END:VCARD"; ASSERT_EQ(CONTACTLOAD_OK, TestFile1.LoadFile("LoadCheck-Load1.vcf")); ASSERT_EQ(CONTACTSAVE_OK, TestFile1.SaveString(&SaveData)); + ASSERT_EQ(SaveDataCompare, SaveData); } \ No newline at end of file -- 2.39.5