X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Flibmemcached-1.0%2Fplus.cpp;h=1077ae72fd1a80b8ba98d803d400dfbb5d8dbf5e;hb=6b7d2bf0319e0bd48bd6aa4ad8c56a935f98b0d2;hp=5078f1f5583cea9c07ab32f5524eec8c3b5ed13c;hpb=2674b74b067e8578bf323445a88f46bb3fa18ffd;p=awesomized%2Flibmemcached diff --git a/tests/libmemcached-1.0/plus.cpp b/tests/libmemcached-1.0/plus.cpp index 5078f1f5..1077ae72 100644 --- a/tests/libmemcached-1.0/plus.cpp +++ b/tests/libmemcached-1.0/plus.cpp @@ -35,13 +35,13 @@ * */ -#include +#include "mem_config.h" /* C++ interface test */ -#include -#include +#include "libmemcached-1.0/memcached.hpp" +#include "libtest/test.hpp" #include #include @@ -49,7 +49,9 @@ #include #include #include -#include +#if HAVE_UNISTD_H +# include +#endif #include #include @@ -181,6 +183,13 @@ static test_return_t mget_test(memcached_st *original) vector return_value; /* We need to empty the server before we continue the test */ + bool flush_res= memc.flush(); + if (flush_res == false) + { + std::string error_string; + ASSERT_TRUE(memc.error(error_string)); + Error << error_string; + } test_true(memc.flush()); test_true(memc.mget(keys)); @@ -203,6 +212,36 @@ static test_return_t mget_test(memcached_st *original) return TEST_SUCCESS; } +static test_return_t lp_1010899_TEST(void*) +{ + // Check to see everything is setup internally even when no initial hosts are + // given. + Memcache memc; + + test_false(memc.increment(__func__, 0, NULL)); + + return TEST_SUCCESS; +} + +static test_return_t lp_1010899_with_args_TEST(memcached_st *original) +{ + // Check to see everything is setup internally even when a host is specified + // on creation. + const memcached_instance_st* instance= memcached_server_instance_by_position(original, 0); + Memcache memc(memcached_server_name(instance), memcached_server_port(instance)); + + test_false(memc.increment(__func__, 0, NULL)); + test_true(memc.set(__func__, test_literal_param("12"), 0, 0)); + test_true(memc.increment(__func__, 3, NULL)); + + std::vector ret_val; + test_true(memc.get(__func__, ret_val)); + + test_strcmp(&ret_val[0], "15"); + + return TEST_SUCCESS; +} + static test_return_t basic_behavior(memcached_st *original) { Memcache memc(original); @@ -273,9 +312,17 @@ test_st tests[] ={ {0, 0, 0} }; +test_st regression_TESTS[] ={ + { "lp:1010899 Memcache()", false, lp_1010899_TEST }, + { "lp:1010899 Memcache(localhost, port)", false, + reinterpret_cast(lp_1010899_with_args_TEST) }, + {0, 0, 0} +}; + collection_st collection[] ={ {"block", 0, 0, tests}, {"error()", 0, 0, error_tests}, + {"regression", 0, 0, regression_TESTS}, {0, 0, 0, 0} }; @@ -284,21 +331,12 @@ collection_st collection[] ={ #define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT +10 #include "tests/libmemcached_world.h" -void get_world(Framework *world) +void get_world(libtest::Framework* world) { - world->collections= collection; - - world->_create= world_create; - world->_destroy= world_destroy; - - world->item._startup= reinterpret_cast(world_test_startup); - world->item._flush= reinterpret_cast(world_flush); - world->item.set_pre(reinterpret_cast(world_pre_run)); - world->item.set_post(reinterpret_cast(world_post_run)); - world->_on_error= reinterpret_cast(world_on_error); + world->collections(collection); - world->collection_startup= reinterpret_cast(world_container_startup); - world->collection_shutdown= reinterpret_cast(world_container_shutdown); + world->create((test_callback_create_fn*)world_create); + world->destroy((test_callback_destroy_fn*)world_destroy); - world->set_runner(&defualt_libmemcached_runner); + world->set_runner(new LibmemcachedRunner); }