command_line.cpp
Go to the documentation of this file.
00001 
00011 /*****************************************************************************
00012 ** Includes
00013 *****************************************************************************/
00014 
00015 #include <gtest/gtest.h>
00016 #include "../../include/ecl/command_line.hpp"
00017 
00018 /*****************************************************************************
00019 ** Using
00020 *****************************************************************************/
00021 
00022 using ecl::CmdLine;
00023 using ecl::SwitchArg;
00024 using ecl::ValueArg;
00025 using ecl::ArgException;
00026 
00027 /*****************************************************************************
00028 ** Globals
00029 *****************************************************************************/
00030 
00031 static int myargc;
00032 static char **myargv;
00033 
00034 /*****************************************************************************
00035 ** Tests
00036 *****************************************************************************/
00037 
00038 TEST(CommandLineTests,verify) {
00039 //    try {
00040         // Supply a program description, argument separator (optional) and version number (optional).
00041         CmdLine cmd("This is a test program to test the command line parsing facilities provided by TCLAP.");
00042 //        CmdLine cmd("This is a test program to test the command line parsing facilities provided by TCLAP.", ' ', "0.01");
00043 
00044         // Add a boolean (flag, name, description), sets the default state to false unless it is found on the command line.
00045         SwitchArg debugSwitch("d","debug","Enable debugging.");
00046         // Add a boolean (flag, name, description, default)
00047         // SwitchArg debug("d","debug","Enable debugging.", false);
00048         cmd.add(debugSwitch);
00049 
00050         // Add an int (flag,name,description,compulsory flag?,default value,help description of the type")
00051         ValueArg<int> intArg("i","integer","An integer argument for testing.",false,5,"integer");
00052         cmd.add(intArg);
00053 
00054         /*********************
00055         ** Parse
00056         **********************/
00057         cmd.parse(myargc,myargv); // RoS gtest 'make test' breaks here.
00058         bool debug = debugSwitch.getValue();
00059         int test = intArg.getValue();
00060 
00061         EXPECT_EQ(5,test);
00062         EXPECT_FALSE(debug);
00063 
00064     } catch ( ArgException &e ) {
00065         ADD_FAILURE() << "Failed to parse commadn line arguments";
00066     }
00067 }
00068 
00069 /*****************************************************************************
00070 ** Main
00071 *****************************************************************************/
00072 
00073 int main(int argc, char **argv) {
00074 
00075         myargc = argc;
00076         myargv = argv;
00077 
00078         testing::InitGoogleTest(&argc,argv);
00079         return RUN_ALL_TESTS();
00080 }
00081 
00082 


ecl_command_line
Author(s): Daniel Stonier
autogenerated on Wed Aug 26 2015 11:27:24