diff options
author | David Robillard <d@drobilla.net> | 2022-08-18 16:44:41 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-08-18 16:44:41 -0400 |
commit | b9d58f74ea1d072e7a2d1c862dc7a1e0fe5fccb0 (patch) | |
tree | 9b01f7f6e96af405457cba746ca85dd21d38a3e5 /test | |
parent | 9ac3f4e009fd0d393d2c41449b121498e5b7ad54 (diff) | |
download | zix-b9d58f74ea1d072e7a2d1c862dc7a1e0fe5fccb0.tar.gz zix-b9d58f74ea1d072e7a2d1c862dc7a1e0fe5fccb0.tar.bz2 zix-b9d58f74ea1d072e7a2d1c862dc7a1e0fe5fccb0.zip |
Factor out converting errno codes to ZixStatus
Diffstat (limited to 'test')
-rw-r--r-- | test/test_status.c (renamed from test/test_strerror.c) | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/test/test_strerror.c b/test/test_status.c index 2f4c090..eb11bc1 100644 --- a/test/test_strerror.c +++ b/test/test_status.c @@ -6,11 +6,33 @@ #include "zix/common.h" #include <assert.h> +#include <errno.h> +#include <limits.h> #include <stdio.h> #include <string.h> -int -main(void) +static void +test_errno_status(void) +{ + assert(zix_errno_status(0) == ZIX_STATUS_SUCCESS); + assert(zix_errno_status(INT_MAX) == ZIX_STATUS_ERROR); + +#ifdef EAGAIN + assert(zix_errno_status(EAGAIN) == ZIX_STATUS_NO_MEM); +#endif +#ifdef EEXIST + assert(zix_errno_status(EEXIST) == ZIX_STATUS_EXISTS); +#endif +#ifdef EINVAL + assert(zix_errno_status(EINVAL) == ZIX_STATUS_BAD_ARG); +#endif +#ifdef EPERM + assert(zix_errno_status(EPERM) == ZIX_STATUS_BAD_PERMS); +#endif +} + +static void +test_strerror(void) { const char* msg = zix_strerror(ZIX_STATUS_SUCCESS); assert(!strcmp(msg, "Success")); @@ -27,5 +49,12 @@ main(void) assert(!strcmp(msg, "Unknown error")); printf("Success\n"); +} + +int +main(void) +{ + test_errno_status(); + test_strerror(); return 0; } |