diff options
| author | Randy Palamar <randy@rnpnr.xyz> | 2025-12-05 21:54:50 -0700 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2025-12-08 09:58:02 -0700 |
| commit | 48fbf21a6d6085d561757afb162d9f7b98792bf9 (patch) | |
| tree | 5749a9ffc34199718b2e11fdea81e184f8c68202 /test/core/map-test.c | |
| parent | b389733ab0fa46f2cecd302cc5826fc7dc322c8e (diff) | |
| download | vis-48fbf21a6d6085d561757afb162d9f7b98792bf9.tar.gz vis-48fbf21a6d6085d561757afb162d9f7b98792bf9.tar.xz | |
map: stop setting errno on error
the return of these functions already give all the necessary
information. this is not c standard library code, we have no need
of such a nonsensical error reporting mechanism
NOTE: since errno needs to be thread local accessing it from
non-libc code ends up being a function call and serves as a
pointless optimization barrier.
Diffstat (limited to 'test/core/map-test.c')
| -rw-r--r-- | test/core/map-test.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/test/core/map-test.c b/test/core/map-test.c index 7a23d57..beb6ba2 100644 --- a/test/core/map-test.c +++ b/test/core/map-test.c @@ -2,7 +2,6 @@ #include <stdbool.h> #include <string.h> #include <stdio.h> -#include <errno.h> #include "tap.h" #include "map.h" @@ -52,16 +51,16 @@ int main(int argc, char *argv[]) { ok(!map_get(map, "404"), "Get non-existing key"); ok(!map_contains(map, "404"), "Contains non-existing key"); - ok(!map_closest(map, "404") && errno == ENOENT, "Closest non-existing key"); + ok(!map_closest(map, "404"), "Closest non-existing key"); - ok(!map_put(map, "a", NULL) && errno == EINVAL && map_empty(map) && !map_get(map, "a"), "Put NULL value"); + ok(!map_put(map, "a", NULL) && map_empty(map) && !map_get(map, "a"), "Put NULL value"); ok(map_put(map, "a", &values[0]) && !map_empty(map) && get(map, "a", &values[0]), "Put 1"); ok(map_first(map, &key) == &values[0] && strcmp(key, "a") == 0, "First on map with 1 value"); key = NULL; ok(map_first(map_prefix(map, "a"), &key) == &values[0] && strcmp(key, "a") == 0, "First on prefix map"); ok(map_contains(map, "a"), "Contains existing key"); ok(map_closest(map, "a") == &values[0], "Closest match existing key"); - ok(!map_put(map, "a", &values[1]) && errno == EEXIST && get(map, "a", &values[0]), "Put duplicate"); + ok(!map_put(map, "a", &values[1]) && get(map, "a", &values[0]), "Put duplicate"); ok(map_put(map, "cafebabe", &values[2]) && get(map, "cafebabe", &values[2]), "Put 2"); ok(map_put(map, "cafe", &values[1]) && get(map, "cafe", &values[1]), "Put 3"); key = NULL; @@ -77,7 +76,7 @@ int main(int argc, char *argv[]) { map_iterate(copy, once, &counter); ok(counter == 1, "Iterate stop condition"); - ok(!map_get(map, "ca") && !map_closest(map, "ca") && errno == 0, "Closest ambigious"); + ok(!map_get(map, "ca") && !map_closest(map, "ca"), "Closest ambigious"); int visited[] = { 0, 0, 0 }; |
