Skip to content

Commit

Permalink
Minor unit test cleanups (#23723)
Browse files Browse the repository at this point in the history
* Remove unused member in Network test helper, reorder code a bit

* Fix proper ifdef for log test - value is always defined but may be 0 or 1
  • Loading branch information
andy31415 authored and pull[bot] committed Mar 28, 2023
1 parent 43e345a commit b40a1c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/lib/support/tests/TestBytesToHex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ void TestHexToBytesAndUint(nlTestSuite * inSuite, void * inContext)
NL_TEST_ASSERT(inSuite, test16Out == test16OutExpected);
}

#if CHIP_PROGRESS_LOGGING

ENFORCE_FORMAT(3, 0) void AccumulateLogLineCallback(const char * module, uint8_t category, const char * msg, va_list args)
{
(void) module;
Expand Down Expand Up @@ -427,13 +429,15 @@ void TestLogBufferAsHex(nlTestSuite * inSuite, void * inContext)
}
}

#endif

const nlTest sTests[] = {
NL_TEST_DEF("TestBytesToHexNotNullTerminated", TestBytesToHexNotNullTerminated), //
NL_TEST_DEF("TestBytesToHexNullTerminated", TestBytesToHexNullTerminated), //
NL_TEST_DEF("TestBytesToHexErrors", TestBytesToHexErrors), //
NL_TEST_DEF("TestBytesToHexUint64", TestBytesToHexUint64), //
NL_TEST_DEF("TestHexToBytesAndUint", TestHexToBytesAndUint), //
#ifdef CHIP_PROGRESS_LOGGING
#if CHIP_PROGRESS_LOGGING
NL_TEST_DEF("TestLogBufferAsHex", TestLogBufferAsHex), //
#endif
NL_TEST_SENTINEL() //
Expand Down
13 changes: 5 additions & 8 deletions src/transport/raw/tests/NetworkTestHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,13 @@ class LoopbackTransport : public Transport::Base
{
mDelegate->OnMessageDropped();
}
}
else
{
System::PacketBufferHandle receivedMessage = msgBuf.CloneData();
mPendingMessageQueue.push(PendingMessageItem(address, std::move(receivedMessage)));
mSystemLayer->ScheduleWork(OnMessageReceived, this);

return CHIP_NO_ERROR;
}

return CHIP_NO_ERROR;
System::PacketBufferHandle receivedMessage = msgBuf.CloneData();
mPendingMessageQueue.push(PendingMessageItem(address, std::move(receivedMessage)));
return mSystemLayer->ScheduleWork(OnMessageReceived, this);
}

bool CanSendToPeer(const Transport::PeerAddress & address) override { return true; }
Expand All @@ -158,7 +156,6 @@ class LoopbackTransport : public Transport::Base

System::Layer * mSystemLayer = nullptr;
std::queue<PendingMessageItem> mPendingMessageQueue;
Transport::PeerAddress mTxAddress;
uint32_t mNumMessagesToDrop = 0;
uint32_t mDroppedMessageCount = 0;
uint32_t mSentMessageCount = 0;
Expand Down

0 comments on commit b40a1c0

Please sign in to comment.