*
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
+#pragma once
+
+#include <cassert>
/* The structure we use for the test system */
struct libmemcached_test_container_st
libmemcached_test_container_st() :
parent(NULL),
memc(NULL)
- {
- memset(&construct, 0, sizeof(server_startup_st));
- }
+ { }
};
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* Prototypes for functions we will pass to test framework */
libmemcached_test_container_st *world_create(test_return_t *error);
test_return_t world_test_startup(libmemcached_test_container_st *);
{
global_container.construct.count= SERVERS_TO_CREATE;
global_container.construct.udp= 0;
- server_startup(&global_container.construct);
+ if (not server_startup(&global_container.construct))
+ {
+ *error= TEST_FAILURE;
+ return NULL;
+ }
*error= TEST_SUCCESS;
char buffer[BUFSIZ];
test_compare_got(MEMCACHED_SUCCESS,
- libmemcached_check_configuration(container->construct.server_list, strlen(container->construct.server_list),
+ libmemcached_check_configuration(container->construct.server_list.c_str(), container->construct.server_list.size(),
buffer, sizeof(buffer)),
buffer);
- container->parent= memcached(container->construct.server_list, strlen(container->construct.server_list));
+ assert(not container->parent);
+ container->parent= memcached(container->construct.server_list.c_str(), container->construct.server_list.size());
test_true(container->parent);
return TEST_SUCCESS;
test_return_t world_test_startup(libmemcached_test_container_st *container)
{
+ assert(container);
+ assert(not container->memc);
+ assert(container->parent);
container->memc= memcached_clone(NULL, container->parent);
test_true(container->memc);
test_return_t world_flush(libmemcached_test_container_st *container)
{
+ assert(container->memc);
memcached_flush(container->memc, 0);
memcached_quit(container->memc);
test_return_t world_pre_run(libmemcached_test_container_st *container)
{
+ assert(container->memc);
for (uint32_t loop= 0; loop < memcached_server_list_count(container->memc->servers); loop++)
{
memcached_server_instance_st instance=
test_return_t world_on_error(test_return_t test_state, libmemcached_test_container_st *container)
{
(void)test_state;
+ assert(container->memc);
memcached_free(container->memc);
container->memc= NULL;
{
if (func)
{
+ assert(container);
+ assert(container->memc);
return func(container->memc);
}
else