File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ namespace xcpp
2323 using base_type = argparse::ArgumentParser;
2424 using base_type::ArgumentParser;
2525
26+ XEUS_CPP_API
2627 void parse (const std::string& line);
2728 };
2829}
Original file line number Diff line number Diff line change 1111#include " xeus-cpp/xholder.hpp"
1212#include " xeus-cpp/xmanager.hpp"
1313#include " xeus-cpp/xutils.hpp"
14+ #include " xeus-cpp/xoptions.hpp"
1415
1516#include " ../src/xparser.hpp"
1617
@@ -396,3 +397,32 @@ TEST_SUITE("xbuffer")
396397 REQUIRE (null_stream.good () == true );
397398 }
398399}
400+
401+ TEST_SUITE (" xotions" )
402+ {
403+ TEST_CASE (" good_status" ) {
404+ xcpp::argparser parser (" test" );
405+ parser.add_argument (" --verbose" ).help (" increase output verbosity" ).default_value (false ).implicit_value (true );
406+ std::string line = " ./main --verbose" ;
407+
408+ parser.parse (line);
409+
410+ REQUIRE (parser[" --verbose" ] == true );
411+ }
412+
413+ TEST_CASE (" bad_status" ) {
414+ xcpp::argparser parser (" test" );
415+ parser.add_argument (" --verbose" );
416+ std::string line = " ./main --verbose" ;
417+
418+ parser.parse (line);
419+
420+ bool exceptionThrown = false ;
421+ try {
422+ bool isVerbose = (parser[" --verbose" ] == false );
423+ } catch (const std::exception& e) {
424+ exceptionThrown = true ;
425+ }
426+ REQUIRE (exceptionThrown);
427+ }
428+ }
You can’t perform that action at this time.
0 commit comments