Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added option to populate a CalDAV calendar in the unit testing application
[xestiacalendar/.git] / source / tests / xestiacalendar_test.cpp
index 198a232..e3e2bed 100644 (file)
@@ -22,8 +22,9 @@
 #include <string>
 #include <stdexcept>
 
-#include "xestiacalendar_icaleventload.h"
 #include "xestiacalendar_commonfunctions.h"
+#include "xestiacalendar_populate.h"
+#include "xestiacalendar_icaleventload.h"
 #include "xestiacalendar_icaltaskload.h"
 #include "xestiacalendar_icaljournalload.h"
 #include "xestiacalendar_icalfreebusyload.h"
@@ -38,9 +39,15 @@ enum MenuOpts {
        TESTS_ICALLOADTIMEZONE,
        TESTS_CALDAV,
        TESTS_COMMONFUNCTIONS,
+       TESTS_EXTRA,
        TESTS_QUIT
 };
 
+enum ExtraMenuOpts{
+       EXTRA_POPULATECALDAV = 1,
+       EXTRA_RETURN
+};
+
 void printn(std::string text){
 // printn: Print a line and end with a newline (\n).
 
@@ -59,11 +66,75 @@ void printmenu(){
        std::cout << TESTS_ICALLOADTIMEZONE << ". iCalendar Timezone Component Load" << std::endl;
        std::cout << TESTS_CALDAV << ". CalDAV Object" << std::endl;
        std::cout << TESTS_COMMONFUNCTIONS << ". Common Functions" << std::endl;
+       std::cout << TESTS_EXTRA << ". Extra Functions Menu" << std::endl;
        std::cout << TESTS_QUIT << ". Quit" << std::endl;
        std::cout << std::endl;
 
 }
 
+void printextramenu(){
+
+       std::cout << "Extra Functions Menu" << std::endl << std::endl;
+       std::cout << "Select an option:" << std::endl << std::endl;     
+       std::cout << EXTRA_POPULATECALDAV << ". Populate CalDAV calendar" << std::endl;
+       std::cout << EXTRA_RETURN << ". Return to previous menu" << std::endl;
+       std::cout << std::endl;
+       
+}
+
+void runextramenu(){
+       
+       bool ExitEnabled = false;
+       std::string StringOption = "";
+       int TestResult = 0;
+
+       while(ExitEnabled == false){
+       
+               printextramenu();
+
+               // Get user input.
+
+               std::cout << "Select Option: "; 
+               std::cin >> StringOption;
+               
+               int IntOption = -1;
+               
+               // Check if input is a number.
+               
+               try{
+                       IntOption = stoi(StringOption);
+               }
+               
+               // Return to the top of the while statement if input
+               // really isn't a number.
+               
+               catch(std::invalid_argument e){
+                       printn("Error: Selected option is not a number.");
+                       continue;
+               }
+               
+               // Find which option has been selected from the
+               // input.
+               
+               switch(IntOption){
+               
+                       case EXTRA_POPULATECALDAV:
+                               printn("Populating CalDAV calendar...");
+                               populatecaldav();
+                               break;
+                       case EXTRA_RETURN:
+                               return;
+                               break;
+                       default:
+                               printn("Invalid menu number given."); 
+                               break;
+               
+               }
+       
+       }
+       
+}
+
 int main(int argc, char* argv[]){
 
        // Initialise the several libraries that have
@@ -146,6 +217,9 @@ int main(int argc, char* argv[]){
                                ::testing::GTEST_FLAG(filter) = "CommonFunctions*";
                                TestResult = RUN_ALL_TESTS();
                                break;
+                       case TESTS_EXTRA:
+                               runextramenu();
+                               break;
                        case TESTS_QUIT:
                                return 0;
                                break;
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