From 2934c09b149efeb7f0dd7b5f2e8c12a578b05da4 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sat, 5 Dec 2015 23:44:26 +0000 Subject: [PATCH] Added test and code to check if an error occured whilst opening the input file. --- source/convert.cpp | 10 ++++++++++ source/convert.h | 1 + source/tests/xestiaab_convert.h | 7 ++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/source/convert.cpp b/source/convert.cpp index 8f6d7d1..69926de 100644 --- a/source/convert.cpp +++ b/source/convert.cpp @@ -80,6 +80,16 @@ ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat, } + wxFile InputFile; + + if (!InputFile.Open(InputFilename, wxFile::read, wxS_DEFAULT)){ + + int InputFileErrNo = InputFile.GetLastError(); + + return CONVERTRESULT_INPUTFILEERROR; + + } + return CONVERTRESULT_OK; } \ No newline at end of file diff --git a/source/convert.h b/source/convert.h index e1e438e..af99f8c 100644 --- a/source/convert.h +++ b/source/convert.h @@ -20,6 +20,7 @@ #define __CONVERT_H__ #include +#include #include #include diff --git a/source/tests/xestiaab_convert.h b/source/tests/xestiaab_convert.h index 2b185c0..7f3d3a7 100644 --- a/source/tests/xestiaab_convert.h +++ b/source/tests/xestiaab_convert.h @@ -59,6 +59,11 @@ TEST(ConvertCmdLine, ConvertTests){ ASSERT_EQ(CONVERTRESULT_INPUTFILEMISSING, ConvertContact(wxT("vCard3"), wxT("vCard4"), wxT("InvalidFile.vcf"), - wxT("Temp-LoadCheck-Load1-v3Conv.vcf"))); + wxT("Temp-LoadCheck-Load1-v3Conv.vcf"))); + + ASSERT_EQ(CONVERTRESULT_INPUTFILEERROR, ConvertContact(wxT("vCard3"), + wxT("vCard4"), + wxT("InvalidPermissions.vcf"), + wxT("Temp-LoadCheck-Load1-v3Conv.vcf"))); } \ No newline at end of file -- 2.39.5