Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
477ee9c55e340e8594a02466a1e5d0e1f9d632d3
[xestiaab/.git] / source / tests / xestiaab_test.cpp
1 #include <gtest/gtest.h>
2 #include <iostream>
3 #include <string>
4 #include "xestiaab_carddav.h"
5 #include "xestiaab_contactload.h"
6 #include "xestiaab_contactsave.h"
7 #include "xestiaab_vcard.h"
9 enum MenuOpts {
10         TESTS_CARDDAV = 1, 
11         TESTS_CONTACTLOAD,
12         TESTS_CONTACTSAVE, 
13         TESTS_VCARD,
14         TESTS_ALL,
15         TESTS_QUIT
16 };
18 void printn(std::string text){
19 // printn: Print a line and end with a newline (\n).
21         std::cout << text << std::endl;
23 }
25 void printmenu(){
26 // printmenu: Print the menu.
28         std::cout << "Select an option:" << std::endl << std::endl;
29         std::cout << TESTS_CARDDAV << ". CardDAV Object" << std::endl;
30         std::cout << TESTS_CONTACTLOAD << ". Contact Loading" << std::endl;
31         std::cout << TESTS_CONTACTSAVE << ". Contact Saving" << std::endl;
32         std::cout << TESTS_VCARD << ". vCard Object" << std::endl;
33         std::cout << TESTS_ALL << ". All Tests" << std::endl;
34         std::cout << TESTS_QUIT << ". Quit" << std::endl;
35         std::cout << std::endl;
37 }
39 int main(int argc, char* argv[]){
41         ::testing::InitGoogleTest(&argc, argv);
43         printn("Xestia Address Book Unit Testing Application");
44         printn("(c)2015 Xestia Software Development");
45         printn("Note: Unit testing is currently in development");
46         printn("");
48         bool ExitEnabled = false;
49         std::string StringOption = "";
50         int TestResult = 0;
52         while(ExitEnabled == false){
53         
54                 printmenu();
56                 // Get user input.
58                 std::cout << "Select Option: "; 
59                 std::cin >> StringOption;
60                 
61                 int IntOption = -1;
62                 
63                 // Check if input is a number.
64                 
65                 try{
66                         IntOption = stoi(StringOption);
67                 }
68                 
69                 // Return to the top of the while statement if input
70                 // really isn't a number.
71                 
72                 catch(std::invalid_argument e){
73                         printn("Error: Selected option is not a number.");
74                         continue;
75                 }
76                 
77                 // Find which option has been selected from the
78                 // input.
79                 
80                 switch(IntOption){
81                 
82                         case TESTS_CARDDAV:
83                                 printn("Running CardDAV tests...");
84                                 ::testing::GTEST_FLAG(filter) = "CardDAV*";
85                                 TestResult = RUN_ALL_TESTS();
86                                 break;
87                         case TESTS_CONTACTLOAD:
88                                 printn("Running Contact Loading tests...");
89                                 ::testing::GTEST_FLAG(filter) = "ContactLoad*";
90                                 TestResult = RUN_ALL_TESTS();
91                                 break;
92                         case TESTS_CONTACTSAVE:
93                                 printn("Running Contact Saving tests...");
94                                 ::testing::GTEST_FLAG(filter) = "ContactSave*";
95                                 TestResult = RUN_ALL_TESTS();
96                                 break;
97                         case TESTS_VCARD:
98                                 printn("Running vCard tests...");
99                                 ::testing::GTEST_FLAG(filter) = "vCard*";
100                                 TestResult = RUN_ALL_TESTS();
101                                 break;
102                         case TESTS_ALL:
103                                 printn("Running all tests...");
104                                 ::testing::GTEST_FLAG(filter) = "*";
105                                 TestResult = RUN_ALL_TESTS();
106                                 break;
107                         case TESTS_QUIT:
108                                 return 0;
109                                 break;
110                         default:
111                                 printn("Invalid menu number given."); 
112                                 break;
113                 
114                 }
115         
116         }
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