From: Steve Brokenshire Date: Tue, 8 Dec 2015 18:55:00 +0000 (+0000) Subject: Added source, header and unit testing code for checking an invalid format for Contact... X-Git-Tag: release-0.09~247 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=cbb594a87fa3bf6d8511d637f8a390f0e9edc9ea;p=xestiaab%2F.git Added source, header and unit testing code for checking an invalid format for ContactDataObject. --- diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index f811e61..854cb56 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -35,8 +35,17 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ } // Check that the vCard is a valid vCard 4.0 file. + + + vCard vCard4FormatCheck; + + vCard4FormatCheck.LoadFile(Filename); + if (vCard4FormatCheck.Get("VERSION") != wxT("4.0")){ + return CONTACTLOAD_FILEINVALIDFORMAT; + + } return CONTACTLOAD_UNITTESTFAIL; diff --git a/source/contacteditor/ContactDataObject.h b/source/contacteditor/ContactDataObject.h index 00b9a72..dda7238 100644 --- a/source/contacteditor/ContactDataObject.h +++ b/source/contacteditor/ContactDataObject.h @@ -20,11 +20,15 @@ #define __CLIENTDATAOBJECT_H__ #include +#include #include +#include "../vcard/vcard.h" enum ContactLoadStatus{ CONTACTLOAD_UNITTESTFAIL = -1, - CONTACTLOAD_FILEMISSING + CONTACTLOAD_FILEMISSING, + CONTACTLOAD_FILEERROR, + CONTACTLOAD_FILEINVALIDFORMAT }; class ContactDataObject{ diff --git a/source/tests/xestiaab_contactload.h b/source/tests/xestiaab_contactload.h index f66f6d5..2c13711 100644 --- a/source/tests/xestiaab_contactload.h +++ b/source/tests/xestiaab_contactload.h @@ -32,6 +32,10 @@ TEST(ContactLoad, ContactLoadTests){ // 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")); }