88#include < cstdlib>
99#include < cstring>
1010
11- namespace
12- {
11+ namespace {
1312constexpr std::uint8_t HeaderMsgBestEffort = 0U ;
1413constexpr std::uint8_t HeaderMsgReliable = 1U ;
1514constexpr std::uint8_t HeaderMsgAck = 2U ;
1615
1716struct arrival_capture_t
1817{
19- std::size_t count{0 };
20- std::array<std::uint64_t , 16 > tags{};
21- std::array<unsigned char , 16 > first_payload_byte{};
18+ std::size_t count{ 0 };
19+ std::array<std::uint64_t , 16 > tags{};
20+ std::array<unsigned char , 16 > first_payload_byte{};
2221};
2322
2423struct test_platform_t
2524{
2625 cy_t cy{};
2726 cy_vtable_t vtable{};
2827
29- cy_us_t now{0 };
30- std::uint64_t random_state{1U };
28+ cy_us_t now{ 0 };
29+ std::uint64_t random_state{ 1U };
3130
32- std::size_t p2p_count{0 };
31+ std::size_t p2p_count{ 0 };
3332 std::array<unsigned char , 16 > last_p2p{};
34- std::size_t p2p_extent{0 };
33+ std::size_t p2p_extent{ 0 };
3534
36- std::size_t subscription_error_count{0 };
37- cy_err_t last_subscription_error{CY_OK};
35+ std::size_t subscription_error_count{ 0 };
36+ cy_err_t last_subscription_error{ CY_OK };
3837};
3938
4039static test_platform_t * platform_from (cy_t * const cy) { return reinterpret_cast <test_platform_t *>(cy); }
@@ -94,7 +93,7 @@ extern "C" void platform_topic_destroy(cy_topic_t* const topic) { std::free(topi
9493
9594extern " C" void platform_p2p_extent (cy_t * const cy, const size_t extent) { platform_from (cy)->p2p_extent = extent; }
9695
97- extern " C" cy_err_t platform_p2p (cy_t * const cy,
96+ extern " C" cy_err_t platform_p2p (cy_t * const cy,
9897 const cy_p2p_context_t * const p2p_context,
9998 const cy_us_t deadline,
10099 const std::uint64_t remote_id,
@@ -112,8 +111,8 @@ extern "C" cy_err_t platform_p2p(cy_t* const cy,
112111 if ((frag->size == 0U ) || (frag->data == nullptr )) {
113112 continue ;
114113 }
115- const std::size_t to_copy = (self-> last_p2p . size () - copied < frag-> size ) ? (self-> last_p2p . size () - copied)
116- : frag->size ;
114+ const std::size_t to_copy =
115+ (self-> last_p2p . size () - copied < frag-> size ) ? (self-> last_p2p . size () - copied) : frag->size ;
117116 std::memcpy (&self->last_p2p [copied], frag->data , to_copy);
118117 copied += to_copy;
119118 }
@@ -145,7 +144,7 @@ extern "C" void on_arrival_capture(cy_subscriber_t* const sub, const cy_arrival_
145144
146145static void platform_init (test_platform_t * const self)
147146{
148- *self = test_platform_t {};
147+ *self = test_platform_t {};
149148 self->vtable .now = platform_now;
150149 self->vtable .realloc = platform_realloc;
151150 self->vtable .random = platform_random;
@@ -172,7 +171,7 @@ static void dispatch_message(test_platform_t* const self,
172171{
173172 std::array<unsigned char , 17 > wire{};
174173 cy_test_make_message_header (wire.data (), type, tag, cy_topic_hash (topic));
175- wire[16 ] = payload_byte;
174+ wire[16 ] = payload_byte;
176175 cy_message_t * const msg = cy_test_message_make (wire.data (), wire.size ());
177176 TEST_ASSERT_NOT_NULL (msg);
178177
@@ -192,9 +191,9 @@ static void test_api_malformed_header_drops_message(void)
192191 std::array<unsigned char , 3 > wire = { 0x01U , 0x02U , 0x03U };
193192 cy_message_t * const msg = cy_test_message_make (wire.data (), wire.size ());
194193 TEST_ASSERT_NOT_NULL (msg);
195- cy_message_ts_t mts;
196- mts.timestamp = 10 ;
197- mts.content = msg;
194+ cy_message_ts_t mts;
195+ mts.timestamp = 10 ;
196+ mts.content = msg;
198197 const cy_p2p_context_t p2p = { { 0 } };
199198
200199 cy_on_message (&platform.cy , p2p, 0U , 1234U , mts);
@@ -209,7 +208,7 @@ static void test_api_reliable_duplicate_acked_once_to_application(void)
209208 platform_init (&platform);
210209 cy_test_message_reset_counters ();
211210
212- arrival_capture_t capture{};
211+ arrival_capture_t capture{};
213212 cy_subscriber_t * const sub = cy_subscribe (&platform.cy , wkv_key (" rx/dup" ), 256U );
214213 TEST_ASSERT_NOT_NULL (sub);
215214
@@ -237,7 +236,7 @@ static void test_api_ordered_subscriber_timeout_flush(void)
237236 platform_init (&platform);
238237 cy_test_message_reset_counters ();
239238
240- arrival_capture_t capture{};
239+ arrival_capture_t capture{};
241240 cy_subscriber_t * const sub = cy_subscribe_ordered (&platform.cy , wkv_key (" rx/ord" ), 256U , 10 );
242241 TEST_ASSERT_NOT_NULL (sub);
243242
0 commit comments