1 // xestiacalendar_test.cpp - Xestia Calendar Unit Testing Suite.
3 // (c) 2016 Xestia Software Development.
5 // This file is part of Xestia Calendar.
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.
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.
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 <curl/curl.h>
20 #include <gtest/gtest.h>
25 #include "xestiacalendar_commonfunctions.h"
26 #include "xestiacalendar_populate.h"
27 #include "xestiacalendar_icaleventload.h"
28 #include "xestiacalendar_icaltaskload.h"
29 #include "xestiacalendar_icaljournalload.h"
30 #include "xestiacalendar_icalfreebusyload.h"
31 #include "xestiacalendar_icaltimezoneload.h"
32 #include "xestiacalendar_caldav.h"
35 TESTS_ICALLOADEVENT = 1,
37 TESTS_ICALLOADJOURNAL,
38 TESTS_ICALLOADFREEBUSY,
39 TESTS_ICALLOADTIMEZONE,
41 TESTS_COMMONFUNCTIONS,
47 EXTRA_POPULATECALDAV = 1,
51 void printn(std::string text){
52 // printn: Print a line and end with a newline (\n).
54 std::cout << text << std::endl;
59 // printmenu: Print the menu.
61 std::cout << "Select an option:" << std::endl << std::endl;
62 std::cout << TESTS_ICALLOADEVENT << ". iCalendar Event Component Load" << std::endl;
63 std::cout << TESTS_ICALLOADTODO << ". iCalendar Task Component Load" << std::endl;
64 std::cout << TESTS_ICALLOADJOURNAL << ". iCalendar Journal Component Load" << std::endl;
65 std::cout << TESTS_ICALLOADFREEBUSY << ". iCalendar FreeBusy Component Load" << std::endl;
66 std::cout << TESTS_ICALLOADTIMEZONE << ". iCalendar Timezone Component Load" << std::endl;
67 std::cout << TESTS_CALDAV << ". CalDAV Object" << std::endl;
68 std::cout << TESTS_COMMONFUNCTIONS << ". Common Functions" << std::endl;
69 std::cout << TESTS_EXTRA << ". Extra Functions Menu" << std::endl;
70 std::cout << TESTS_QUIT << ". Quit" << std::endl;
71 std::cout << std::endl;
75 void printextramenu(){
77 std::cout << "Extra Functions Menu" << std::endl << std::endl;
78 std::cout << "Select an option:" << std::endl << std::endl;
79 std::cout << EXTRA_POPULATECALDAV << ". Populate CalDAV calendar" << std::endl;
80 std::cout << EXTRA_RETURN << ". Return to previous menu" << std::endl;
81 std::cout << std::endl;
87 bool ExitEnabled = false;
88 std::string StringOption = "";
91 while(ExitEnabled == false){
97 std::cout << "Select Option: ";
98 std::cin >> StringOption;
102 // Check if input is a number.
105 IntOption = stoi(StringOption);
108 // Return to the top of the while statement if input
109 // really isn't a number.
111 catch(std::invalid_argument e){
112 printn("Error: Selected option is not a number.");
116 // Find which option has been selected from the
121 case EXTRA_POPULATECALDAV:
122 printn("Populating CalDAV calendar...");
129 printn("Invalid menu number given.");
138 int main(int argc, char* argv[]){
140 // Initialise the several libraries that have
143 ::testing::InitGoogleTest(&argc, argv);
144 curl_global_init(CURL_GLOBAL_ALL);
146 printn("Xestia Calendar Unit Testing Application");
147 printn("(c)2016 Xestia Software Development");
148 printn("Note: Unit testing is currently in development");
151 bool ExitEnabled = false;
152 std::string StringOption = "";
155 while(ExitEnabled == false){
161 std::cout << "Select Option: ";
162 std::cin >> StringOption;
166 // Check if input is a number.
169 IntOption = stoi(StringOption);
172 // Return to the top of the while statement if input
173 // really isn't a number.
175 catch(std::invalid_argument e){
176 printn("Error: Selected option is not a number.");
180 // Find which option has been selected from the
185 case TESTS_ICALLOADEVENT:
186 printn("Running iCalendar Event Component tests...");
187 ::testing::GTEST_FLAG(filter) = "iCalendarEvent*";
188 TestResult = RUN_ALL_TESTS();
190 case TESTS_ICALLOADTODO:
191 printn("Running iCalendar Task Component tests...");
192 ::testing::GTEST_FLAG(filter) = "iCalendarTask*";
193 TestResult = RUN_ALL_TESTS();
195 case TESTS_ICALLOADJOURNAL:
196 printn("Running iCalendar Journal Component tests...");
197 ::testing::GTEST_FLAG(filter) = "iCalendarJournal*";
198 TestResult = RUN_ALL_TESTS();
200 case TESTS_ICALLOADFREEBUSY:
201 printn("Running iCalendar Free Busy Component tests...");
202 ::testing::GTEST_FLAG(filter) = "iCalendarFreeBusy*";
203 TestResult = RUN_ALL_TESTS();
205 case TESTS_ICALLOADTIMEZONE:
206 printn("Running iCalendar Free Busy Component tests...");
207 ::testing::GTEST_FLAG(filter) = "iCalendarTimezone*";
208 TestResult = RUN_ALL_TESTS();
211 printn("Running CalDAV tests...");
212 ::testing::GTEST_FLAG(filter) = "CalDAV*";
213 TestResult = RUN_ALL_TESTS();
215 case TESTS_COMMONFUNCTIONS:
216 printn("Running Commmon Functions tests...");
217 ::testing::GTEST_FLAG(filter) = "CommonFunctions*";
218 TestResult = RUN_ALL_TESTS();
227 printn("Invalid menu number given.");