2023-06-05 00:16:05 +01:00
|
|
|
/* SPDX-License-Identifier: MPL-2.0 */
|
2014-12-23 01:14:38 +01:00
|
|
|
|
|
|
|
#include "testutil.hpp"
|
2018-12-07 07:51:30 -05:00
|
|
|
#include "testutil_unity.hpp"
|
2014-12-23 01:14:38 +01:00
|
|
|
|
2018-12-07 07:51:30 -05:00
|
|
|
#include <unity.h>
|
|
|
|
|
|
|
|
void setUp ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void tearDown ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void test ()
|
2014-12-23 01:14:38 +01:00
|
|
|
{
|
|
|
|
void *counter = zmq_atomic_counter_new ();
|
2018-12-07 07:51:30 -05:00
|
|
|
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));
|
2014-12-23 01:14:38 +01:00
|
|
|
zmq_atomic_counter_set (counter, 2);
|
2018-12-07 07:51:30 -05:00
|
|
|
TEST_ASSERT_EQUAL_INT (1, zmq_atomic_counter_dec (counter));
|
|
|
|
TEST_ASSERT_EQUAL_INT (0, zmq_atomic_counter_dec (counter));
|
2014-12-23 01:14:38 +01:00
|
|
|
zmq_atomic_counter_destroy (&counter);
|
2018-12-07 07:51:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int main ()
|
|
|
|
{
|
|
|
|
UNITY_BEGIN ();
|
|
|
|
RUN_TEST (test);
|
|
|
|
return UNITY_END ();
|
2014-12-23 01:14:38 +01:00
|
|
|
}
|