diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile.am | 6 | ||||
-rw-r--r-- | librabbitmq/amqp.h | 5 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 5 | ||||
-rw-r--r-- | tests/test_status_enum.c | 55 |
5 files changed, 70 insertions, 2 deletions
@@ -52,6 +52,7 @@ tests/*.log tests/*.trs tests/test_hostcheck tests/test_parse_url +tests/test_status_enum tests/test_tables tools/amqp-consume tools/amqp-declare-queue diff --git a/Makefile.am b/Makefile.am index 9df689a..5ca61ad 100644 --- a/Makefile.am +++ b/Makefile.am @@ -78,7 +78,8 @@ endif check_PROGRAMS = \ tests/test_tables \ tests/test_parse_url \ - tests/test_hostcheck + tests/test_hostcheck \ + tests/test_status_enum TESTS = $(check_PROGRAMS) @@ -92,6 +93,9 @@ tests_test_hostcheck_SOURCES = \ tests/test_hostcheck.c \ librabbitmq/amqp_hostcheck.c +tests_test_status_enum_SOURCES = tests/test_status_enum.c +tests_test_status_enum_LDADD = librabbitmq/librabbitmq.la + noinst_LTLIBRARIES = if EXAMPLES diff --git a/librabbitmq/amqp.h b/librabbitmq/amqp.h index f4c1996..13d2f7f 100644 --- a/librabbitmq/amqp.h +++ b/librabbitmq/amqp.h @@ -703,12 +703,14 @@ typedef enum amqp_status_enum_ closed */ AMQP_STATUS_SOCKET_INUSE = -0x0012, /**< Underlying socket is already open */ + _AMQP_STATUS_NEXT_VALUE = -0x0013, /**< Internal value */ AMQP_STATUS_TCP_ERROR = -0x0100, /**< A generic TCP error occurred */ AMQP_STATUS_TCP_SOCKETLIB_INIT_ERROR = -0x0101, /**< An error occurred trying to initialize the socket library*/ + _AMQP_STATUS_TCP_NEXT_VALUE = -0x0102, /**< Internal value */ AMQP_STATUS_SSL_ERROR = -0x0200, /**< A generic SSL error occurred. */ @@ -718,7 +720,8 @@ typedef enum amqp_status_enum_ failed */ AMQP_STATUS_SSL_PEER_VERIFY_FAILED = -0x0202, /**< SSL validation of peer certificate failed. */ - AMQP_STATUS_SSL_CONNECTION_FAILED = -0x0203 /**< SSL handshake failed. */ + AMQP_STATUS_SSL_CONNECTION_FAILED = -0x0203, /**< SSL handshake failed. */ + _AMQP_STATUS_SSL_NEXT_VALUE = -0x0204 /**< Internal value */ } amqp_status_enum; /** 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; +} |