1 // xestiaab_vcard.h - Xestia Address Book vCard 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>
21 #include "vcard/vcard.h"
23 TEST(vCard, LoadCheck){
27 // Do a failed loading test.
28 // LoadCheck-Invalid.vcf should never exist in the tests directory.
30 ASSERT_EQ(1, vCardTest.LoadFile("LoadCheck-Invalid.vcf"));
32 // Load a vCard that does exist in the tests directory.
34 ASSERT_EQ(0, vCardTest.LoadFile("LoadCheck-Load1.vcf"));
38 TEST(vCard, SaveCheck){
42 wxFFile vCardTestFileHdl;
43 wxString vCardTestData;
44 wxString vCardSaveCheck;
48 vCardTest.LoadFile("LoadCheck-Load1.vcf");
49 vCardSaveCheck = vCardTest.WriteString();
51 // Load the file again and put it into the vCardTestData
52 // string. Both sets of data should match.
54 vCardTestFileHdl.Open("LoadCheck-Load1.vcf", "r");
55 vCardTestFileHdl.ReadAll(&vCardTestData, wxConvAuto());
56 vCardTestFileHdl.Close();
58 ASSERT_EQ(vCardSaveCheck, vCardTestData);
60 vCardTestData.Clear();
61 vCardSaveCheck.Clear();
63 // Add a line and then compare with a saved file.
65 vCardTest2.AddRaw(wxT("BEGIN"), wxT("VCARD"));
66 vCardTest2.AddRaw(wxT("VERSION"), wxT("4.0"));
67 vCardTest2.AddRaw(wxT("FN"), wxT("Test vCard"));
68 vCardTest2.AddRaw(wxT("TITLE"), wxT("The Third Title"));
69 vCardTest2.AddRaw(wxT("TITLE"), wxT("Knight of the Tests"));
70 vCardTest2.AddRaw(wxT("TITLE"), wxT("The Tester of Cornwall"));
71 vCardTest2.AddRaw(wxT("END"), wxT("VCARD"));
73 vCardSaveCheck = vCardTest2.WriteString();
75 vCardTestFileHdl.Open("LoadCheck-Load2.vcf", "r");
76 vCardTestFileHdl.ReadAll(&vCardTestData, wxConvAuto());
77 vCardTestFileHdl.Close();
79 ASSERT_EQ(vCardSaveCheck, vCardTestData);
83 TEST(vCard, GetStrings){
89 TEST(vCard, GetMultipleStrings){
91 // Get multiple strings.
95 TEST(vCard, v3Conversion){
97 // Convert from a vCard v4 contact to a
102 TEST(vCard, v4Conversion){
104 // Convert from a vCard v3 contact to a
109 TEST(vCard, BackwardCompatability){
111 // Check backward compatability which should
112 // prevent data loss.