projects
/
m6w6
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Fix --disable-assert, lp:829810
[m6w6/libmemcached]
/
tests
/
hashkit_functions.cc
diff --git
a/tests/hashkit_functions.cc
b/tests/hashkit_functions.cc
index 42abcb620ff24541e1790ffdc42967f4198dca80..12cd3988ba83cc97fbff8ef40fe8af303bc5bc36 100644
(file)
--- a/
tests/hashkit_functions.cc
+++ b/
tests/hashkit_functions.cc
@@
-35,12
+35,15
@@
*
*/
*
*/
-#include <libtest/common.h>
+#include <config.h>
+#include <libtest/test.hpp>
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+using namespace libtest;
+
+#include <cassert>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <libhashkit/hashkit.h>
#include <libhashkit/hashkit.h>
@@
-189,7
+192,7
@@
static test_return_t crc_run (hashkit_st *hashk)
uint32_t hash_val;
hash_val= libhashkit_crc32(*ptr, strlen(*ptr));
uint32_t hash_val;
hash_val= libhashkit_crc32(*ptr, strlen(*ptr));
-
assert(crc_values[x] ==
hash_val);
+
test_compare(crc_values[x],
hash_val);
}
return TEST_SUCCESS;
}
return TEST_SUCCESS;
@@
-206,7
+209,7
@@
static test_return_t fnv1_64_run (hashkit_st *hashk)
uint32_t hash_val;
hash_val= libhashkit_fnv1_64(*ptr, strlen(*ptr));
uint32_t hash_val;
hash_val= libhashkit_fnv1_64(*ptr, strlen(*ptr));
-
assert(fnv1_64_values[x] ==
hash_val);
+
test_compare(fnv1_64_values[x],
hash_val);
}
return TEST_SUCCESS;
}
return TEST_SUCCESS;
@@
-223,7
+226,7
@@
static test_return_t fnv1a_64_run (hashkit_st *hashk)
uint32_t hash_val;
hash_val= libhashkit_fnv1a_64(*ptr, strlen(*ptr));
uint32_t hash_val;
hash_val= libhashkit_fnv1a_64(*ptr, strlen(*ptr));
-
assert(fnv1a_64_values[x] ==
hash_val);
+
test_compare(fnv1a_64_values[x],
hash_val);
}
return TEST_SUCCESS;
}
return TEST_SUCCESS;
@@
-240,7
+243,7
@@
static test_return_t fnv1_32_run (hashkit_st *hashk)
uint32_t hash_val;
hash_val= libhashkit_fnv1_32(*ptr, strlen(*ptr));
uint32_t hash_val;
hash_val= libhashkit_fnv1_32(*ptr, strlen(*ptr));
-
assert(fnv1_32_values[x] ==
hash_val);
+
test_compare(fnv1_32_values[x],
hash_val);
}
return TEST_SUCCESS;
}
return TEST_SUCCESS;
@@
-257,7
+260,7
@@
static test_return_t fnv1a_32_run (hashkit_st *hashk)
uint32_t hash_val;
hash_val= libhashkit_fnv1a_32(*ptr, strlen(*ptr));
uint32_t hash_val;
hash_val= libhashkit_fnv1a_32(*ptr, strlen(*ptr));
-
assert(fnv1a_32_values[x] ==
hash_val);
+
test_compare(fnv1a_32_values[x],
hash_val);
}
return TEST_SUCCESS;
}
return TEST_SUCCESS;
@@
-278,7
+281,7
@@
static test_return_t hsieh_run (hashkit_st *hashk)
#else
hash_val= 1;
#endif
#else
hash_val= 1;
#endif
-
assert(hsieh_values[x] ==
hash_val);
+
test_compare(hsieh_values[x],
hash_val);
}
return TEST_SUCCESS;
}
return TEST_SUCCESS;
@@
-304,7
+307,7
@@
static test_return_t murmur_run (hashkit_st *hashk)
#else
hash_val= 1;
#endif
#else
hash_val= 1;
#endif
-
assert(murmur_values[x] ==
hash_val);
+
test_compare(murmur_values[x],
hash_val);
}
return TEST_SUCCESS;
}
return TEST_SUCCESS;
@@
-322,7
+325,7
@@
static test_return_t jenkins_run (hashkit_st *hashk)
uint32_t hash_val;
hash_val= libhashkit_jenkins(*ptr, strlen(*ptr));
uint32_t hash_val;
hash_val= libhashkit_jenkins(*ptr, strlen(*ptr));
-
assert(jenkins_values[x] ==
hash_val);
+
test_compare(jenkins_values[x],
hash_val);
}
return TEST_SUCCESS;
}
return TEST_SUCCESS;
@@
-344,8
+347,7
@@
test_st allocation[]= {
static test_return_t hashkit_digest_test(hashkit_st *hashk)
{
static test_return_t hashkit_digest_test(hashkit_st *hashk)
{
- uint32_t value;
- value= hashkit_digest(hashk, "a", sizeof("a"));
+ test_true(hashkit_digest(hashk, "a", sizeof("a")));
return TEST_SUCCESS;
}
return TEST_SUCCESS;
}
@@
-576,36
+578,31
@@
collection_st collection[] ={
{0, 0, 0, 0}
};
{0, 0, 0, 0}
};
-/* Prototypes for functions we will pass to test framework */
-void *world_create(test_return_t *error);
-test_return_t world_destroy(hashkit_st *hashk);
-
-void *world_create(test_return_t *error)
+static void *world_create(libtest::server_startup_st&, test_return_t& error)
{
hashkit_st *hashk_ptr= hashkit_create(&global_hashk);
if (hashk_ptr != &global_hashk)
{
{
hashkit_st *hashk_ptr= hashkit_create(&global_hashk);
if (hashk_ptr != &global_hashk)
{
-
*
error= TEST_FAILURE;
+ error= TEST_FAILURE;
return NULL;
}
if (hashkit_is_allocated(hashk_ptr) == true)
{
return NULL;
}
if (hashkit_is_allocated(hashk_ptr) == true)
{
-
*
error= TEST_FAILURE;
+ error= TEST_FAILURE;
return NULL;
}
return NULL;
}
- *error= TEST_SUCCESS;
-
return hashk_ptr;
}
return hashk_ptr;
}
-
test_return_t world_destroy(hashkit_st *hashk
)
+
static bool world_destroy(void *object
)
{
{
+ hashkit_st *hashk= (hashkit_st *)object;
// Did we get back what we expected?
// Did we get back what we expected?
-
assert
(hashkit_is_allocated(hashk) == false);
+
test_true
(hashkit_is_allocated(hashk) == false);
hashkit_free(&global_hashk);
return TEST_SUCCESS;
hashkit_free(&global_hashk);
return TEST_SUCCESS;
@@
-614,6
+611,6
@@
test_return_t world_destroy(hashkit_st *hashk)
void get_world(Framework *world)
{
world->collections= collection;
void get_world(Framework *world)
{
world->collections= collection;
- world->_create=
(test_callback_create_fn*)
world_create;
- world->_destroy=
(test_callback_fn*)
world_destroy;
+ world->_create= world_create;
+ world->_destroy= world_destroy;
}
}