From: Brian Aker Date: Sat, 10 Nov 2012 12:52:43 +0000 (-0500) Subject: Add test for 1048945. The error was in the user's code. This code was corrected and... X-Git-Tag: 1.0.14~4 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=d4c8a38faeda1342d57c2ba74e073d6a2899e558;p=m6w6%2Flibmemcached Add test for 1048945. The error was in the user's code. This code was corrected and included for completeness. --- diff --git a/libmemcached/server_list.cc b/libmemcached/server_list.cc index 537e9edd..5ead6fe9 100644 --- a/libmemcached/server_list.cc +++ b/libmemcached/server_list.cc @@ -45,11 +45,11 @@ memcached_server_list_append_with_weight(memcached_server_list_st ptr, uint32_t weight, memcached_return_t *error) { - uint32_t count; - memcached_return_t unused; if (error == NULL) + { error= &unused; + } if (hostname == NULL) { @@ -60,14 +60,14 @@ memcached_server_list_append_with_weight(memcached_server_list_st ptr, { port = 0; } - else if (not port) + else if (port == 0) { port= MEMCACHED_DEFAULT_PORT; } /* Increment count for hosts */ - count= 1; + uint32_t count= 1; if (ptr != NULL) { count+= memcached_server_list_count(ptr); diff --git a/tests/libmemcached-1.0/all_tests.h b/tests/libmemcached-1.0/all_tests.h index 25fda094..7bdfe394 100644 --- a/tests/libmemcached-1.0/all_tests.h +++ b/tests/libmemcached-1.0/all_tests.h @@ -278,6 +278,7 @@ test_st regression_tests[]= { {"lp:994772", true, (test_callback_fn*)regression_994772_TEST }, {"lp:1009493", true, (test_callback_fn*)regression_1009493_TEST }, {"lp:1021819", true, (test_callback_fn*)regression_1021819_TEST }, + {"lp:1048945", true, (test_callback_fn*)regression_1048945_TEST }, {0, false, (test_callback_fn*)0} }; diff --git a/tests/libmemcached-1.0/mem_functions.cc b/tests/libmemcached-1.0/mem_functions.cc index 3884ac52..38c0db77 100644 --- a/tests/libmemcached-1.0/mem_functions.cc +++ b/tests/libmemcached-1.0/mem_functions.cc @@ -1845,6 +1845,34 @@ test_return_t add_host_test(memcached_st *memc) return TEST_SUCCESS; } +test_return_t regression_1048945_TEST(memcached_st*) +{ + memcached_return status; + + memcached_server_st* list= memcached_server_list_append_with_weight(NULL, "a", 11211, 0, &status); + test_compare(status, MEMCACHED_SUCCESS); + + list= memcached_server_list_append_with_weight(list, "b", 11211, 0, &status); + test_compare(status, MEMCACHED_SUCCESS); + + list= memcached_server_list_append_with_weight(list, "c", 11211, 0, &status); + test_compare(status, MEMCACHED_SUCCESS); + + memcached_st* memc= memcached_create(NULL); + + status= memcached_server_push(memc, list); + memcached_server_list_free(list); + test_compare(status, MEMCACHED_SUCCESS); + + memcached_server_instance_st server= memcached_server_by_key(memc, test_literal_param(__func__), &status); + test_true(server); + test_compare(status, MEMCACHED_SUCCESS); + + memcached_free(memc); + + return TEST_SUCCESS; +} + test_return_t memcached_fetch_result_NOT_FOUND(memcached_st *memc) { memcached_return_t rc; diff --git a/tests/libmemcached-1.0/mem_functions.h b/tests/libmemcached-1.0/mem_functions.h index 5d433aa5..eb9afa29 100644 --- a/tests/libmemcached-1.0/mem_functions.h +++ b/tests/libmemcached-1.0/mem_functions.h @@ -179,3 +179,4 @@ test_return_t kill_HUP_TEST(memcached_st *memc); test_return_t regression_996813_TEST(memcached_st*); test_return_t regression_994772_TEST(memcached_st*); test_return_t regression_1009493_TEST(memcached_st*); +test_return_t regression_1048945_TEST(memcached_st*);