mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-26 23:01:04 +08:00
da31917f4f
Relicense permission collected from all relevant authors as tallied at: https://github.com/rlenferink/libzmq-relicense/blob/master/checklist.md The relicense grants are collected under RELICENSE/ and will be moved to the above repository in a later commit. Fixes https://github.com/zeromq/libzmq/issues/2376
39 lines
1.0 KiB
C++
39 lines
1.0 KiB
C++
/* SPDX-License-Identifier: MPL-2.0 */
|
|
|
|
#include "testutil.hpp"
|
|
#include "testutil_unity.hpp"
|
|
|
|
#include <unity.h>
|
|
|
|
void setUp ()
|
|
{
|
|
}
|
|
|
|
void tearDown ()
|
|
{
|
|
}
|
|
|
|
void test ()
|
|
{
|
|
void *counter = zmq_atomic_counter_new ();
|
|
TEST_ASSERT_EQUAL_INT (0, zmq_atomic_counter_value (counter));
|
|
TEST_ASSERT_EQUAL_INT (0, zmq_atomic_counter_inc (counter));
|
|
TEST_ASSERT_EQUAL_INT (1, zmq_atomic_counter_inc (counter));
|
|
TEST_ASSERT_EQUAL_INT (2, zmq_atomic_counter_inc (counter));
|
|
TEST_ASSERT_EQUAL_INT (3, zmq_atomic_counter_value (counter));
|
|
TEST_ASSERT_EQUAL_INT (1, zmq_atomic_counter_dec (counter));
|
|
TEST_ASSERT_EQUAL_INT (1, zmq_atomic_counter_dec (counter));
|
|
TEST_ASSERT_EQUAL_INT (0, zmq_atomic_counter_dec (counter));
|
|
zmq_atomic_counter_set (counter, 2);
|
|
TEST_ASSERT_EQUAL_INT (1, zmq_atomic_counter_dec (counter));
|
|
TEST_ASSERT_EQUAL_INT (0, zmq_atomic_counter_dec (counter));
|
|
zmq_atomic_counter_destroy (&counter);
|
|
}
|
|
|
|
int main ()
|
|
{
|
|
UNITY_BEGIN ();
|
|
RUN_TEST (test);
|
|
return UNITY_END ();
|
|
}
|