1 // xestiaab_convert.h - Xestia Address Book Convert Unit Tests.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include <gtest/gtest.h>
20 #include "../convert.h"
22 TEST(ConvertCmdLine, ConvertTests){
24 // Test that the input format is valid.
26 ASSERT_EQ(CONVERTRESULT_OK, ConvertContact(wxT("vCard4"),
28 wxT("LoadCheck-Load1.vcf"),
29 wxT("Temp-LoadCheck-Load1-v3Conv.vcf")));
30 ASSERT_EQ(CONVERTRESULT_OK, ConvertContact(wxT("vCard3"),
32 wxT("LoadCheck-Load1-v3.vcf"),
33 wxT("Temp-LoadCheck-Load1-v4Conv.vcf")));
35 // Test that a matching input and output formats return
38 ASSERT_EQ(CONVERTRESULT_FORMATSSAME, ConvertContact(wxT("vCard3"),
40 wxT("LoadCheck-Load1.vcf"),
41 wxT("Temp-LoadCheck-Load1-v3Conv.vcf")));
43 // Test that an invalid input format returns an error.
45 ASSERT_EQ(CONVERTRESULT_INVALIDINPUTFORMAT, ConvertContact(wxT("vCardNope"),
47 wxT("LoadCheck-Load1.vcf"),
48 wxT("Temp-LoadCheck-Load1-v3Conv.vcf")));
50 // Test that an empty input filename was given.
52 ASSERT_EQ(CONVERTRESULT_INPUTFILEEMPTY, ConvertContact(wxT("vCard3"),
55 wxT("Temp-LoadCheck-Load1-v3Conv.vcf")));
57 // Check that the input file given exists.
59 ASSERT_EQ(CONVERTRESULT_INPUTFILEMISSING, ConvertContact(wxT("vCard3"),
61 wxT("InvalidFile.vcf"),
62 wxT("Temp-LoadCheck-Load1-v3Conv.vcf")));
64 // Check that input file can't be opened.
66 ASSERT_EQ(CONVERTRESULT_INPUTFILEERROR, ConvertContact(wxT("vCard3"),
68 wxT("InvalidPermissions.vcf"),
69 wxT("Temp-LoadCheck-Load1-v3Conv.vcf")));
71 // Check that the output file can't be opened.
73 ASSERT_EQ(CONVERTRESULT_OUTPUTFILEERROR, ConvertContact(wxT("vCard3"),
75 wxT("LoadCheck-Load1.vcf"),
76 wxT("InvalidPermissions.vcf")));
78 // Check that the input file has the correct format.
79 // Tests for: vCard 4.0, vCard 3.0.
81 ASSERT_EQ(CONVERTRESULT_INPUTFILEINVALIDFORMAT, ConvertContact(wxT("vCard4"),
83 wxT("LoadCheck-Load1-v3.vcf"),
84 wxT("Temp-LoadCheck-Load1.vcf")));
86 ASSERT_EQ(CONVERTRESULT_INPUTFILEINVALIDFORMAT, ConvertContact(wxT("vCard3"),
88 wxT("LoadCheck-Load1.vcf"),
89 wxT("Temp-LoadCheck-Load1.vcf")));
91 // Check that that outputting to console (piping) works.
93 ASSERT_EQ(CONVERTRESULT_OK, ConvertContact(wxT("vCard4"),
95 wxT("LoadCheck-Load1.vcf"),
98 ASSERT_EQ(CONVERTRESULT_OK, ConvertContact(wxT("vCard3"),
100 wxT("LoadCheck-Load1-v3.vcf"),