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