Commit b4558bb7 authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

tests: fix unit tests

parent b731b84f
......@@ -22,7 +22,6 @@
add_executable(unit-tests-common
logging.cpp
advio.cpp
json_buffer.cpp
bitset.cpp
......@@ -31,7 +30,6 @@ add_executable(unit-tests-common
hist.cpp
kernel.cpp
list.cpp
log.cpp
task.cpp
timing.cpp
tsc.cpp
......
......@@ -118,10 +118,6 @@ Test(list, destructor)
cr_assert_eq(elm.destroyed, 1);
}
static int compare(const void *a, const void *b) {
return (intptr_t) b - (intptr_t) a;
}
Test(list, basics)
{
uintptr_t i;
......@@ -147,13 +143,13 @@ Test(list, basics)
cr_assert_eq(k, (void *) i++);
}
list_sort(&l, compare); /* Reverse list */
for (size_t j = 0, i = 99; j < list_length(&l); j++) {
void *k = list_at(&l, j);
list_sort(&l, (cmp_cb_t) [](const void *a, const void *b) -> int {
return (intptr_t) b - (intptr_t) a;
});
cr_assert_eq(k, (void *) i, "Is %#zx, expected %p", i, k);
i--;
for (size_t j = 0, i = 99; j <= 99; j++, i--) {
uintptr_t k = (uintptr_t) list_at(&l, j);
cr_assert_eq(k, i, "Is %zu, expected %zu", k, i);
}
ret = list_contains(&l, (void *) 55);
......@@ -164,7 +160,8 @@ Test(list, basics)
ret = list_contains(&l, (void *) 55);
cr_assert(!ret);
list_destroy(&l, nullptr, false);
ret = list_destroy(&l, nullptr, false);
cr_assert(!ret);
ret = list_length(&l);
cr_assert_eq(ret, -1, "List not properly destroyed: l.length = %zd", l.length);
......
......@@ -33,10 +33,7 @@ Test(timing, time_now)
struct timespec now1 = time_now();
struct timespec now2 = time_now();
double delta = time_delta(&now1, &now2);
cr_assert_float_eq(delta, 0, 1e-5, "time_now() shows large variance!");
cr_assert_gt(delta, 0, "time_now() was reordered!");
cr_assert(time_cmp(&now1, &now2) <= 0, "time_now() was reordered!");
}
Test(timing, time_diff)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment