From 5dbc64bfe7b86b105b1c552eaa2b3f54453db2bc Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Mon, 27 Feb 2012 11:05:56 -0800 Subject: [PATCH] Remove assert --- libtest/fatal.hpp | 1 + tests/hashkit_functions.cc | 1 - tests/libmemcached-1.0/all_tests.cc | 2 +- tests/libmemcached-1.0/callbacks.cc | 4 ++-- tests/libmemcached-1.0/deprecated.cc | 4 +--- tests/libmemcached-1.0/mem_functions.cc | 5 ++--- tests/libmemcached-1.0/parser.cc | 7 +++---- tests/libmemcached-1.0/pool.cc | 3 +-- tests/libmemcached_world.h | 2 -- tests/mem_udp.cc | 1 - 10 files changed, 11 insertions(+), 19 deletions(-) diff --git a/libtest/fatal.hpp b/libtest/fatal.hpp index b64b3606..23f47bd9 100644 --- a/libtest/fatal.hpp +++ b/libtest/fatal.hpp @@ -56,3 +56,4 @@ private: } // namespace libtest #define fatal_message(__mesg) libtest::fatal(LIBYATL_DEFAULT_PARAM, __mesg) +#define fatal_assert(__assert) if((__assert)) {} else { libtest::fatal(LIBYATL_DEFAULT_PARAM, #__assert); } diff --git a/tests/hashkit_functions.cc b/tests/hashkit_functions.cc index 908ad960..e13a854b 100644 --- a/tests/hashkit_functions.cc +++ b/tests/hashkit_functions.cc @@ -40,7 +40,6 @@ using namespace libtest; -#include #include #include #include diff --git a/tests/libmemcached-1.0/all_tests.cc b/tests/libmemcached-1.0/all_tests.cc index 7fae6d31..b8f93fb5 100644 --- a/tests/libmemcached-1.0/all_tests.cc +++ b/tests/libmemcached-1.0/all_tests.cc @@ -73,7 +73,7 @@ void get_world(Framework *world) if (getenv("LIBMEMCACHED_SERVER_NUMBER")) { int set_count= atoi(getenv("LIBMEMCACHED_SERVER_NUMBER")); - assert(set_count >= 0); + fatal_assert(set_count >= 0); world->servers().set_count(set_count); } else diff --git a/tests/libmemcached-1.0/callbacks.cc b/tests/libmemcached-1.0/callbacks.cc index 206e6092..72b2f974 100644 --- a/tests/libmemcached-1.0/callbacks.cc +++ b/tests/libmemcached-1.0/callbacks.cc @@ -50,8 +50,8 @@ static memcached_return_t delete_trigger(memcached_st *, const char *key, size_t key_length) { - assert(key); - assert(key_length); + fatal_assert(key); + fatal_assert(key_length); return MEMCACHED_SUCCESS; } diff --git a/tests/libmemcached-1.0/deprecated.cc b/tests/libmemcached-1.0/deprecated.cc index e98faf40..d7ebdb05 100644 --- a/tests/libmemcached-1.0/deprecated.cc +++ b/tests/libmemcached-1.0/deprecated.cc @@ -38,8 +38,6 @@ #include #include -#include - #include #include @@ -68,7 +66,7 @@ test_return_t server_list_null_test(memcached_st *ptr) test_return_t regression_bug_728286(memcached_st *) { memcached_server_st *servers= memcached_servers_parse("1.2.3.4:99"); - assert(servers); + fatal_assert(servers); memcached_server_free(servers); return TEST_SUCCESS; diff --git a/tests/libmemcached-1.0/mem_functions.cc b/tests/libmemcached-1.0/mem_functions.cc index d44b5561..a878b2df 100644 --- a/tests/libmemcached-1.0/mem_functions.cc +++ b/tests/libmemcached-1.0/mem_functions.cc @@ -52,7 +52,6 @@ #include -#include #include #include #include @@ -290,7 +289,7 @@ static memcached_return_t server_display_function(const memcached_st *ptr, /* Do Nothing */ size_t bigger= *((size_t *)(context)); (void)ptr; - assert(bigger <= memcached_server_port(server)); + fatal_assert(bigger <= memcached_server_port(server)); *((size_t *)(context))= memcached_server_port(server); return MEMCACHED_SUCCESS; @@ -2884,7 +2883,7 @@ test_return_t user_supplied_bug20(memcached_st *memc) /* sighandler_t function that always asserts false */ static void fail(int) { - assert(0); + fatal_assert(0); } diff --git a/tests/libmemcached-1.0/parser.cc b/tests/libmemcached-1.0/parser.cc index 03da195a..b8b4f47a 100644 --- a/tests/libmemcached-1.0/parser.cc +++ b/tests/libmemcached-1.0/parser.cc @@ -43,7 +43,6 @@ using namespace libtest; #include #include #include -#include #include #include @@ -621,19 +620,19 @@ static memcached_return_t dump_server_information(const memcached_st *, { if (strcmp(memcached_server_name(instance), "localhost")) { - assert(not memcached_server_name(instance)); + fatal_assert(not memcached_server_name(instance)); return MEMCACHED_FAILURE; } if (memcached_server_port(instance) < 8888 or memcached_server_port(instance) > 8892) { - assert(not memcached_server_port(instance)); + fatal_assert(not memcached_server_port(instance)); return MEMCACHED_FAILURE; } if (instance->weight > 5 or instance->weight < 2) { - assert(not instance->weight); + fatal_assert(not instance->weight); return MEMCACHED_FAILURE; } diff --git a/tests/libmemcached-1.0/pool.cc b/tests/libmemcached-1.0/pool.cc index f6214e0d..5b22c94e 100644 --- a/tests/libmemcached-1.0/pool.cc +++ b/tests/libmemcached-1.0/pool.cc @@ -238,10 +238,9 @@ struct test_pool_context_st { static void* connection_release(void *arg) { test_pool_context_st *resource= static_cast(arg); - assert(resource); if (resource == NULL) { - abort(); + fatal_message("resource == NULL"); } // Release all of the memc we are holding diff --git a/tests/libmemcached_world.h b/tests/libmemcached_world.h index cedb8c2f..9f8b657a 100644 --- a/tests/libmemcached_world.h +++ b/tests/libmemcached_world.h @@ -39,8 +39,6 @@ #pragma once -#include - /* The structure we use for the test system */ struct libmemcached_test_container_st { diff --git a/tests/mem_udp.cc b/tests/mem_udp.cc index ff631921..713885fd 100644 --- a/tests/mem_udp.cc +++ b/tests/mem_udp.cc @@ -51,7 +51,6 @@ using namespace libtest; #include #include -#include #include #include #include -- 2.30.2