Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added source, header and unit testing code for checking an invalid format for Contact...
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Tue, 8 Dec 2015 18:55:00 +0000 (18:55 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Tue, 8 Dec 2015 18:55:00 +0000 (18:55 +0000)
source/contacteditor/ContactDataObject.cpp
source/contacteditor/ContactDataObject.h
source/tests/xestiaab_contactload.h

index f811e61..854cb56 100644 (file)
@@ -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;
 
index 00b9a72..dda7238 100644 (file)
 #define __CLIENTDATAOBJECT_H__
 
 #include <wx/wx.h>
+#include <wx/file.h>
 #include <map>
+#include "../vcard/vcard.h"
 
 enum ContactLoadStatus{
        CONTACTLOAD_UNITTESTFAIL = -1,
-       CONTACTLOAD_FILEMISSING
+       CONTACTLOAD_FILEMISSING,
+       CONTACTLOAD_FILEERROR,
+       CONTACTLOAD_FILEINVALIDFORMAT
 };
 
 class ContactDataObject{
index f66f6d5..2c13711 100644 (file)
@@ -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"));
 
 }
 
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy