@@ -52,8 +52,7 @@ struct TestBuffer {
5252// Write `count` bytes with values 0, 1, 2, … into tb and reset for reading.
5353void makeFilled (TestBuffer& tb, FwSizeType count) {
5454 for (FwSizeType i = 0 ; i < count; ++i) {
55- Fw::SerializeStatus st =
56- tb.buf .serializeFrom (static_cast <U8>(i & 0xFF ));
55+ Fw::SerializeStatus st = tb.buf .serializeFrom (static_cast <U8>(i & 0xFF ));
5756 EXPECT_EQ (st, Fw::FW_SERIALIZE_OK);
5857 }
5958 tb.buf .resetDeser ();
@@ -62,8 +61,7 @@ void makeFilled(TestBuffer& tb, FwSizeType count) {
6261// Write `count` bytes preceded by a FwSizeStoreType length prefix into tb,
6362// then reset for reading.
6463void makeFilledWithLength (TestBuffer& tb, FwSizeType count) {
65- Fw::SerializeStatus st =
66- tb.buf .serializeFrom (static_cast <FwSizeStoreType>(count));
64+ Fw::SerializeStatus st = tb.buf .serializeFrom (static_cast <FwSizeStoreType>(count));
6765 EXPECT_EQ (st, Fw::FW_SERIALIZE_OK);
6866 for (FwSizeType i = 0 ; i < count; ++i) {
6967 st = tb.buf .serializeFrom (static_cast <U8>(i & 0xFF ));
@@ -83,19 +81,18 @@ void makeFilledWithLength(TestBuffer& tb, FwSizeType count) {
8381// ---------------------------------------------------------------------------
8482TEST (DeserializeTo, HappyPathOmitLengthExactFit) {
8583 constexpr FwSizeType N = 8 ;
86- TestBuffer tb; makeFilled (tb, N);
84+ TestBuffer tb;
85+ makeFilled (tb, N);
8786
8887 U8 dest[N] = {};
8988 FwSizeType length = N; // caller specifies how many bytes to pull
9089
91- Fw::SerializeStatus status = tb.buf .deserializeTo (
92- dest, sizeof (dest), length, Fw::Serialization::OMIT_LENGTH);
90+ Fw::SerializeStatus status = tb.buf .deserializeTo (dest, sizeof (dest), length, Fw::Serialization::OMIT_LENGTH);
9391
9492 EXPECT_EQ (status, Fw::FW_SERIALIZE_OK);
9593 EXPECT_EQ (length, N);
9694 for (FwSizeType i = 0 ; i < N; ++i) {
97- EXPECT_EQ (dest[i], static_cast <U8>(i & 0xFF ))
98- << " Byte mismatch at index " << i;
95+ EXPECT_EQ (dest[i], static_cast <U8>(i & 0xFF )) << " Byte mismatch at index " << i;
9996 }
10097}
10198
@@ -104,19 +101,18 @@ TEST(DeserializeTo, HappyPathOmitLengthExactFit) {
104101// ---------------------------------------------------------------------------
105102TEST (DeserializeTo, HappyPathOmitLengthOversizedDest) {
106103 constexpr FwSizeType N = 4 ;
107- TestBuffer tb; makeFilled (tb, N);
104+ TestBuffer tb;
105+ makeFilled (tb, N);
108106
109107 U8 dest[32 ] = {}; // bigger than N
110108 FwSizeType length = N;
111109
112- Fw::SerializeStatus status = tb.buf .deserializeTo (
113- dest, sizeof (dest), length, Fw::Serialization::OMIT_LENGTH);
110+ Fw::SerializeStatus status = tb.buf .deserializeTo (dest, sizeof (dest), length, Fw::Serialization::OMIT_LENGTH);
114111
115112 EXPECT_EQ (status, Fw::FW_SERIALIZE_OK);
116113 EXPECT_EQ (length, N);
117114 for (FwSizeType i = 0 ; i < N; ++i) {
118- EXPECT_EQ (dest[i], static_cast <U8>(i & 0xFF ))
119- << " Byte mismatch at index " << i;
115+ EXPECT_EQ (dest[i], static_cast <U8>(i & 0xFF )) << " Byte mismatch at index " << i;
120116 }
121117}
122118
@@ -125,15 +121,15 @@ TEST(DeserializeTo, HappyPathOmitLengthOversizedDest) {
125121// ---------------------------------------------------------------------------
126122TEST (DeserializeTo, OverflowRejectedOmitLengthDestTooSmall) {
127123 constexpr FwSizeType N = 8 ;
128- TestBuffer tb; makeFilled (tb, N);
124+ TestBuffer tb;
125+ makeFilled (tb, N);
129126
130127 U8 dest[N - 1 ] = {};
131128 FwSizeType length = N; // ask for N bytes into a buffer of only N-1
132129
133130 const FwSizeType cursorBefore = tb.buf .getDeserializeSizeLeft ();
134131
135- Fw::SerializeStatus status = tb.buf .deserializeTo (
136- dest, sizeof (dest), length, Fw::Serialization::OMIT_LENGTH);
132+ Fw::SerializeStatus status = tb.buf .deserializeTo (dest, sizeof (dest), length, Fw::Serialization::OMIT_LENGTH);
137133
138134 EXPECT_EQ (status, Fw::FW_DESERIALIZE_SIZE_MISMATCH);
139135
@@ -148,13 +144,13 @@ TEST(DeserializeTo, OverflowRejectedOmitLengthDestTooSmall) {
148144TEST (DeserializeTo, SourceUnderrunOmitLength) {
149145 constexpr FwSizeType WRITTEN = 4 ;
150146 constexpr FwSizeType REQUESTED = 8 ; // more than what was written
151- TestBuffer tb; makeFilled (tb, WRITTEN);
147+ TestBuffer tb;
148+ makeFilled (tb, WRITTEN);
152149
153150 U8 dest[REQUESTED] = {};
154151 FwSizeType length = REQUESTED;
155152
156- Fw::SerializeStatus status = tb.buf .deserializeTo (
157- dest, sizeof (dest), length, Fw::Serialization::OMIT_LENGTH);
153+ Fw::SerializeStatus status = tb.buf .deserializeTo (dest, sizeof (dest), length, Fw::Serialization::OMIT_LENGTH);
158154
159155 EXPECT_EQ (status, Fw::FW_DESERIALIZE_SIZE_MISMATCH);
160156}
@@ -168,35 +164,34 @@ TEST(DeserializeTo, SourceUnderrunOmitLength) {
168164// ---------------------------------------------------------------------------
169165TEST (DeserializeTo, HappyPathIncludeLength) {
170166 constexpr FwSizeType N = 6 ;
171- TestBuffer tb; makeFilledWithLength (tb, N);
167+ TestBuffer tb;
168+ makeFilledWithLength (tb, N);
172169
173170 U8 dest[N] = {};
174171 FwSizeType length = N; // initial value acts as the max the caller accepts
175172
176- Fw::SerializeStatus status = tb.buf .deserializeTo (
177- dest, sizeof (dest), length, Fw::Serialization::INCLUDE_LENGTH);
173+ Fw::SerializeStatus status = tb.buf .deserializeTo (dest, sizeof (dest), length, Fw::Serialization::INCLUDE_LENGTH);
178174
179175 EXPECT_EQ (status, Fw::FW_SERIALIZE_OK);
180176 EXPECT_EQ (length, N); // length is updated to the actual bytes written
181177 for (FwSizeType i = 0 ; i < N; ++i) {
182- EXPECT_EQ (dest[i], static_cast <U8>(i & 0xFF ))
183- << " Byte mismatch at index " << i;
178+ EXPECT_EQ (dest[i], static_cast <U8>(i & 0xFF )) << " Byte mismatch at index " << i;
184179 }
185180}
186181
187182// ---------------------------------------------------------------------------
188183// Overflow rejected — stored length prefix exceeds destination capacity
189184// ---------------------------------------------------------------------------
190185TEST (DeserializeTo, OverflowRejectedIncludeLengthDestTooSmall) {
191- constexpr FwSizeType STORED = 8 ; // serialized as the length prefix
186+ constexpr FwSizeType STORED = 8 ; // serialized as the length prefix
192187 constexpr FwSizeType DEST_CAP = 4 ; // destination is smaller
193- TestBuffer tb; makeFilledWithLength (tb, STORED);
188+ TestBuffer tb;
189+ makeFilledWithLength (tb, STORED);
194190
195191 U8 dest[DEST_CAP] = {};
196192 FwSizeType length = STORED;
197193
198- Fw::SerializeStatus status = tb.buf .deserializeTo (
199- dest, DEST_CAP, length, Fw::Serialization::INCLUDE_LENGTH);
194+ Fw::SerializeStatus status = tb.buf .deserializeTo (dest, DEST_CAP, length, Fw::Serialization::INCLUDE_LENGTH);
200195
201196 EXPECT_EQ (status, Fw::FW_DESERIALIZE_SIZE_MISMATCH);
202197
@@ -214,19 +209,18 @@ TEST(DeserializeTo, OverflowRejectedIncludeLengthDestTooSmall) {
214209
215210TEST (DeserializeTo, HappyPathExplicitEndianMode) {
216211 constexpr FwSizeType N = 5 ;
217- TestBuffer tb; makeFilledWithLength (tb, N);
212+ TestBuffer tb;
213+ makeFilledWithLength (tb, N);
218214
219215 U8 dest[N] = {};
220216 Fw::Serializable::SizeType length = static_cast <Fw::Serializable::SizeType>(N);
221217
222- Fw::SerializeStatus status =
223- tb.buf .deserializeTo (dest, sizeof (dest), length, Fw::Endianness::BIG);
218+ Fw::SerializeStatus status = tb.buf .deserializeTo (dest, sizeof (dest), length, Fw::Endianness::BIG);
224219
225220 EXPECT_EQ (status, Fw::FW_SERIALIZE_OK);
226221 EXPECT_EQ (length, static_cast <Fw::Serializable::SizeType>(N));
227222 for (FwSizeType i = 0 ; i < N; ++i) {
228- EXPECT_EQ (dest[i], static_cast <U8>(i & 0xFF ))
229- << " Byte mismatch at index " << i;
223+ EXPECT_EQ (dest[i], static_cast <U8>(i & 0xFF )) << " Byte mismatch at index " << i;
230224 }
231225}
232226
@@ -239,12 +233,12 @@ TEST(DeserializeTo, HappyPathExplicitEndianMode) {
239233// ---------------------------------------------------------------------------
240234TEST (DeserializeTo, NullPointerNonZeroCapacityRejected) {
241235 constexpr FwSizeType N = 4 ;
242- TestBuffer tb; makeFilled (tb, N);
236+ TestBuffer tb;
237+ makeFilled (tb, N);
243238
244239 FwSizeType length = N;
245240
246- Fw::SerializeStatus status = tb.buf .deserializeTo (
247- nullptr , N, length, Fw::Serialization::OMIT_LENGTH);
241+ Fw::SerializeStatus status = tb.buf .deserializeTo (nullptr , N, length, Fw::Serialization::OMIT_LENGTH);
248242
249243 EXPECT_EQ (status, Fw::FW_DESERIALIZE_SIZE_MISMATCH);
250244}
@@ -255,15 +249,15 @@ TEST(DeserializeTo, NullPointerNonZeroCapacityRejected) {
255249// with a zero length and would be caught by UBSAN.
256250// ---------------------------------------------------------------------------
257251TEST (DeserializeTo, ZeroLengthIsNoOp) {
258- TestBuffer tb; makeFilled (tb, 4 );
252+ TestBuffer tb;
253+ makeFilled (tb, 4 );
259254
260255 U8 dest[4 ] = {};
261256 FwSizeType length = 0 ;
262257
263258 const FwSizeType cursorBefore = tb.buf .getDeserializeSizeLeft ();
264259
265- Fw::SerializeStatus status = tb.buf .deserializeTo (
266- dest, sizeof (dest), length, Fw::Serialization::OMIT_LENGTH);
260+ Fw::SerializeStatus status = tb.buf .deserializeTo (dest, sizeof (dest), length, Fw::Serialization::OMIT_LENGTH);
267261
268262 EXPECT_EQ (status, Fw::FW_SERIALIZE_OK);
269263 EXPECT_EQ (length, static_cast <FwSizeType>(0 ));
@@ -285,26 +279,25 @@ TEST(DeserializeTo, ZeroLengthIsNoOp) {
285279// ---------------------------------------------------------------------------
286280TEST (DeserializeTo, CursorUnchangedAfterFailedCall) {
287281 constexpr FwSizeType N = 8 ;
288- TestBuffer tb; makeFilled (tb, N);
282+ TestBuffer tb;
283+ makeFilled (tb, N);
289284
290285 // First attempt: destination too small — must fail.
291286 U8 smallDest[N / 2 ] = {};
292287 FwSizeType length = N;
293- Fw::SerializeStatus status = tb. buf . deserializeTo (
294- smallDest, sizeof (smallDest), length, Fw::Serialization::OMIT_LENGTH);
288+ Fw::SerializeStatus status =
289+ tb. buf . deserializeTo ( smallDest, sizeof (smallDest), length, Fw::Serialization::OMIT_LENGTH);
295290 EXPECT_EQ (status, Fw::FW_DESERIALIZE_SIZE_MISMATCH);
296291
297292 // Second attempt: correctly-sized destination — must succeed and return
298293 // the same data that was written originally.
299294 U8 goodDest[N] = {};
300295 length = N;
301- status = tb.buf .deserializeTo (
302- goodDest, sizeof (goodDest), length, Fw::Serialization::OMIT_LENGTH);
296+ status = tb.buf .deserializeTo (goodDest, sizeof (goodDest), length, Fw::Serialization::OMIT_LENGTH);
303297 EXPECT_EQ (status, Fw::FW_SERIALIZE_OK);
304298 EXPECT_EQ (length, N);
305299 for (FwSizeType i = 0 ; i < N; ++i) {
306- EXPECT_EQ (goodDest[i], static_cast <U8>(i & 0xFF ))
307- << " Byte mismatch at index " << i;
300+ EXPECT_EQ (goodDest[i], static_cast <U8>(i & 0xFF )) << " Byte mismatch at index " << i;
308301 }
309302}
310303
@@ -315,27 +308,23 @@ TEST(DeserializeTo, SuccessiveCallsPartitionSource) {
315308 constexpr FwSizeType TOTAL = 8 ;
316309 constexpr FwSizeType FIRST = 3 ;
317310 constexpr FwSizeType SECOND = TOTAL - FIRST;
318- TestBuffer tb; makeFilled (tb, TOTAL);
311+ TestBuffer tb;
312+ makeFilled (tb, TOTAL);
319313
320314 U8 dest1[FIRST] = {};
321315 FwSizeType len1 = FIRST;
322- EXPECT_EQ (tb.buf .deserializeTo (dest1, sizeof (dest1), len1,
323- Fw::Serialization::OMIT_LENGTH),
324- Fw::FW_SERIALIZE_OK);
316+ EXPECT_EQ (tb.buf .deserializeTo (dest1, sizeof (dest1), len1, Fw::Serialization::OMIT_LENGTH), Fw::FW_SERIALIZE_OK);
325317
326318 U8 dest2[SECOND] = {};
327319 FwSizeType len2 = SECOND;
328- EXPECT_EQ (tb.buf .deserializeTo (dest2, sizeof (dest2), len2,
329- Fw::Serialization::OMIT_LENGTH),
330- Fw::FW_SERIALIZE_OK);
320+ EXPECT_EQ (tb.buf .deserializeTo (dest2, sizeof (dest2), len2, Fw::Serialization::OMIT_LENGTH), Fw::FW_SERIALIZE_OK);
331321
332322 // Verify each partition contains the right slice of 0, 1, 2, …
333323 for (FwSizeType i = 0 ; i < FIRST; ++i) {
334324 EXPECT_EQ (dest1[i], static_cast <U8>(i)) << " dest1 mismatch at " << i;
335325 }
336326 for (FwSizeType i = 0 ; i < SECOND; ++i) {
337- EXPECT_EQ (dest2[i], static_cast <U8>((FIRST + i) & 0xFF ))
338- << " dest2 mismatch at " << i;
327+ EXPECT_EQ (dest2[i], static_cast <U8>((FIRST + i) & 0xFF )) << " dest2 mismatch at " << i;
339328 }
340329}
341330
@@ -361,8 +350,7 @@ TEST(PopBytes, HappyPath) {
361350
362351 EXPECT_EQ (status, Fw::FW_SERIALIZE_OK);
363352 for (FwSizeType i = 0 ; i < N; ++i) {
364- EXPECT_EQ (dest[i], static_cast <U8>(10 + i))
365- << " popBytes byte mismatch at " << i;
353+ EXPECT_EQ (dest[i], static_cast <U8>(10 + i)) << " popBytes byte mismatch at " << i;
366354 }
367355}
368356
0 commit comments