Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added input file missing test and replaced wording of import/export with input/output.
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 5 Dec 2015 22:48:59 +0000 (22:48 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 5 Dec 2015 22:48:59 +0000 (22:48 +0000)
source/convert.cpp
source/convert.h
source/tests/xestiaab_convert.h

index d8578d7..8f6d7d1 100644 (file)
@@ -26,7 +26,7 @@ ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat,
                wxT("vCard4") 
        };
 
-       bool ValidImport = false;
+       bool ValidInput = false;
        bool ValidOutput = false;
 
        // Check that the input format is valid.
@@ -34,26 +34,52 @@ ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat,
        for (long l = 0; l < ValidFormats.size(); l++){
        
                if (InputFormat == ValidFormats[l]){
-                       ValidImport = true;
+                       ValidInput = true;
                        break;
                }
        
        }
        
-       if (ValidImport == false){
+       if (ValidInput == false){
        
-               return CONVERTRESULT_INVALIDIMPORTFORMAT;
+               return CONVERTRESULT_INVALIDINPUTFORMAT;
        
        }
 
+       // Check that the output format is valid.
+
+       for (long l = 0; l < ValidFormats.size(); l++){
+       
+               if (OutputFormat == ValidFormats[l]){
+                       ValidOutput = true;
+                       break;
+               }
+       
+       }
+       
+       if (ValidOutput == false){
+       
+               return CONVERTRESULT_INVALIDOUTPUTFORMAT;
+       
+       }
+
+       // Check that the input and output formats
+       // are not the same.
+
        if (InputFormat == OutputFormat){
        
                return CONVERTRESULT_FORMATSSAME;
        
        }
        
-       // Check that the output format is valid.
-
+       // Check that the input file given exists.
+       
+       if (!wxFileExists(InputFilename)){
+               
+               return CONVERTRESULT_INPUTFILEMISSING;
+               
+       }
+       
        return CONVERTRESULT_OK;
        
 }
\ No newline at end of file
index 8994dbe..e1e438e 100644 (file)
@@ -27,13 +27,13 @@ enum ConvertResult {
        CONVERTRESULT_UNITTESTFAIL = -1,
        CONVERTRESULT_OK,
        CONVERTRESULT_FORMATSSAME,
-       CONVERTRESULT_INVALIDIMPORTFORMAT,
-       CONVERTRESULT_INVALIDEXPORTFORMAT,
-       CONVERTRESULT_IMPORTFILEMISSING,
-       CONVERTRESULT_IMPORTFILEERROR,
+       CONVERTRESULT_INVALIDINPUTFORMAT,
+       CONVERTRESULT_INVALIDOUTPUTFORMAT,
+       CONVERTRESULT_INPUTFILEMISSING,
+       CONVERTRESULT_INPUTFILEERROR,
 };
 
-ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat, 
+ConvertResult ConvertContact(wxString InputFormat, wxString ExportFormat, 
        wxString InputFilename, wxString OutputFilename);
 
 #endif
\ No newline at end of file
index 383b18d..2b185c0 100644 (file)
@@ -21,7 +21,7 @@
 
 TEST(ConvertCmdLine, ConvertTests){
 
-       // Test that the import format is valid.
+       // Test that the input format is valid.
        
        ASSERT_EQ(CONVERTRESULT_OK, ConvertContact(wxT("vCard4"), 
                wxT("vCard3"), 
@@ -30,9 +30,9 @@ TEST(ConvertCmdLine, ConvertTests){
        ASSERT_EQ(CONVERTRESULT_OK, ConvertContact(wxT("vCard3"), 
                wxT("vCard4"), 
                wxT("LoadCheck-Load1.vcf"), 
-               wxT("LoadCheck-Load1-v3Conv.vcf")));            
+               wxT("LoadCheck-Load1-v3Conv.vcf")));
                
-       // Test that a matching import and export formats return
+       // Test that a matching input and output formats return
        // an error.
 
        ASSERT_EQ(CONVERTRESULT_FORMATSSAME, ConvertContact(wxT("vCard3"), 
@@ -40,11 +40,25 @@ TEST(ConvertCmdLine, ConvertTests){
                wxT("LoadCheck-Load1.vcf"), 
                wxT("LoadCheck-Load1-v3Conv.vcf")));
                
-       // Test that an invalid import format returns an error.
+       // Test that an invalid input format returns an error.
                
-       ASSERT_EQ(CONVERTRESULT_INVALIDIMPORTFORMAT, ConvertContact(wxT("vCardNope"), 
+       ASSERT_EQ(CONVERTRESULT_INVALIDINPUTFORMAT, ConvertContact(wxT("vCardNope"), 
                wxT("vCard3"), 
                wxT("LoadCheck-Load1.vcf"), 
                wxT("LoadCheck-Load1-v3Conv.vcf")));
+               
+       // Test that an invalid output format return an error.
+       
+       ASSERT_EQ(CONVERTRESULT_INVALIDOUTPUTFORMAT, ConvertContact(wxT("vCard3"), 
+               wxT("vCardNope"), 
+               wxT("LoadCheck-Load1.vcf"), 
+               wxT("LoadCheck-Load1-v3Conv.vcf")));
+
+       // Check that the file given exists.
+       
+       ASSERT_EQ(CONVERTRESULT_INPUTFILEMISSING, ConvertContact(wxT("vCard3"), 
+               wxT("vCard4"), 
+               wxT("InvalidFile.vcf"), 
+               wxT("Temp-LoadCheck-Load1-v3Conv.vcf"))); 
 
 }
\ No newline at end of file
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