Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
ContactLoad Unit Tests: Partial split of tests to Given/When/Then format
[xestiaab/.git] / source / tests / xestiaab_convert.h
1 // xestiaab_convert.h - Xestia Address Book Convert Unit Tests.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
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.
10 //
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.
15 //
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.
25         
26         ASSERT_EQ(CONVERTRESULT_OK, ConvertContact(wxT("vCard4"), 
27                 wxT("vCard3"), 
28                 wxT("LoadCheck-Load1.vcf"), 
29                 wxT("Temp-LoadCheck-Load1-v3Conv.vcf")));
30         ASSERT_EQ(CONVERTRESULT_OK, ConvertContact(wxT("vCard3"), 
31                 wxT("vCard4"), 
32                 wxT("LoadCheck-Load1-v3.vcf"), 
33                 wxT("Temp-LoadCheck-Load1-v4Conv.vcf")));
34                 
35         // Test that a matching input and output formats return
36         // an error.
38         ASSERT_EQ(CONVERTRESULT_FORMATSSAME, ConvertContact(wxT("vCard3"), 
39                 wxT("vCard3"), 
40                 wxT("LoadCheck-Load1.vcf"), 
41                 wxT("Temp-LoadCheck-Load1-v3Conv.vcf")));
42                 
43         // Test that an invalid input format returns an error.
44                 
45         ASSERT_EQ(CONVERTRESULT_INVALIDINPUTFORMAT, ConvertContact(wxT("vCardNope"), 
46                 wxT("vCard3"), 
47                 wxT("LoadCheck-Load1.vcf"), 
48                 wxT("Temp-LoadCheck-Load1-v3Conv.vcf")));
50         // Test that an empty input filename was given.
51         
52         ASSERT_EQ(CONVERTRESULT_INPUTFILEEMPTY, ConvertContact(wxT("vCard3"), 
53                 wxT("vCard4"), 
54                 wxT(""), 
55                 wxT("Temp-LoadCheck-Load1-v3Conv.vcf")));
57         // Check that the input file given exists.
58         
59         ASSERT_EQ(CONVERTRESULT_INPUTFILEMISSING, ConvertContact(wxT("vCard3"), 
60                 wxT("vCard4"), 
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"), 
67                 wxT("vCard4"), 
68                 wxT("InvalidPermissions.vcf"), 
69                 wxT("Temp-LoadCheck-Load1-v3Conv.vcf")));
70                 
71         // Check that the output file can't be opened.
72         
73         ASSERT_EQ(CONVERTRESULT_OUTPUTFILEERROR, ConvertContact(wxT("vCard3"), 
74                 wxT("vCard4"), 
75                 wxT("LoadCheck-Load1.vcf"), 
76                 wxT("InvalidPermissions.vcf")));
77                 
78         // Check that the input file has the correct format.
79         // Tests for: vCard 4.0, vCard 3.0.
80         
81         ASSERT_EQ(CONVERTRESULT_INPUTFILEINVALIDFORMAT, ConvertContact(wxT("vCard4"), 
82                 wxT("vCard3"), 
83                 wxT("LoadCheck-Load1-v3.vcf"), 
84                 wxT("Temp-LoadCheck-Load1.vcf")));
86         ASSERT_EQ(CONVERTRESULT_INPUTFILEINVALIDFORMAT, ConvertContact(wxT("vCard3"), 
87                 wxT("vCard4"), 
88                 wxT("LoadCheck-Load1.vcf"), 
89                 wxT("Temp-LoadCheck-Load1.vcf")));
90                 
91         // Check that that outputting to console (piping) works.
92         
93         ASSERT_EQ(CONVERTRESULT_OK, ConvertContact(wxT("vCard4"), 
94                 wxT("vCard3"), 
95                 wxT("LoadCheck-Load1.vcf"), 
96                 wxT("")));
98         ASSERT_EQ(CONVERTRESULT_OK, ConvertContact(wxT("vCard3"), 
99                 wxT("vCard4"), 
100                 wxT("LoadCheck-Load1-v3.vcf"), 
101                 wxT("")));
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