Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added iCalendar Alarm Component Load unit test to the menu.
[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"
26 #include "xestiacalendar_icaltaskload.h"
27 #include "xestiacalendar_icaljournalload.h"
28 #include "xestiacalendar_icalfreebusyload.h"
29 #include "xestiacalendar_icaltimezoneload.h"
30 #include "xestiacalendar_icalalarmload.h"
32 enum MenuOpts {
33         TESTS_ICALLOADEVENT = 1,
34         TESTS_ICALLOADTODO,
35         TESTS_ICALLOADJOURNAL,
36         TESTS_ICALLOADFREEBUSY,
37         TESTS_ICALLOADTIMEZONE,
38         TESTS_ICALLOADALARM,
39         TESTS_COMMONFUNCTIONS,
40         TESTS_QUIT
41 };
43 void printn(std::string text){
44 // printn: Print a line and end with a newline (\n).
46         std::cout << text << std::endl;
48 }
50 void printmenu(){
51 // printmenu: Print the menu.
53         std::cout << "Select an option:" << std::endl << std::endl;
54         std::cout << TESTS_ICALLOADEVENT << ". iCalendar Event Component Load" << std::endl;
55         std::cout << TESTS_ICALLOADTODO << ". iCalendar Task Component Load" << std::endl;
56         std::cout << TESTS_ICALLOADJOURNAL << ". iCalendar Journal Component Load" << std::endl;
57         std::cout << TESTS_ICALLOADFREEBUSY << ". iCalendar FreeBusy Component Load" << std::endl;
58         std::cout << TESTS_ICALLOADTIMEZONE << ". iCalendar Timezone Component Load" << std::endl;
59         std::cout << TESTS_ICALLOADALARM << ". iCalendar Alarm Component Load" << std::endl;
60         std::cout << TESTS_COMMONFUNCTIONS << ". Common Functions" << std::endl;
61         std::cout << TESTS_QUIT << ". Quit" << std::endl;
62         std::cout << std::endl;
64 }
66 int main(int argc, char* argv[]){
68         ::testing::InitGoogleTest(&argc, argv);
70         printn("Xestia Calendar Unit Testing Application");
71         printn("(c)2016 Xestia Software Development");
72         printn("Note: Unit testing is currently in development");
73         printn("");
75         bool ExitEnabled = false;
76         std::string StringOption = "";
77         int TestResult = 0;
79         while(ExitEnabled == false){
80         
81                 printmenu();
83                 // Get user input.
85                 std::cout << "Select Option: "; 
86                 std::cin >> StringOption;
87                 
88                 int IntOption = -1;
89                 
90                 // Check if input is a number.
91                 
92                 try{
93                         IntOption = stoi(StringOption);
94                 }
95                 
96                 // Return to the top of the while statement if input
97                 // really isn't a number.
98                 
99                 catch(std::invalid_argument e){
100                         printn("Error: Selected option is not a number.");
101                         continue;
102                 }
103                 
104                 // Find which option has been selected from the
105                 // input.
106                 
107                 switch(IntOption){
108                 
109                         case TESTS_ICALLOADEVENT:
110                                 printn("Running iCalendar Event Component tests...");
111                                 ::testing::GTEST_FLAG(filter) = "iCalendarEvent*";
112                                 TestResult = RUN_ALL_TESTS();
113                                 break;
114                         case TESTS_ICALLOADTODO:
115                                 printn("Running iCalendar Task Component tests...");
116                                 ::testing::GTEST_FLAG(filter) = "iCalendarTask*";
117                                 TestResult = RUN_ALL_TESTS();
118                                 break;
119                         case TESTS_ICALLOADJOURNAL:
120                                 printn("Running iCalendar Journal Component tests...");
121                                 ::testing::GTEST_FLAG(filter) = "iCalendarJournal*";
122                                 TestResult = RUN_ALL_TESTS();
123                                 break;
124                         case TESTS_ICALLOADFREEBUSY:
125                                 printn("Running iCalendar Free Busy Component tests...");
126                                 ::testing::GTEST_FLAG(filter) = "iCalendarFreeBusy*";
127                                 TestResult = RUN_ALL_TESTS();
128                                 break;
129                         case TESTS_ICALLOADTIMEZONE:
130                                 printn("Running iCalendar Free Busy Component tests...");
131                                 ::testing::GTEST_FLAG(filter) = "iCalendarTimezone*";
132                                 TestResult = RUN_ALL_TESTS();
133                                 break;
134                         case TESTS_ICALLOADALARM:
135                                 printn("Running iCalendar Alarm Component tests...");
136                                 ::testing::GTEST_FLAG(filter) = "iCalendarAlarm*";
137                                 TestResult = RUN_ALL_TESTS();
138                                 break;
139                         case TESTS_COMMONFUNCTIONS:
140                                 printn("Running Commmon Functions tests...");
141                                 ::testing::GTEST_FLAG(filter) = "CommonFunctions*";
142                                 TestResult = RUN_ALL_TESTS();
143                                 break;
144                         /*case TESTS_CARDDAV:
145                                 printn("Running CardDAV tests...");
146                                 ::testing::GTEST_FLAG(filter) = "CardDAV*";
147                                 TestResult = RUN_ALL_TESTS();
148                                 break;*/
149                         case TESTS_QUIT:
150                                 return 0;
151                                 break;
152                         default:
153                                 printn("Invalid menu number given."); 
154                                 break;
155                 
156                 }
157         
158         }
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