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