summaryrefslogtreecommitdiffstats
path: root/test/strerror_test.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-09-10 21:31:51 -0400
committerDavid Robillard <d@drobilla.net>2021-09-10 21:41:29 -0400
commitf4e7e7116b0fcd104fa3859c92ec998468030ace (patch)
tree58f39792ab8d710f41500b3cd3d6196dec6518e0 /test/strerror_test.c
parentd35db8f148c4b735211e22b25d7140314474f19e (diff)
downloadzix-f4e7e7116b0fcd104fa3859c92ec998468030ace.tar.gz
zix-f4e7e7116b0fcd104fa3859c92ec998468030ace.tar.bz2
zix-f4e7e7116b0fcd104fa3859c92ec998468030ace.zip
Add test for zix_strerror()
Diffstat (limited to 'test/strerror_test.c')
-rw-r--r--test/strerror_test.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/strerror_test.c b/test/strerror_test.c
new file mode 100644
index 0000000..1173c3a
--- /dev/null
+++ b/test/strerror_test.c
@@ -0,0 +1,47 @@
+/*
+ Copyright 2021 David Robillard <d@drobilla.net>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+#undef NDEBUG
+
+#include "zix/common.h"
+
+#include <assert.h>
+#include <string.h>
+
+static void
+test_strerror(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"));
+}
+
+int
+main(void)
+{
+ test_strerror();
+ return 0;
+}