X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Fmemcat.cc;h=1da52fd2543f06ca2d7f53cb9425b436b15de55b;hb=c0b779f4045f4858701b3741af805414bc066717;hp=2910e4b9be2635d05dbd1b4959aa19206dedd7c4;hpb=743e893ecbbaacd66d2832e9c3ae16404422a173;p=awesomized%2Flibmemcached diff --git a/tests/memcat.cc b/tests/memcat.cc index 2910e4b9..1da52fd2 100644 --- a/tests/memcat.cc +++ b/tests/memcat.cc @@ -39,10 +39,10 @@ Test that we are cycling the servers we are creating during testing. */ -#include +#include "mem_config.h" -#include -#include +#include "libtest/test.hpp" +#include "libmemcached-1.0/memcached.h" using namespace libtest; @@ -50,7 +50,7 @@ using namespace libtest; #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif -static std::string executable("clients/memcat"); +static std::string executable("src/bin/memcat"); static test_return_t help_test(void *) { @@ -64,10 +64,10 @@ static test_return_t help_test(void *) static test_return_t cat_test(void *) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); const char *args[]= { buffer, "foo", 0 }; - memcached_st *memc= memcached(buffer, strlen(buffer)); + memcached_st *memc= memcached(buffer, length); test_true(memc); test_compare(MEMCACHED_SUCCESS, @@ -77,6 +77,7 @@ static test_return_t cat_test(void *) test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_SUCCESS, rc); + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); @@ -90,11 +91,11 @@ static test_return_t cat_test(void *) static test_return_t NOT_FOUND_test(void *) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); + int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); const char *args[]= { buffer, "foo", 0 }; - memcached_st *memc= memcached(buffer, strlen(buffer)); - test_true(memc); + memcached_st *memc= memcached(buffer, length); + ASSERT_TRUE(memc); test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); @@ -102,6 +103,7 @@ static test_return_t NOT_FOUND_test(void *) test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_NOTFOUND, rc); + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));