Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Replaced mention of Xestia Address Book with Xestia Calendar
[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"
26 enum MenuOpts {
27         TESTS_ICALLOADEVENT = 1,
28         TESTS_ICALLOADTODO,
29         TESTS_ICALLOADJOURNAL,
30         TESTS_ICALLOADFREEBUSY,
31         TESTS_ICALLOADTIMEZONE,
32         TESTS_ICALLOADALARM,
33         TESTS_QUIT
34 };
36 void printn(std::string text){
37 // printn: Print a line and end with a newline (\n).
39         std::cout << text << std::endl;
41 }
43 void printmenu(){
44 // printmenu: Print the menu.
46         std::cout << "Select an option:" << std::endl << std::endl;
47         std::cout << TESTS_ICALLOADEVENT << ". iCalendar Event Component Load" << std::endl;
48         std::cout << TESTS_QUIT << ". Quit" << std::endl;
49         std::cout << std::endl;
51 }
53 int main(int argc, char* argv[]){
55         ::testing::InitGoogleTest(&argc, argv);
57         printn("Xestia Calendar Unit Testing Application");
58         printn("(c)2016 Xestia Software Development");
59         printn("Note: Unit testing is currently in development");
60         printn("");
62         bool ExitEnabled = false;
63         std::string StringOption = "";
64         int TestResult = 0;
66         while(ExitEnabled == false){
67         
68                 printmenu();
70                 // Get user input.
72                 std::cout << "Select Option: "; 
73                 std::cin >> StringOption;
74                 
75                 int IntOption = -1;
76                 
77                 // Check if input is a number.
78                 
79                 try{
80                         IntOption = stoi(StringOption);
81                 }
82                 
83                 // Return to the top of the while statement if input
84                 // really isn't a number.
85                 
86                 catch(std::invalid_argument e){
87                         printn("Error: Selected option is not a number.");
88                         continue;
89                 }
90                 
91                 // Find which option has been selected from the
92                 // input.
93                 
94                 switch(IntOption){
95                 
96                         case TESTS_ICALLOADEVENT:
97                                 printn("Running iCalendar Event Component tests...");
98                                 ::testing::GTEST_FLAG(filter) = "iCalendarEvent*";
99                                 TestResult = RUN_ALL_TESTS();
100                                 break;
101                         /*case TESTS_CARDDAV:
102                                 printn("Running CardDAV tests...");
103                                 ::testing::GTEST_FLAG(filter) = "CardDAV*";
104                                 TestResult = RUN_ALL_TESTS();
105                                 break;*/
106                         case TESTS_QUIT:
107                                 return 0;
108                                 break;
109                         default:
110                                 printn("Invalid menu number given."); 
111                                 break;
112                 
113                 }
114         
115         }
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