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"
7 using Catch::Matchers::Contains
;
9 TEST_CASE("bin/memerror") {
10 Shell sh
{string
{TESTING_ROOT
"/../src/bin"}};
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"));
23 SECTION("valid error codes") {
24 for (underlying_type_t
<memcached_return_t
> rc
= MEMCACHED_SUCCESS
; rc
< MEMCACHED_MAXIMUM_RETURN
; ++rc
) {
26 REQUIRE(sh
.run("memerror " + to_string(rc
), output
));
27 CHECK(output
== memcached_strerror(nullptr, static_cast<memcached_return_t
>(rc
)) + string
{"\n"});
31 SECTION("unknown error code") {
33 REQUIRE_FALSE(sh
.run("memerror " + to_string(MEMCACHED_MAXIMUM_RETURN
), output
));
34 REQUIRE_THAT(output
, Contains("INVALID memcached_return_t"));