From: Date: Tue, 5 Feb 2008 02:25:37 +0000 (-0500) Subject: Added test for get_by_key, set_by_key C++ tests X-Git-Tag: _20~25 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=31a81895955ef622149ee03a72799f2672719948;p=m6w6%2Flibmemcached Added test for get_by_key, set_by_key C++ tests --- diff --git a/ChangeLog b/ChangeLog index e42a42f4..1d48faa4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 0.16 * Work on the UDP protocol + * Added get_by_key, set_by_key tests for C++ API 0.15 Tue Jan 29 14:55:44 PST 2008 * More work on the C++ API. diff --git a/include/memcached.hh b/include/memcached.hh index 82fbd3ce..e482f4bf 100644 --- a/include/memcached.hh +++ b/include/memcached.hh @@ -33,12 +33,12 @@ public: value_length, &flags, &rc); } - char *get_by_key(char *key, char *master_key, size_t *value_length) + char *get_by_key(char *master_key, char *key, size_t *value_length) { uint32_t flags; memcached_return rc; - return memcached_get_by_key(&memc, key, strlen(key), master_key, strlen(master_key), + return memcached_get_by_key(&memc, master_key, strlen(master_key), key, strlen(key), value_length, &flags, &rc); } diff --git a/tests/plus.cpp b/tests/plus.cpp index cb0b0837..10b2440a 100644 --- a/tests/plus.cpp +++ b/tests/plus.cpp @@ -29,9 +29,31 @@ uint8_t basic_test(memcached_st *memc) return 0; } +uint8_t basic_master_key_test(memcached_st *memc) +{ + Memcached foo; + char *value_set= "Data for server A"; + char *master_key_a= "server-a"; + char *master_key_b= "server-b"; + char *key= "xyz"; + char *value; + size_t value_length; + + foo.set_by_key(master_key_a, key, value_set, strlen(value_set)); + value= foo.get_by_key(master_key_a, key, &value_length); + + assert((memcmp(value, value_set, value_length) == 0)); + + value= foo.get_by_key(master_key_b, key, &value_length); + assert((memcmp(value, value_set, value_length) == 0)); + + return 0; +} + test_st tests[] ={ {"basic", 0, basic_test }, + {"basic_master_key", 0, basic_master_key_test }, {0, 0, 0} };