@@ -104,18 +104,10 @@ void VerifyStatusReport(const System::PacketBufferHandle & msg, StatusCode expec
104
104
{
105
105
CHIP_ERROR err = CHIP_NO_ERROR;
106
106
107
- if (msg.IsNull ())
108
- {
109
- EXPECT_TRUE (false );
110
- return ;
111
- }
107
+ ASSERT_FALSE (msg.IsNull ())
112
108
113
109
System::PacketBufferHandle msgCopy = msg.CloneData ();
114
- if (msgCopy.IsNull ())
115
- {
116
- EXPECT_TRUE (false );
117
- return ;
118
- }
110
+ ASSERT_FALSE (msgCopy.IsNull ())
119
111
120
112
SecureChannel::StatusReport report;
121
113
err = report.Parse (std::move (msgCopy));
@@ -175,22 +167,14 @@ void SendAndVerifyTransferInit(TransferSession::OutputEvent & outEvent, System::
175
167
}
176
168
if (outEvent.transferInitData .Metadata != nullptr )
177
169
{
178
- EXPECT_EQ (outEvent.transferInitData .MetadataLength , initData.MetadataLength );
179
- if (outEvent.transferInitData .MetadataLength == initData.MetadataLength )
180
- {
181
- // Even if initData.MetadataLength is 0, it is still technically undefined behaviour to call memcmp with a null
182
- bool isNullAndLengthZero = initData.Metadata == nullptr && initData.MetadataLength == 0 ;
183
- if (!isNullAndLengthZero)
184
- {
185
- // Only check that metadata buffers match. The OutputEvent can still be inspected when this function returns to
186
- // parse the metadata and verify that it matches.
187
- EXPECT_EQ (0 ,
188
- memcmp (initData.Metadata , outEvent.transferInitData .Metadata , outEvent.transferInitData .MetadataLength ));
189
- }
190
- }
191
- else
170
+ ASSERT_EQ (outEvent.transferInitData .MetadataLength , initData.MetadataLength );
171
+ // Even if initData.MetadataLength is 0, it is still technically undefined behaviour to call memcmp with a null
172
+ bool isNullAndLengthZero = initData.Metadata == nullptr && initData.MetadataLength == 0 ;
173
+ if (!isNullAndLengthZero)
192
174
{
193
- EXPECT_TRUE (false ); // Metadata length mismatch
175
+ // Only check that metadata buffers match. The OutputEvent can still be inspected when this function returns to
176
+ // parse the metadata and verify that it matches.
177
+ EXPECT_EQ (0 , memcmp (initData.Metadata , outEvent.transferInitData .Metadata , outEvent.transferInitData .MetadataLength ));
194
178
}
195
179
}
196
180
}
@@ -235,23 +219,15 @@ void SendAndVerifyAcceptMsg(TransferSession::OutputEvent & outEvent, TransferSes
235
219
EXPECT_EQ (outEvent.transferAcceptData .Length , acceptData.Length );
236
220
if (outEvent.transferAcceptData .Metadata != nullptr )
237
221
{
238
- EXPECT_EQ (outEvent.transferAcceptData .MetadataLength , acceptData.MetadataLength );
239
- if (outEvent.transferAcceptData .MetadataLength == acceptData.MetadataLength )
222
+ ASSERT_EQ (outEvent.transferAcceptData .MetadataLength , acceptData.MetadataLength );
223
+ // Even if acceptData.MetadataLength is 0, it is still technically undefined behaviour to call memcmp with a null
224
+ bool isNullAndLengthZero = acceptData.Metadata == nullptr && acceptData.MetadataLength == 0 ;
225
+ if (!isNullAndLengthZero)
240
226
{
241
- // Even if acceptData.MetadataLength is 0, it is still technically undefined behaviour to call memcmp with a null
242
- bool isNullAndLengthZero = acceptData.Metadata == nullptr && acceptData.MetadataLength == 0 ;
243
- if (!isNullAndLengthZero)
244
- {
245
- // Only check that metadata buffers match. The OutputEvent can still be inspected when this function returns to
246
- // parse the metadata and verify that it matches.
247
- EXPECT_EQ (
248
- 0 ,
249
- memcmp (acceptData.Metadata , outEvent.transferAcceptData .Metadata , outEvent.transferAcceptData .MetadataLength ));
250
- }
251
- }
252
- else
253
- {
254
- EXPECT_TRUE (false ); // Metadata length mismatch
227
+ // Only check that metadata buffers match. The OutputEvent can still be inspected when this function returns to
228
+ // parse the metadata and verify that it matches.
229
+ EXPECT_EQ (
230
+ 0 , memcmp (acceptData.Metadata , outEvent.transferAcceptData .Metadata , outEvent.transferAcceptData .MetadataLength ));
255
231
}
256
232
}
257
233
@@ -289,11 +265,7 @@ void SendAndVerifyArbitraryBlock(TransferSession & sender, TransferSession & rec
289
265
290
266
EXPECT_GT (maxBlockSize, 0 );
291
267
System::PacketBufferHandle fakeDataBuf = System::PacketBufferHandle::New (maxBlockSize);
292
- if (fakeDataBuf.IsNull ())
293
- {
294
- EXPECT_TRUE (false );
295
- return ;
296
- }
268
+ ASSERT_FALSE (fakeDataBuf.IsNull ());
297
269
298
270
uint8_t * fakeBlockData = fakeDataBuf->Start ();
299
271
fakeBlockData[0 ] = dataCount++;
@@ -356,7 +328,7 @@ struct TestBdxTransferSession : public ::testing::Test
356
328
static void SetUpTestSuite ()
357
329
{
358
330
CHIP_ERROR error = chip::Platform::MemoryInit ();
359
- EXPECT_EQ (error, CHIP_NO_ERROR);
331
+ ASSERT_EQ (error, CHIP_NO_ERROR);
360
332
}
361
333
362
334
static void TearDownTestSuite () { chip::Platform::MemoryShutdown (); }
@@ -434,11 +406,7 @@ TEST_F(TestBdxTransferSession, TestInitiatingReceiverReceiverDrive)
434
406
// Test only one block can be prepared at a time, without receiving a response to the first
435
407
System::PacketBufferHandle fakeBuf = System::PacketBufferHandle::New (testSmallerBlockSize);
436
408
TransferSession::BlockData prematureBlock;
437
- if (fakeBuf.IsNull ())
438
- {
439
- EXPECT_TRUE (false );
440
- return ;
441
- }
409
+ ASSERT_FALSE (fakeBuf.IsNull ());
442
410
prematureBlock.Data = fakeBuf->Start ();
443
411
prematureBlock.Length = testSmallerBlockSize;
444
412
prematureBlock.IsEof = false ;
0 commit comments