exit(EXIT_FAILURE);
}
+ auto exit_code = EXIT_SUCCESS;
for (auto arg = argp; *arg; ++arg) {
auto code = std::stoul(*arg);
auto rc = static_cast<memcached_return_t>(code);
std::cout << "code: " << code << "\n";
std::cout << "name: ";
}
- std::cout << memcached_strerror(nullptr, rc) << std::endl;
+ if (rc >= MEMCACHED_MAXIMUM_RETURN) {
+ exit_code = EXIT_FAILURE;
+ std::cerr << memcached_strerror(nullptr, rc) << std::endl;
+ } else {
+ std::cout << memcached_strerror(nullptr, rc) << std::endl;
+ }
}
- exit(EXIT_SUCCESS);
+ exit(exit_code);
}
SECTION("no servers provided") {
string output;
REQUIRE_FALSE(sh.run("memdump", output));
- REQUIRE(output == "No Servers provided\n");
+ REQUIRE(output == "No servers provided.\n");
}
SECTION("--help") {
string output;
REQUIRE(sh.run("memdump --help", output));
- REQUIRE_THAT(output, Contains("memdump"));
- REQUIRE_THAT(output, Contains("v1"));
- REQUIRE_THAT(output, Contains("help"));
- REQUIRE_THAT(output, Contains("version"));
- REQUIRE_THAT(output, Contains("option"));
- REQUIRE_THAT(output, Contains("--"));
- REQUIRE_THAT(output, Contains("="));
+ REQUIRE_THAT(output, Contains("memdump v1"));
+ REQUIRE_THAT(output, Contains("Usage:"));
+ REQUIRE_THAT(output, Contains("Options:"));
+ REQUIRE_THAT(output, Contains("-h|--help"));
+ REQUIRE_THAT(output, Contains("-V|--version"));
+ REQUIRE_THAT(output, Contains("Environment:"));
+ REQUIRE_THAT(output, Contains("MEMCACHED_SERVERS"));
}
SECTION("with server") {
SECTION("--help") {
string output;
REQUIRE(sh.run("memerror --help", output));
- REQUIRE_THAT(output, Contains("memerror"));
- REQUIRE_THAT(output, Contains("v1"));
- REQUIRE_THAT(output, Contains("help"));
- REQUIRE_THAT(output, Contains("version"));
- REQUIRE_THAT(output, Contains("option"));
- REQUIRE_THAT(output, Contains("--"));
- REQUIRE_THAT(output, Contains("="));
+ REQUIRE_THAT(output, Contains("memerror v1"));
+ REQUIRE_THAT(output, Contains("Usage:"));
+ REQUIRE_THAT(output, Contains("code [code ...]"));
+ REQUIRE_THAT(output, Contains("Options:"));
+ REQUIRE_THAT(output, Contains("-h|--help"));
+ REQUIRE_THAT(output, Contains("-V|--version"));
+ REQUIRE_THAT(output, Contains("Environment:"));
+ REQUIRE_THAT(output, Contains("MEMCACHED_SERVERS"));
}
SECTION("valid error codes") {
SECTION("no servers provided") {
string output;
REQUIRE_FALSE(sh.run("memexist", output));
- REQUIRE(output == "No Servers provided\n");
+ REQUIRE(output == "No servers provided.\n");
}
SECTION("--help") {
string output;
REQUIRE(sh.run("memexist --help", output));
- REQUIRE_THAT(output, Contains("memexist"));
- REQUIRE_THAT(output, Contains("v1"));
- REQUIRE_THAT(output, Contains("help"));
- REQUIRE_THAT(output, Contains("version"));
- REQUIRE_THAT(output, Contains("option"));
- REQUIRE_THAT(output, Contains("--"));
- REQUIRE_THAT(output, Contains("="));
+ REQUIRE_THAT(output, Contains("memexist v1"));
+ REQUIRE_THAT(output, Contains("Usage:"));
+ REQUIRE_THAT(output, Contains("key [key ...]"));
+ REQUIRE_THAT(output, Contains("Options:"));
+ REQUIRE_THAT(output, Contains("-h|--help"));
+ REQUIRE_THAT(output, Contains("-V|--version"));
+ REQUIRE_THAT(output, Contains("Environment:"));
+ REQUIRE_THAT(output, Contains("MEMCACHED_SERVERS"));
}
SECTION("with server") {