Commit c50dd580bdd190ca4586b5ad2e2790b366b6d5aa
1 parent
50ef3110
HorribleError for subcommand test
Showing
2 changed files
with
14 additions
and
0 deletions
include/CLI/App.hpp
| ... | ... | @@ -1081,6 +1081,13 @@ struct AppFriend { |
| 1081 | 1081 | return app->_parse_long(std::forward<Args>(args)...); |
| 1082 | 1082 | } |
| 1083 | 1083 | |
| 1084 | + /// Wrap _parse_subcommand, perfectly forward arguments and return | |
| 1085 | + template<typename ...Args> | |
| 1086 | + static auto parse_subcommand(App* app, Args && ...args) | |
| 1087 | + -> typename std::result_of<decltype(&App::_parse_subcommand)(App, Args...)>::type { | |
| 1088 | + return app->_parse_subcommand(std::forward<Args>(args)...); | |
| 1089 | + } | |
| 1090 | + | |
| 1084 | 1091 | }; |
| 1085 | 1092 | } |
| 1086 | 1093 | ... | ... |
tests/AppTest.cpp
| ... | ... | @@ -803,3 +803,10 @@ TEST_F(TApp, CheckLongFail) { |
| 803 | 803 | |
| 804 | 804 | EXPECT_THROW(CLI::detail::AppFriend::parse_long(&app, args), CLI::HorribleError); |
| 805 | 805 | } |
| 806 | + | |
| 807 | +// Test horrible error | |
| 808 | +TEST_F(TApp, CheckSubcomFail) { | |
| 809 | + args = {"subcom"}; | |
| 810 | + | |
| 811 | + EXPECT_THROW(CLI::detail::AppFriend::parse_long(&app, args), CLI::HorribleError); | |
| 812 | +} | ... | ... |