1 #include <gtest/gtest.h>
4 #include "xestiaab_carddav.h"
5 #include "xestiaab_contactload.h"
6 #include "xestiaab_contactsave.h"
7 #include "xestiaab_vcard.h"
18 void printn(std::string text){
19 // printn: Print a line and end with a newline (\n).
21 std::cout << text << std::endl;
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;
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");
48 bool ExitEnabled = false;
49 std::string StringOption = "";
52 while(ExitEnabled == false){
58 std::cout << "Select Option: ";
59 std::cin >> StringOption;
63 // Check if input is a number.
66 IntOption = stoi(StringOption);
69 // Return to the top of the while statement if input
70 // really isn't a number.
72 catch(std::invalid_argument e){
73 printn("Error: Selected option is not a number.");
77 // Find which option has been selected from the
83 printn("Running CardDAV tests...");
84 ::testing::GTEST_FLAG(filter) = "CardDAV*";
85 TestResult = RUN_ALL_TESTS();
87 case TESTS_CONTACTLOAD:
88 printn("Running Contact Loading tests...");
89 ::testing::GTEST_FLAG(filter) = "ContactLoad*";
90 TestResult = RUN_ALL_TESTS();
92 case TESTS_CONTACTSAVE:
93 printn("Running Contact Saving tests...");
94 ::testing::GTEST_FLAG(filter) = "ContactSave*";
95 TestResult = RUN_ALL_TESTS();
98 printn("Running vCard tests...");
99 ::testing::GTEST_FLAG(filter) = "vCard*";
100 TestResult = RUN_ALL_TESTS();
103 printn("Running all tests...");
104 ::testing::GTEST_FLAG(filter) = "*";
105 TestResult = RUN_ALL_TESTS();
111 printn("Invalid menu number given.");