X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Fparser.cc;h=598e2edd9a0c4b3b5e336e81e473c87ca7cb18f6;hb=c5c5f2799a24eac8df5e11f447b48e031299579a;hp=c53c0512538c108afda7a9d947bd68f2ea037c44;hpb=609d07c5a051c301ce6595747c2f64d3819554f5;p=m6w6%2Flibmemcached diff --git a/tests/parser.cc b/tests/parser.cc index c53c0512..598e2edd 100644 --- a/tests/parser.cc +++ b/tests/parser.cc @@ -35,7 +35,10 @@ * */ -#include +#include +#include + +using namespace libtest; #include #include @@ -235,16 +238,24 @@ static test_return_t _test_option(scanner_variable_t *scanner, bool test_true_op for (scanner_variable_t *ptr= scanner; ptr->type != NIL; ptr++) { memcached_st *memc= memcached(ptr->option.c_str, ptr->option.size); - if (test_true_opt) + + // The case that it should have parsed, but it didn't. We will inspect + // for an error with libmemcached_check_configuration() + if (not memc and test_true_opt) { char buffer[2048]; - if (not memc) - { - libmemcached_check_configuration(ptr->option.c_str, ptr->option.size, buffer, sizeof(buffer)); - } + bool success= libmemcached_check_configuration(ptr->option.c_str, ptr->option.size, buffer, sizeof(buffer)); - test_true_got(memc, buffer); + std::string temp(buffer); + temp+= " with option string:"; + temp+= ptr->option.c_str; + test_true_got(success, temp.c_str()); + return TEST_FAILURE; // The line above should fail since memc should be null + } + + if (test_true_opt) + { if (ptr->check_func) { test_return_t test_rc= (*ptr->check_func)(memc, ptr->result); @@ -527,10 +538,8 @@ test_return_t test_hostname_port_weight(memcached_st *) const char *server_string= "--server=localhost:8888/?2 --server=localhost:8889/?3 --server=localhost:8890/?4 --server=localhost:8891/?5 --server=localhost:8892/?3"; char buffer[BUFSIZ]; - memcached_return_t rc; test_compare_got(MEMCACHED_SUCCESS, - rc= libmemcached_check_configuration(server_string, strlen(server_string), buffer, sizeof(buffer)), - memcached_strerror(NULL, rc)); + libmemcached_check_configuration(server_string, strlen(server_string), buffer, sizeof(buffer)), buffer); memcached_st *memc= memcached(server_string, strlen(server_string)); test_true(memc); @@ -613,14 +622,14 @@ test_return_t regression_bug_71231153_connect(memcached_st *) { // Test the connect-timeout, on a bad host we should get MEMCACHED_CONNECTION_FAILURE memcached_st *memc= memcached(memcached_literal_param("--SERVER=10.0.2.252 --CONNECT-TIMEOUT=0")); test_true(memc); - test_compare(0, memc->connect_timeout); + test_zero(memc->connect_timeout); test_compare(MEMCACHED_DEFAULT_TIMEOUT, memc->poll_timeout); memcached_return_t rc; size_t value_len; char *value= memcached_get(memc, memcached_literal_param("test"), &value_len, NULL, &rc); test_false(value); - test_compare(0, value_len); + test_zero(value_len); test_compare_got(MEMCACHED_TIMEOUT, rc, memcached_strerror(NULL, rc)); memcached_free(memc); @@ -638,13 +647,13 @@ test_return_t regression_bug_71231153_poll(memcached_st *) memcached_st *memc= memcached(memcached_literal_param("--SERVER=10.0.2.252 --POLL-TIMEOUT=0")); test_true(memc); test_compare(MEMCACHED_DEFAULT_CONNECT_TIMEOUT, memc->connect_timeout); - test_compare(0, memc->poll_timeout); + test_zero(memc->poll_timeout); memcached_return_t rc; size_t value_len; char *value= memcached_get(memc, memcached_literal_param("test"), &value_len, NULL, &rc); test_false(value); - test_compare(0, value_len); + test_zero(value_len); test_compare_got(MEMCACHED_TIMEOUT, rc, memcached_strerror(NULL, rc)); memcached_free(memc);