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
23
23
using base_type = argparse::ArgumentParser;
24
24
using base_type::ArgumentParser;
25
25
26
+ XEUS_CPP_API
26
27
void parse (const std::string& line);
27
28
};
28
29
}
Original file line number Diff line number Diff line change 11
11
#include " xeus-cpp/xholder.hpp"
12
12
#include " xeus-cpp/xmanager.hpp"
13
13
#include " xeus-cpp/xutils.hpp"
14
+ #include " xeus-cpp/xoptions.hpp"
14
15
15
16
#include " ../src/xparser.hpp"
16
17
@@ -396,3 +397,32 @@ TEST_SUITE("xbuffer")
396
397
REQUIRE (null_stream.good () == true );
397
398
}
398
399
}
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