mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
tests: fix unit tests
This commit is contained in:
parent
fc95c7c70a
commit
b8df22ebe7
3 changed files with 9 additions and 17 deletions
|
@ -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 */
|
||||
list_sort(&l, (cmp_cb_t) [](const void *a, const void *b) -> int {
|
||||
return (intptr_t) b - (intptr_t) a;
|
||||
});
|
||||
|
||||
for (size_t j = 0, i = 99; j < list_length(&l); j++) {
|
||||
void *k = list_at(&l, j);
|
||||
|
||||
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)
|
||||
|
|
Loading…
Add table
Reference in a new issue