Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added SOURCE to the SaveString function of ContactDataObject
[xestiaab/.git] / source / tests / xestiaab_test.cpp
1 // xestiaab_test.cpp - Xestia Address Book Unit Testing Suite.
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 <iostream>
21 #include <string>
22 #include "xestiaab_carddav.h"
23 #include "xestiaab_contactload.h"
24 #include "xestiaab_contactsave.h"
25 #include "xestiaab_convert.h"
26 #include "xestiaab_vcard.h"
27 #include "xestiaab_common.h"
29 enum MenuOpts {
30         TESTS_CARDDAV = 1, 
31         TESTS_CONTACTLOAD,
32         TESTS_CONTACTSAVE, 
33         TESTS_VCARD,
34         TESTS_CONVERT,
35         TESTS_COMMON,
36         TESTS_ALL,
37         TESTS_QUIT
38 };
40 void printn(std::string text){
41 // printn: Print a line and end with a newline (\n).
43         std::cout << text << std::endl;
45 }
47 void printmenu(){
48 // printmenu: Print the menu.
50         std::cout << "Select an option:" << std::endl << std::endl;
51         std::cout << TESTS_CARDDAV << ". CardDAV Object" << std::endl;
52         std::cout << TESTS_CONTACTLOAD << ". Contact Loading" << std::endl;
53         std::cout << TESTS_CONTACTSAVE << ". Contact Saving" << std::endl;
54         std::cout << TESTS_VCARD << ". vCard Object" << std::endl;
55         std::cout << TESTS_CONVERT << ". Contact Conversion" << std::endl;
56         std::cout << TESTS_COMMON << ". Common Functions" << std::endl;
57         std::cout << TESTS_ALL << ". All Tests" << std::endl;
58         std::cout << TESTS_QUIT << ". Quit" << std::endl;
59         std::cout << std::endl;
61 }
63 int main(int argc, char* argv[]){
65         ::testing::InitGoogleTest(&argc, argv);
67         printn("Xestia Address Book Unit Testing Application");
68         printn("(c)2015 Xestia Software Development");
69         printn("Note: Unit testing is currently in development");
70         printn("");
72         bool ExitEnabled = false;
73         std::string StringOption = "";
74         int TestResult = 0;
76         while(ExitEnabled == false){
77         
78                 printmenu();
80                 // Get user input.
82                 std::cout << "Select Option: "; 
83                 std::cin >> StringOption;
84                 
85                 int IntOption = -1;
86                 
87                 // Check if input is a number.
88                 
89                 try{
90                         IntOption = stoi(StringOption);
91                 }
92                 
93                 // Return to the top of the while statement if input
94                 // really isn't a number.
95                 
96                 catch(std::invalid_argument e){
97                         printn("Error: Selected option is not a number.");
98                         continue;
99                 }
100                 
101                 // Find which option has been selected from the
102                 // input.
103                 
104                 switch(IntOption){
105                 
106                         case TESTS_CARDDAV:
107                                 printn("Running CardDAV tests...");
108                                 ::testing::GTEST_FLAG(filter) = "CardDAV*";
109                                 TestResult = RUN_ALL_TESTS();
110                                 break;
111                         case TESTS_CONTACTLOAD:
112                                 printn("Running Contact Loading tests...");
113                                 ::testing::GTEST_FLAG(filter) = "ContactLoad*";
114                                 TestResult = RUN_ALL_TESTS();
115                                 break;
116                         case TESTS_CONTACTSAVE:
117                                 printn("Running Contact Saving tests...");
118                                 ::testing::GTEST_FLAG(filter) = "ContactSave*";
119                                 TestResult = RUN_ALL_TESTS();
120                                 break;
121                         case TESTS_CONVERT:
122                                 printn("Running Contact Conversion tests...");
123                                 ::testing::GTEST_FLAG(filter) = "ConvertCmdLine*";
124                                 TestResult = RUN_ALL_TESTS();
125                                 break;
126                         case TESTS_VCARD:
127                                 printn("Running vCard tests...");
128                                 ::testing::GTEST_FLAG(filter) = "vCard*";
129                                 TestResult = RUN_ALL_TESTS();
130                                 break;
131                         case TESTS_COMMON:
132                                 printn("Running Common Functions tests...");
133                                 ::testing::GTEST_FLAG(filter) = "CommonFunctions*";
134                                 TestResult = RUN_ALL_TESTS();
135                                 break;
136                         case TESTS_ALL:
137                                 printn("Running all tests...");
138                                 ::testing::GTEST_FLAG(filter) = "*";
139                                 TestResult = RUN_ALL_TESTS();
140                                 break;
141                         case TESTS_QUIT:
142                                 return 0;
143                                 break;
144                         default:
145                                 printn("Invalid menu number given."); 
146                                 break;
147                 
148                 }
149         
150         }
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