summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlan Antonuk <alan.antonuk@gmail.com>2015-01-06 23:06:28 -0800
committerAlan Antonuk <alan.antonuk@gmail.com>2015-01-06 23:19:05 -0800
commit9b404bfafc8e20cb718ce1802bb1d7dc21881642 (patch)
tree2a5fa72c648fb5d73980fa9fc60caf32931a64e3 /tests
parent6503377031547bc83718e830fe00be7a4eba7637 (diff)
downloadrabbitmq-c-9b404bfafc8e20cb718ce1802bb1d7dc21881642.tar.gz
Add test for amqp_error_string2() for new values.
Add a tests that ensures that we add error message strings as we add new amqp_status_enum values.
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt5
-rw-r--r--tests/test_status_enum.c55
2 files changed, 60 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 3a90464..c8d96d7 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -23,3 +23,8 @@ add_executable(test_hostcheck
test_hostcheck.c
../librabbitmq/amqp_hostcheck.c)
add_test(hostcheck test_hostcheck)
+
+add_executable(test_status_enum
+ test_status_enum.c)
+target_link_libraries(test_status_enum ${RMQ_LIBRARY_TARGET})
+add_test(status_enum test_status_enum)
diff --git a/tests/test_status_enum.c b/tests/test_status_enum.c
new file mode 100644
index 0000000..f74046e
--- /dev/null
+++ b/tests/test_status_enum.c
@@ -0,0 +1,55 @@
+/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */
+/*
+ * Copyright 2015 Alan Antonuk
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "amqp.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void check_errorstrings(amqp_status_enum start, amqp_status_enum end) {
+ int i;
+ for (i = start; i > end; --i) {
+ const char* err = amqp_error_string2(i);
+ if (0 == strcmp(err, "(unknown error)")) {
+ printf("amqp_status_enum value %s%X",
+ i < 0 ? "-" : "",
+ (unsigned)i);
+ abort();
+ }
+ }
+}
+
+int main(void) {
+ check_errorstrings(AMQP_STATUS_OK, _AMQP_STATUS_NEXT_VALUE);
+ check_errorstrings(AMQP_STATUS_TCP_ERROR, _AMQP_STATUS_TCP_NEXT_VALUE);
+ check_errorstrings(AMQP_STATUS_SSL_ERROR, _AMQP_STATUS_SSL_NEXT_VALUE);
+
+ return 0;
+}