diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-06-21 17:18:57 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-06-21 17:18:57 +0100 |
| commit | d27d1302d1fa1b96bf8f53f17fce947f19d21330 (patch) | |
| tree | f56ef29d7816c3b574b3359c746355a44e3b0819 /tests/command_map.cc | |
| parent | 75c6b5fee029ec95e7e45e18525e3e78b9616f48 (diff) | |
| download | nihil-d27d1302d1fa1b96bf8f53f17fce947f19d21330.tar.gz nihil-d27d1302d1fa1b96bf8f53f17fce947f19d21330.tar.bz2 | |
add nihil.config (incomplete)
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); -} |
