aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Evans <je@fb.com>2016-03-15 09:35:14 -0700
committerJason Evans <je@fb.com>2016-03-15 09:40:02 -0700
commit22af74e10615ce6b6898ae38a378af27757f9e16 (patch)
tree5f42710d766f9417ce1c7cb6d6d897b59c01029d /test
parent434ea64b267e5e9e16a66ab1cccf9fab34302ff5 (diff)
downloadjemalloc-22af74e10615ce6b6898ae38a378af27757f9e16.tar.gz
Refactor out signed/unsigned comparisons.
Diffstat (limited to 'test')
-rw-r--r--test/src/timer.c5
-rw-r--r--test/unit/bitmap.c4
-rw-r--r--test/unit/util.c8
3 files changed, 8 insertions, 9 deletions
diff --git a/test/src/timer.c b/test/src/timer.c
index e91b3cf..3c7e63a 100644
--- a/test/src/timer.c
+++ b/test/src/timer.c
@@ -32,9 +32,8 @@ timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen)
uint64_t t0 = timer_usec(a);
uint64_t t1 = timer_usec(b);
uint64_t mult;
- unsigned i = 0;
- unsigned j;
- int n;
+ size_t i = 0;
+ size_t j, n;
/* Whole. */
n = malloc_snprintf(&buf[i], buflen-i, "%"FMTu64, t0 / t1);
diff --git a/test/unit/bitmap.c b/test/unit/bitmap.c
index 1ab0bb8..a2dd546 100644
--- a/test/unit/bitmap.c
+++ b/test/unit/bitmap.c
@@ -101,7 +101,7 @@ TEST_BEGIN(test_bitmap_sfu)
bitmap_info_t binfo;
bitmap_info_init(&binfo, i);
{
- ssize_t j;
+ size_t j;
bitmap_t *bitmap = (bitmap_t *)malloc(
bitmap_size(&binfo));
bitmap_init(bitmap, &binfo);
@@ -119,7 +119,7 @@ TEST_BEGIN(test_bitmap_sfu)
* Iteratively unset bits starting at the end, and
* verify that bitmap_sfu() reaches the unset bits.
*/
- for (j = i - 1; j >= 0; j--) {
+ for (j = i - 1; j < i; j--) { /* (i..0] */
bitmap_unset(bitmap, &binfo, j);
assert_zd_eq(bitmap_sfu(bitmap, &binfo), j,
"First unset bit should the bit previously "
diff --git a/test/unit/util.c b/test/unit/util.c
index 2f65aad..d24c1c7 100644
--- a/test/unit/util.c
+++ b/test/unit/util.c
@@ -160,14 +160,14 @@ TEST_BEGIN(test_malloc_snprintf_truncated)
{
#define BUFLEN 15
char buf[BUFLEN];
- int result;
+ size_t result;
size_t len;
#define TEST(expected_str_untruncated, ...) do { \
result = malloc_snprintf(buf, len, __VA_ARGS__); \
assert_d_eq(strncmp(buf, expected_str_untruncated, len-1), 0, \
"Unexpected string inequality (\"%s\" vs \"%s\")", \
buf, expected_str_untruncated); \
- assert_d_eq(result, strlen(expected_str_untruncated), \
+ assert_zu_eq(result, strlen(expected_str_untruncated), \
"Unexpected result"); \
} while (0)
@@ -193,11 +193,11 @@ TEST_BEGIN(test_malloc_snprintf)
{
#define BUFLEN 128
char buf[BUFLEN];
- int result;
+ size_t result;
#define TEST(expected_str, ...) do { \
result = malloc_snprintf(buf, sizeof(buf), __VA_ARGS__); \
assert_str_eq(buf, expected_str, "Unexpected output"); \
- assert_d_eq(result, strlen(expected_str), "Unexpected result"); \
+ assert_zu_eq(result, strlen(expected_str), "Unexpected result");\
} while (0)
TEST("hello", "hello");