diff options
Diffstat (limited to 'test/test_strerror.c')
-rw-r--r-- | test/test_strerror.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/test_strerror.c b/test/test_strerror.c new file mode 100644 index 0000000..2f4c090 --- /dev/null +++ b/test/test_strerror.c @@ -0,0 +1,31 @@ +// Copyright 2021 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: ISC + +#undef NDEBUG + +#include "zix/common.h" + +#include <assert.h> +#include <stdio.h> +#include <string.h> + +int +main(void) +{ + const char* msg = zix_strerror(ZIX_STATUS_SUCCESS); + assert(!strcmp(msg, "Success")); + + for (int i = ZIX_STATUS_ERROR; i <= ZIX_STATUS_REACHED_END; ++i) { + msg = zix_strerror((ZixStatus)i); + assert(strcmp(msg, "Success")); + } + + msg = zix_strerror((ZixStatus)-1); + assert(!strcmp(msg, "Unknown error")); + + msg = zix_strerror((ZixStatus)1000000); + assert(!strcmp(msg, "Unknown error")); + + printf("Success\n"); + return 0; +} |