Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added menu option for testing common functions.
[xestiacalendar/.git] / source / tests / xestiacalendar_test.cpp
1 // xestiacalendar_test.cpp - Xestia Calendar Unit Testing Suite.
2 //
3 // (c) 2016 Xestia Software Development.
4 //
5 // This file is part of Xestia Calendar.
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 Calendar. If not, see <http://www.gnu.org/licenses/>
19 #include <gtest/gtest.h>
20 #include <iostream>
21 #include <string>
22 #include <stdexcept>
24 #include "xestiacalendar_icaleventload.h"
25 #include "xestiacalendar_commonfunctions.h"
27 enum MenuOpts {
28         TESTS_ICALLOADEVENT = 1,
29         TESTS_ICALLOADTODO,
30         TESTS_ICALLOADJOURNAL,
31         TESTS_ICALLOADFREEBUSY,
32         TESTS_ICALLOADTIMEZONE,
33         TESTS_ICALLOADALARM,
34         TESTS_COMMONFUNCTIONS,
35         TESTS_QUIT
36 };
38 void printn(std::string text){
39 // printn: Print a line and end with a newline (\n).
41         std::cout << text << std::endl;
43 }
45 void printmenu(){
46 // printmenu: Print the menu.
48         std::cout << "Select an option:" << std::endl << std::endl;
49         std::cout << TESTS_ICALLOADEVENT << ". iCalendar Event Component Load" << std::endl;
50         std::cout << TESTS_COMMONFUNCTIONS << ". Common Functions" << std::endl;
51         std::cout << TESTS_QUIT << ". Quit" << std::endl;
52         std::cout << std::endl;
54 }
56 int main(int argc, char* argv[]){
58         ::testing::InitGoogleTest(&argc, argv);
60         printn("Xestia Calendar Unit Testing Application");
61         printn("(c)2016 Xestia Software Development");
62         printn("Note: Unit testing is currently in development");
63         printn("");
65         bool ExitEnabled = false;
66         std::string StringOption = "";
67         int TestResult = 0;
69         while(ExitEnabled == false){
70         
71                 printmenu();
73                 // Get user input.
75                 std::cout << "Select Option: "; 
76                 std::cin >> StringOption;
77                 
78                 int IntOption = -1;
79                 
80                 // Check if input is a number.
81                 
82                 try{
83                         IntOption = stoi(StringOption);
84                 }
85                 
86                 // Return to the top of the while statement if input
87                 // really isn't a number.
88                 
89                 catch(std::invalid_argument e){
90                         printn("Error: Selected option is not a number.");
91                         continue;
92                 }
93                 
94                 // Find which option has been selected from the
95                 // input.
96                 
97                 switch(IntOption){
98                 
99                         case TESTS_ICALLOADEVENT:
100                                 printn("Running iCalendar Event Component tests...");
101                                 ::testing::GTEST_FLAG(filter) = "iCalendarEvent*";
102                                 TestResult = RUN_ALL_TESTS();
103                                 break;
104                         case TESTS_COMMONFUNCTIONS:
105                                 printn("Running Commmon Functions tests...");
106                                 ::testing::GTEST_FLAG(filter) = "CommonFunctions*";
107                                 TestResult = RUN_ALL_TESTS();
108                                 break;
109                         /*case TESTS_CARDDAV:
110                                 printn("Running CardDAV tests...");
111                                 ::testing::GTEST_FLAG(filter) = "CardDAV*";
112                                 TestResult = RUN_ALL_TESTS();
113                                 break;*/
114                         case TESTS_QUIT:
115                                 return 0;
116                                 break;
117                         default:
118                                 printn("Invalid menu number given."); 
119                                 break;
120                 
121                 }
122         
123         }
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