Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added menu option for unit testing the iCalendar Task Component.
[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"
28 enum MenuOpts {
29         TESTS_ICALLOADEVENT = 1,
30         TESTS_ICALLOADTODO,
31         TESTS_ICALLOADJOURNAL,
32         TESTS_ICALLOADFREEBUSY,
33         TESTS_ICALLOADTIMEZONE,
34         TESTS_ICALLOADALARM,
35         TESTS_COMMONFUNCTIONS,
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_ICALLOADEVENT << ". iCalendar Event Component Load" << std::endl;
51         std::cout << TESTS_ICALLOADTODO << ". iCalendar Task Component Load" << std::endl;
52         std::cout << TESTS_COMMONFUNCTIONS << ". Common Functions" << std::endl;
53         std::cout << TESTS_QUIT << ". Quit" << std::endl;
54         std::cout << std::endl;
56 }
58 int main(int argc, char* argv[]){
60         ::testing::InitGoogleTest(&argc, argv);
62         printn("Xestia Calendar Unit Testing Application");
63         printn("(c)2016 Xestia Software Development");
64         printn("Note: Unit testing is currently in development");
65         printn("");
67         bool ExitEnabled = false;
68         std::string StringOption = "";
69         int TestResult = 0;
71         while(ExitEnabled == false){
72         
73                 printmenu();
75                 // Get user input.
77                 std::cout << "Select Option: "; 
78                 std::cin >> StringOption;
79                 
80                 int IntOption = -1;
81                 
82                 // Check if input is a number.
83                 
84                 try{
85                         IntOption = stoi(StringOption);
86                 }
87                 
88                 // Return to the top of the while statement if input
89                 // really isn't a number.
90                 
91                 catch(std::invalid_argument e){
92                         printn("Error: Selected option is not a number.");
93                         continue;
94                 }
95                 
96                 // Find which option has been selected from the
97                 // input.
98                 
99                 switch(IntOption){
100                 
101                         case TESTS_ICALLOADEVENT:
102                                 printn("Running iCalendar Event Component tests...");
103                                 ::testing::GTEST_FLAG(filter) = "iCalendarEvent*";
104                                 TestResult = RUN_ALL_TESTS();
105                                 break;
106                         case TESTS_ICALLOADTODO:
107                                 printn("Running iCalendar Task Component tests...");
108                                 ::testing::GTEST_FLAG(filter) = "iCalendarTask*";
109                                 TestResult = RUN_ALL_TESTS();
110                                 break;
111                         case TESTS_COMMONFUNCTIONS:
112                                 printn("Running Commmon Functions tests...");
113                                 ::testing::GTEST_FLAG(filter) = "CommonFunctions*";
114                                 TestResult = RUN_ALL_TESTS();
115                                 break;
116                         /*case TESTS_CARDDAV:
117                                 printn("Running CardDAV tests...");
118                                 ::testing::GTEST_FLAG(filter) = "CardDAV*";
119                                 TestResult = RUN_ALL_TESTS();
120                                 break;*/
121                         case TESTS_QUIT:
122                                 return 0;
123                                 break;
124                         default:
125                                 printn("Invalid menu number given."); 
126                                 break;
127                 
128                 }
129         
130         }
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