1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00
SqMod/vendor/ZMQ/tests/test_last_endpoint.cpp
Sandu Liviu Catalin 9298065cef Update WIP discord and some vendors.
CPR has features disabled and PCRE is fully disabled until updated to new code.
2023-08-05 21:31:33 +03:00

39 lines
888 B
C++

/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
static void do_bind_and_verify (void *s_, const char *endpoint_)
{
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (s_, endpoint_));
char reported[255];
size_t size = 255;
TEST_ASSERT_SUCCESS_ERRNO (
zmq_getsockopt (s_, ZMQ_LAST_ENDPOINT, reported, &size));
TEST_ASSERT_EQUAL_STRING (endpoint_, reported);
}
void test_last_endpoint ()
{
void *sb = test_context_socket (ZMQ_ROUTER);
int val = 0;
TEST_ASSERT_SUCCESS_ERRNO (
zmq_setsockopt (sb, ZMQ_LINGER, &val, sizeof (val)));
do_bind_and_verify (sb, ENDPOINT_1);
do_bind_and_verify (sb, ENDPOINT_2);
test_context_socket_close (sb);
}
int main (void)
{
setup_test_environment ();
UNITY_BEGIN ();
RUN_TEST (test_last_endpoint);
return UNITY_END ();
}