diff options
author | Petr Špaček <petr.spacek@nic.cz> | 2017-01-27 10:02:11 +0100 |
---|---|---|
committer | Daniel Salzman <daniel.salzman@nic.cz> | 2017-01-30 16:47:34 +0100 |
commit | 339f7a5fb9f1206a018cfafc5f010ee14a55711d (patch) | |
tree | e7d5919e75349cd008999df2971956bdd65e615a /tests/utils | |
parent | tests-extra: update requirements (diff) | |
download | knot-339f7a5fb9f1206a018cfafc5f010ee14a55711d.tar.xz knot-339f7a5fb9f1206a018cfafc5f010ee14a55711d.zip |
tests: replace ok(ret == KNOT_E???) with is_int(KNOT_E???, ret) to ease debugging
Throwing away unexpected retun codes makes debugging harder.
TAP function is_int can nicely log mismatches which makes debugging easier.
To make our lives easier I replaced all ok(ret == KNOT_E???) checks with
is_int() calls. It was done using following command
+ manual review and reverts in libknot/test_control.c.
$ find -name '*.c' | xargs sed -i 's#ok(ret == \(KNOT_E[0-9A-Z_]\+\),#is_int(\1, ret,#'
Diffstat (limited to 'tests/utils')
-rw-r--r-- | tests/utils/test_lookup.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/utils/test_lookup.c b/tests/utils/test_lookup.c index 70f7646f9..111eb26be 100644 --- a/tests/utils/test_lookup.c +++ b/tests/utils/test_lookup.c @@ -25,7 +25,7 @@ static void check_search_ok(lookup_t *l, const char *in, const char *out) { diag("Search for '%s'", in); int ret = lookup_search(l, in, strlen(in)); - ok(ret == KNOT_EOK, "Check found"); + is_int(KNOT_EOK, ret, "Check found"); ok(strcmp(out, l->found.key) == 0, "Compare key"); ok(strcmp(out, l->found.data) == 0, "Compare data"); ok(l->iter.first_key == NULL, "Compare no first key"); @@ -37,7 +37,7 @@ static void check_search_multi(lookup_t *l, const char *in, const char *out, { diag("Search for '%s'", in); int ret = lookup_search(l, in, strlen(in)); - ok(ret == KNOT_EFEWDATA, "Check found multi"); + is_int(KNOT_EFEWDATA, ret, "Check found multi"); ok(strcmp(out, l->found.key) == 0, "Compare key"); ok(l->found.data == NULL, "Compare no data"); ok(strcmp(first, l->iter.first_key) == 0, "Compare first key"); @@ -48,7 +48,7 @@ static void check_search_none(lookup_t *l, const char *in) { diag("Search for '%s'", in); int ret = lookup_search(l, in, strlen(in)); - ok(ret == KNOT_ENOENT, "Check not found"); + is_int(KNOT_ENOENT, ret, "Check not found"); ok(l->found.key == NULL, "Check no key"); ok(l->found.data == NULL, "Check no data"); } @@ -56,11 +56,11 @@ static void check_search_none(lookup_t *l, const char *in) static void init(lookup_t *l, const char **table) { int ret = lookup_init(l); - ok(ret == KNOT_EOK, "Init"); + is_int(KNOT_EOK, ret, "Init"); while (*table != NULL) { ret = lookup_insert(l, *table, (void *)*table); - ok(ret == KNOT_EOK, "Insert '%s'", *table); + is_int(KNOT_EOK, ret, "Insert '%s'", *table); table++; } } |