diff options
Diffstat (limited to 'tests/command_map.cc')
| -rw-r--r-- | tests/command_map.cc | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/tests/command_map.cc b/tests/command_map.cc deleted file mode 100644 index 75b6f0d..0000000 --- a/tests/command_map.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This source code is released into the public domain. - */ - -#include <vector> - -#include <catch2/catch_test_macros.hpp> - -import nihil; - -namespace { - -auto cmd_sub1_called = false; -auto cmd_sub1 = nihil::command<int>("cmd sub1", [](int, int, char **) -> int -{ - cmd_sub1_called = true; - return 0; -}); - -} // anonymous namespace - -TEST_CASE("command_map: basic", "[command_map]") -{ - auto args = std::vector<char const *>{ - "cmd", "sub1", nullptr - }; - auto argv = const_cast<char **>(args.data()); - nihil::dispatch_command(0, args.size(), argv); - REQUIRE(cmd_sub1_called == true); -} - -TEST_CASE("command_map: unknown command", "[command_map]") -{ - auto args = std::vector<char const *>{ - "cmd", "nonesuch", nullptr - }; - auto argv = const_cast<char **>(args.data()); - - REQUIRE_THROWS_AS(nihil::dispatch_command(0, args.size(), argv), - nihil::usage_error); -} |
