Skip to content

Commit

Permalink
Integrating Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Alami-Amine committed Jun 7, 2024
1 parent 34c62e1 commit eace30b
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 131 deletions.
6 changes: 2 additions & 4 deletions src/app/tests/TestBasicCommandPathRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,20 @@ TEST(TestBasicCommandPathRegistry, TestAddingSameCommandRef)

TEST(TestBasicCommandPathRegistry, TestAddingMaxNumberOfEntries)
{
CHIP_ERROR err = CHIP_NO_ERROR;
BasicCommandPathRegistry<kQuickTestSize> basicCommandPathRegistry;

std::optional<uint16_t> commandRef;
uint16_t commandRefAndEndpointValue = 0;

size_t idx = 0;
for (idx = 0; idx < kQuickTestSize && err == CHIP_NO_ERROR; idx++)
for (idx = 0; idx < kQuickTestSize; idx++)
{
ConcreteCommandPath concretePath(commandRefAndEndpointValue, 0, 0);
commandRef.emplace(commandRefAndEndpointValue);
commandRefAndEndpointValue++;
err = basicCommandPathRegistry.Add(concretePath, commandRef);
ASSERT_EQ(basicCommandPathRegistry.Add(concretePath, commandRef), CHIP_NO_ERROR);
}

EXPECT_EQ(err, CHIP_NO_ERROR);
EXPECT_EQ(basicCommandPathRegistry.Count(), kQuickTestSize);
}

Expand Down
34 changes: 19 additions & 15 deletions src/app/tests/TestDataModelSerialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,20 @@ using namespace chip::app::Clusters;
class TestDataModelSerialization : public ::testing::Test
{
public:
static void SetUpTestSuite() { ASSERT_EQ(chip::Platform::MemoryInit(), CHIP_NO_ERROR); }
static void SetUpTestSuite()
{
ASSERT_EQ(chip::Platform::MemoryInit(), CHIP_NO_ERROR);
mStore = new System::TLVPacketBufferBackingStore;
}
static void TearDownTestSuite()
{
Shutdown();
System::PacketBufferHandle buf = mStore->Release();

// This was added to avoid the error that occurs when buf is destructed just after MemoryShutdown, i.e. when it goes out of
// scope
buf = nullptr;

delete mStore;
chip::Platform::MemoryShutdown();
}

Expand All @@ -53,32 +63,31 @@ class TestDataModelSerialization : public ::testing::Test
void SetupBuf();
void DumpBuf();
void SetupReader();
static void Shutdown();

static System::TLVPacketBufferBackingStore mStore;
static System::TLVPacketBufferBackingStore * mStore;
TLV::TLVWriter mWriter;
TLV::TLVReader mReader;
};

using namespace TLV;

System::TLVPacketBufferBackingStore TestDataModelSerialization::mStore;
System::TLVPacketBufferBackingStore * TestDataModelSerialization::mStore = nullptr;

void TestDataModelSerialization::SetupBuf()
{
System::PacketBufferHandle buf;

buf = System::PacketBufferHandle::New(1024);
mStore.Init(std::move(buf));
mStore->Init(std::move(buf));

mWriter.Init(mStore);
mReader.Init(mStore);
mWriter.Init(*mStore);
mReader.Init(*mStore);
}

void TestDataModelSerialization::DumpBuf()
{
TLV::TLVReader reader;
reader.Init(mStore);
reader.Init(*mStore);

//
// Enable this once the TLV pretty printer has been checked in.
Expand All @@ -91,15 +100,10 @@ void TestDataModelSerialization::DumpBuf()
void TestDataModelSerialization::SetupReader()
{

mReader.Init(mStore);
mReader.Init(*mStore);
EXPECT_EQ(mReader.Next(), CHIP_NO_ERROR);
}

void TestDataModelSerialization::Shutdown()
{
System::PacketBufferHandle buf = mStore.Release();
}

template <typename T>
struct TagValuePair
{
Expand Down
4 changes: 2 additions & 2 deletions src/app/tests/TestExtensionFieldSets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ TEST_F(TestExtensionFieldSets, TestInsertExtensionFieldSet)

memset(double_size_buffer, static_cast<uint8_t>(1), sizeof(double_size_buffer));

EXPECT_EQ(true, EFS->IsEmpty());
EXPECT_TRUE(EFS->IsEmpty());

// Test creators of single ExtensionFieldSet
EXPECT_EQ(EFS1.mID, kOnOffClusterId);
Expand Down Expand Up @@ -309,7 +309,7 @@ TEST_F(TestExtensionFieldSets, TestRemoveExtensionFieldSet)

// Emptying the table
EFS->Clear();
EXPECT_EQ(true, EFS->IsEmpty());
EXPECT_TRUE(EFS->IsEmpty());
}

} // namespace TestEFS
Loading

0 comments on commit eace30b

Please sign in to comment.