update TODO
[awesomized/libmemcached] / test / tests / bin / memerror.cpp
1 #include "test/lib/common.hpp"
2 #include "test/lib/Shell.hpp"
3 #include "test/lib/Server.hpp"
4 #include "test/lib/Retry.hpp"
5 #include "test/lib/ReturnMatcher.hpp"
6
7 using Catch::Matchers::Contains;
8
9 TEST_CASE("bin/memerror") {
10 Shell sh{string{TESTING_ROOT "/../src/bin"}};
11
12 SECTION("--help") {
13 string output;
14 REQUIRE(sh.run("memerror --help", output));
15 REQUIRE_THAT(output, Contains("memerror v1"));
16 REQUIRE_THAT(output, Contains("Usage:"));
17 REQUIRE_THAT(output, Contains("code [code ...]"));
18 REQUIRE_THAT(output, Contains("Options:"));
19 REQUIRE_THAT(output, Contains("-h|--help"));
20 REQUIRE_THAT(output, Contains("-V|--version"));
21 }
22
23 SECTION("valid error codes") {
24 for (underlying_type_t<memcached_return_t> rc = MEMCACHED_SUCCESS; rc < MEMCACHED_MAXIMUM_RETURN; ++rc) {
25 string output;
26 REQUIRE(sh.run("memerror " + to_string(rc), output));
27 CHECK(output == memcached_strerror(nullptr, static_cast<memcached_return_t>(rc)) + string{"\n"});
28 }
29 }
30
31 SECTION("unknown error code") {
32 string output;
33 REQUIRE_FALSE(sh.run("memerror " + to_string(MEMCACHED_MAXIMUM_RETURN), output));
34 REQUIRE_THAT(output, Contains("INVALID memcached_return_t"));
35 }
36 }