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_icaleventload.h"
26 #include "xestiacalendar_commonfunctions.h"
27 #include "xestiacalendar_icaltaskload.h"
28 #include "xestiacalendar_icaljournalload.h"
29 #include "xestiacalendar_icalfreebusyload.h"
30 #include "xestiacalendar_icaltimezoneload.h"
31 #include "xestiacalendar_caldav.h"
34 TESTS_ICALLOADEVENT = 1,
36 TESTS_ICALLOADJOURNAL,
37 TESTS_ICALLOADFREEBUSY,
38 TESTS_ICALLOADTIMEZONE,
40 TESTS_COMMONFUNCTIONS,
44 void printn(std::string text){
45 // printn: Print a line and end with a newline (\n).
47 std::cout << text << std::endl;
52 // printmenu: Print the menu.
54 std::cout << "Select an option:" << std::endl << std::endl;
55 std::cout << TESTS_ICALLOADEVENT << ". iCalendar Event Component Load" << std::endl;
56 std::cout << TESTS_ICALLOADTODO << ". iCalendar Task Component Load" << std::endl;
57 std::cout << TESTS_ICALLOADJOURNAL << ". iCalendar Journal Component Load" << std::endl;
58 std::cout << TESTS_ICALLOADFREEBUSY << ". iCalendar FreeBusy Component Load" << std::endl;
59 std::cout << TESTS_ICALLOADTIMEZONE << ". iCalendar Timezone Component Load" << std::endl;
60 std::cout << TESTS_CALDAV << ". CalDAV Object" << std::endl;
61 std::cout << TESTS_COMMONFUNCTIONS << ". Common Functions" << std::endl;
62 std::cout << TESTS_QUIT << ". Quit" << std::endl;
63 std::cout << std::endl;
67 int main(int argc, char* argv[]){
69 // Initialise the several libraries that have
72 ::testing::InitGoogleTest(&argc, argv);
73 curl_global_init(CURL_GLOBAL_ALL);
75 printn("Xestia Calendar Unit Testing Application");
76 printn("(c)2016 Xestia Software Development");
77 printn("Note: Unit testing is currently in development");
80 bool ExitEnabled = false;
81 std::string StringOption = "";
84 while(ExitEnabled == false){
90 std::cout << "Select Option: ";
91 std::cin >> StringOption;
95 // Check if input is a number.
98 IntOption = stoi(StringOption);
101 // Return to the top of the while statement if input
102 // really isn't a number.
104 catch(std::invalid_argument e){
105 printn("Error: Selected option is not a number.");
109 // Find which option has been selected from the
114 case TESTS_ICALLOADEVENT:
115 printn("Running iCalendar Event Component tests...");
116 ::testing::GTEST_FLAG(filter) = "iCalendarEvent*";
117 TestResult = RUN_ALL_TESTS();
119 case TESTS_ICALLOADTODO:
120 printn("Running iCalendar Task Component tests...");
121 ::testing::GTEST_FLAG(filter) = "iCalendarTask*";
122 TestResult = RUN_ALL_TESTS();
124 case TESTS_ICALLOADJOURNAL:
125 printn("Running iCalendar Journal Component tests...");
126 ::testing::GTEST_FLAG(filter) = "iCalendarJournal*";
127 TestResult = RUN_ALL_TESTS();
129 case TESTS_ICALLOADFREEBUSY:
130 printn("Running iCalendar Free Busy Component tests...");
131 ::testing::GTEST_FLAG(filter) = "iCalendarFreeBusy*";
132 TestResult = RUN_ALL_TESTS();
134 case TESTS_ICALLOADTIMEZONE:
135 printn("Running iCalendar Free Busy Component tests...");
136 ::testing::GTEST_FLAG(filter) = "iCalendarTimezone*";
137 TestResult = RUN_ALL_TESTS();
140 printn("Running CalDAV tests...");
141 ::testing::GTEST_FLAG(filter) = "CalDAV*";
142 TestResult = RUN_ALL_TESTS();
144 case TESTS_COMMONFUNCTIONS:
145 printn("Running Commmon Functions tests...");
146 ::testing::GTEST_FLAG(filter) = "CommonFunctions*";
147 TestResult = RUN_ALL_TESTS();
153 printn("Invalid menu number given.");