pigweed unit_test migration: App 3rd batch (#33757)
* pigweed unit_test migration: App 3rd batch
* Integrating Comments
* moving buffer in TestDataModelSerialization to Teardown
diff --git a/src/app/tests/BUILD.gn b/src/app/tests/BUILD.gn
index e8413b9..41f083e 100644
--- a/src/app/tests/BUILD.gn
+++ b/src/app/tests/BUILD.gn
@@ -143,11 +143,18 @@
test_sources = [
"TestAttributeAccessInterfaceCache.cpp",
"TestAttributePathExpandIterator.cpp",
+ "TestAttributePathParams.cpp",
"TestAttributePersistenceProvider.cpp",
"TestAttributeValueDecoder.cpp",
"TestAttributeValueEncoder.cpp",
+ "TestBasicCommandPathRegistry.cpp",
"TestBindingTable.cpp",
"TestBuilderParser.cpp",
+ "TestCommandPathParams.cpp",
+ "TestConcreteAttributePath.cpp",
+ "TestDataModelSerialization.cpp",
+ "TestDefaultOTARequestorStorage.cpp",
+ "TestEventPathParams.cpp",
"TestMessageDef.cpp",
"TestNullable.cpp",
"TestNumericAttributeTraits.cpp",
@@ -193,6 +200,17 @@
"${chip_root}/src/lib/support:test_utils",
"${chip_root}/src/lib/support:testing",
]
+
+ if (chip_device_platform != "android") {
+ test_sources += [
+ "TestExtensionFieldSets.cpp",
+ "TestSceneTable.cpp",
+ ]
+ public_deps += [
+ ":power-cluster-test-srcs",
+ ":scenes-table-test-srcs",
+ ]
+ }
}
chip_test_suite_using_nltest("tests_nltest") {
@@ -201,16 +219,9 @@
test_sources = [
"TestAclAttribute.cpp",
"TestAclEvent.cpp",
- "TestBasicCommandPathRegistry.cpp",
- "TestClusterInfo.cpp",
"TestCommandInteraction.cpp",
- "TestCommandPathParams.cpp",
- "TestConcreteAttributePath.cpp",
- "TestDataModelSerialization.cpp",
- "TestDefaultOTARequestorStorage.cpp",
"TestEventLoggingNoUTCTime.cpp",
"TestEventOverflow.cpp",
- "TestEventPathParams.cpp",
"TestFabricScopedEventLogging.cpp",
"TestInteractionModelEngine.cpp",
"TestReadInteraction.cpp",
@@ -258,17 +269,6 @@
"${nlunit_test_root}:nlunit-test",
]
- if (chip_device_platform != "android") {
- test_sources += [
- "TestExtensionFieldSets.cpp",
- "TestSceneTable.cpp",
- ]
- public_deps += [
- ":power-cluster-test-srcs",
- ":scenes-table-test-srcs",
- ]
- }
-
if (chip_config_network_layer_ble &&
(chip_device_platform == "linux" || chip_device_platform == "darwin")) {
test_sources += [ "TestCommissionManager.cpp" ]
diff --git a/src/app/tests/TestAttributePathParams.cpp b/src/app/tests/TestAttributePathParams.cpp
new file mode 100644
index 0000000..19745e2
--- /dev/null
+++ b/src/app/tests/TestAttributePathParams.cpp
@@ -0,0 +1,156 @@
+/*
+ *
+ * Copyright (c) 2021 Project CHIP Authors
+ * All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <app/AttributePathParams.h>
+#include <app/DataVersionFilter.h>
+
+#include <lib/core/StringBuilderAdapters.h>
+#include <pw_unit_test/framework.h>
+
+namespace chip {
+namespace app {
+namespace TestPath {
+
+TEST(TestAttributePathParams, TestAttributePathIntersect)
+{
+ EndpointId endpointIdArray[2] = { 1, kInvalidEndpointId };
+ ClusterId clusterIdArray[2] = { 2, kInvalidClusterId };
+ AttributeId attributeIdArray[2] = { 3, kInvalidAttributeId };
+
+ for (auto endpointId1 : endpointIdArray)
+ {
+ for (auto clusterId1 : clusterIdArray)
+ {
+ for (auto attributeId1 : attributeIdArray)
+ {
+ for (auto endpointId2 : endpointIdArray)
+ {
+ for (auto clusterId2 : clusterIdArray)
+ {
+ for (auto attributeId2 : attributeIdArray)
+ {
+ AttributePathParams path1;
+ path1.mEndpointId = endpointId1;
+ path1.mClusterId = clusterId1;
+ path1.mAttributeId = attributeId1;
+ AttributePathParams path2;
+ path2.mEndpointId = endpointId2;
+ path2.mClusterId = clusterId2;
+ path2.mAttributeId = attributeId2;
+ EXPECT_TRUE(path1.Intersects(path2));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ {
+ AttributePathParams path1;
+ path1.mEndpointId = 1;
+ AttributePathParams path2;
+ path2.mEndpointId = 2;
+ EXPECT_FALSE(path1.Intersects(path2));
+ }
+
+ {
+ AttributePathParams path1;
+ path1.mClusterId = 1;
+ AttributePathParams path2;
+ path2.mClusterId = 2;
+ EXPECT_FALSE(path1.Intersects(path2));
+ }
+
+ {
+ AttributePathParams path1;
+ path1.mAttributeId = 1;
+ AttributePathParams path2;
+ path2.mAttributeId = 2;
+ EXPECT_FALSE(path1.Intersects(path2));
+ }
+}
+
+TEST(TestAttributePathParams, TestAttributePathIncludedSameFieldId)
+{
+ AttributePathParams path1;
+ AttributePathParams path2;
+ AttributePathParams path3;
+ path1.mAttributeId = 1;
+ path2.mAttributeId = 1;
+ path3.mAttributeId = 1;
+ EXPECT_TRUE(path1.IsAttributePathSupersetOf(path2));
+ path2.mListIndex = 1;
+ EXPECT_TRUE(path1.IsAttributePathSupersetOf(path2));
+ path1.mListIndex = 0;
+ EXPECT_FALSE(path1.IsAttributePathSupersetOf(path3));
+ path3.mListIndex = 0;
+ EXPECT_TRUE(path1.IsAttributePathSupersetOf(path3));
+ path3.mListIndex = 1;
+ EXPECT_FALSE(path1.IsAttributePathSupersetOf(path3));
+}
+
+TEST(TestAttributePathParams, TestAttributePathIncludedDifferentFieldId)
+{
+ {
+ AttributePathParams path1;
+ AttributePathParams path2;
+ path1.mAttributeId = 1;
+ path2.mAttributeId = 2;
+ EXPECT_FALSE(path1.IsAttributePathSupersetOf(path2));
+ }
+ {
+ AttributePathParams path1;
+ AttributePathParams path2;
+ path2.mAttributeId = 2;
+ EXPECT_TRUE(path1.IsAttributePathSupersetOf(path2));
+ }
+ {
+ AttributePathParams path1;
+ AttributePathParams path2;
+ EXPECT_TRUE(path1.IsAttributePathSupersetOf(path2));
+ }
+ {
+ AttributePathParams path1;
+ AttributePathParams path2;
+
+ path1.mAttributeId = 1;
+ EXPECT_FALSE(path1.IsAttributePathSupersetOf(path2));
+ }
+}
+
+TEST(TestAttributePathParams, TestAttributePathIncludedDifferentEndpointId)
+{
+ AttributePathParams path1;
+ AttributePathParams path2;
+ path1.mEndpointId = 1;
+ path2.mEndpointId = 2;
+ EXPECT_FALSE(path1.IsAttributePathSupersetOf(path2));
+}
+
+TEST(TestAttributePathParams, TestAttributePathIncludedDifferentClusterId)
+{
+ AttributePathParams path1;
+ AttributePathParams path2;
+ path1.mClusterId = 1;
+ path2.mClusterId = 2;
+ EXPECT_FALSE(path1.IsAttributePathSupersetOf(path2));
+}
+
+} // namespace TestPath
+} // namespace app
+} // namespace chip
diff --git a/src/app/tests/TestBasicCommandPathRegistry.cpp b/src/app/tests/TestBasicCommandPathRegistry.cpp
index 28d7621..cc003cf 100644
--- a/src/app/tests/TestBasicCommandPathRegistry.cpp
+++ b/src/app/tests/TestBasicCommandPathRegistry.cpp
@@ -17,9 +17,9 @@
*/
#include <app/CommandPathRegistry.h>
-#include <lib/support/UnitTestRegistration.h>
-#include <nlunit-test.h>
+#include <lib/core/StringBuilderAdapters.h>
+#include <pw_unit_test/framework.h>
namespace chip {
namespace app {
@@ -30,7 +30,7 @@
} // namespace
-void TestAddingSameConcretePath(nlTestSuite * apSuite, void * apContext)
+TEST(TestBasicCommandPathRegistry, TestAddingSameConcretePath)
{
CHIP_ERROR err = CHIP_NO_ERROR;
BasicCommandPathRegistry<kQuickTestSize> basicCommandPathRegistry;
@@ -47,11 +47,11 @@
err = basicCommandPathRegistry.Add(concretePath, commandRef);
}
- NL_TEST_ASSERT(apSuite, err == CHIP_ERROR_DUPLICATE_KEY_ID);
- NL_TEST_ASSERT(apSuite, basicCommandPathRegistry.Count() == 1);
+ EXPECT_EQ(err, CHIP_ERROR_DUPLICATE_KEY_ID);
+ EXPECT_EQ(basicCommandPathRegistry.Count(), 1u);
}
-void TestAddingSameCommandRef(nlTestSuite * apSuite, void * apContext)
+TEST(TestBasicCommandPathRegistry, TestAddingSameCommandRef)
{
CHIP_ERROR err = CHIP_NO_ERROR;
BasicCommandPathRegistry<kQuickTestSize> basicCommandPathRegistry;
@@ -69,32 +69,30 @@
err = basicCommandPathRegistry.Add(concretePath, commandRef);
}
- NL_TEST_ASSERT(apSuite, err == CHIP_ERROR_DUPLICATE_KEY_ID);
- NL_TEST_ASSERT(apSuite, basicCommandPathRegistry.Count() == 1);
+ EXPECT_EQ(err, CHIP_ERROR_DUPLICATE_KEY_ID);
+ EXPECT_EQ(basicCommandPathRegistry.Count(), 1u);
}
-void TestAddingMaxNumberOfEntries(nlTestSuite * apSuite, void * apContext)
+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);
}
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
- NL_TEST_ASSERT(apSuite, basicCommandPathRegistry.Count() == kQuickTestSize);
+ EXPECT_EQ(basicCommandPathRegistry.Count(), kQuickTestSize);
}
-void TestAddingTooManyEntries(nlTestSuite * apSuite, void * apContext)
+TEST(TestBasicCommandPathRegistry, TestAddingTooManyEntries)
{
CHIP_ERROR err = CHIP_NO_ERROR;
BasicCommandPathRegistry<kQuickTestSize> basicCommandPathRegistry;
@@ -112,36 +110,10 @@
err = basicCommandPathRegistry.Add(concretePath, commandRef);
}
- NL_TEST_ASSERT(apSuite, err == CHIP_ERROR_NO_MEMORY);
- NL_TEST_ASSERT(apSuite, basicCommandPathRegistry.Count() == kQuickTestSize);
+ EXPECT_EQ(err, CHIP_ERROR_NO_MEMORY);
+ EXPECT_EQ(basicCommandPathRegistry.Count(), kQuickTestSize);
}
} // namespace TestBasicCommandPathRegistry
} // namespace app
} // namespace chip
-
-namespace {
-// clang-format off
-const nlTest sTests[] =
-{
- NL_TEST_DEF("TestAddingSameConcretePath", chip::app::TestBasicCommandPathRegistry::TestAddingSameConcretePath),
- NL_TEST_DEF("TestAddingSameCommandRef", chip::app::TestBasicCommandPathRegistry::TestAddingSameCommandRef),
- NL_TEST_DEF("TestAddingMaxNumberOfEntries", chip::app::TestBasicCommandPathRegistry::TestAddingMaxNumberOfEntries),
- NL_TEST_DEF("TestAddingTooManyEntries", chip::app::TestBasicCommandPathRegistry::TestAddingTooManyEntries),
-
- NL_TEST_SENTINEL()
-};
-// clang-format on
-
-} // namespace
-
-int TestBasicCommandPathRegistry()
-{
- nlTestSuite theSuite = { "CommandPathRegistry", &sTests[0], nullptr, nullptr };
-
- nlTestRunner(&theSuite, nullptr);
-
- return (nlTestRunnerStats(&theSuite));
-}
-
-CHIP_REGISTER_TEST_SUITE(TestBasicCommandPathRegistry)
diff --git a/src/app/tests/TestClusterInfo.cpp b/src/app/tests/TestClusterInfo.cpp
deleted file mode 100644
index bfbefc7..0000000
--- a/src/app/tests/TestClusterInfo.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- *
- * Copyright (c) 2021 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file
- * This file implements unit tests for CommandPathParams
- *
- */
-
-#include <app/AttributePathParams.h>
-#include <app/DataVersionFilter.h>
-#include <app/EventPathParams.h>
-#include <app/util/mock/Constants.h>
-#include <lib/support/UnitTestRegistration.h>
-#include <nlunit-test.h>
-
-using namespace chip::Test;
-
-namespace chip {
-namespace app {
-namespace TestPath {
-void TestAttributePathIntersect(nlTestSuite * apSuite, void * apContext)
-{
- EndpointId endpointIdArray[2] = { 1, kInvalidEndpointId };
- ClusterId clusterIdArray[2] = { 2, kInvalidClusterId };
- AttributeId attributeIdArray[2] = { 3, kInvalidAttributeId };
-
- for (auto endpointId1 : endpointIdArray)
- {
- for (auto clusterId1 : clusterIdArray)
- {
- for (auto attributeId1 : attributeIdArray)
- {
- for (auto endpointId2 : endpointIdArray)
- {
- for (auto clusterId2 : clusterIdArray)
- {
- for (auto attributeId2 : attributeIdArray)
- {
- AttributePathParams path1;
- path1.mEndpointId = endpointId1;
- path1.mClusterId = clusterId1;
- path1.mAttributeId = attributeId1;
- AttributePathParams path2;
- path2.mEndpointId = endpointId2;
- path2.mClusterId = clusterId2;
- path2.mAttributeId = attributeId2;
- NL_TEST_ASSERT(apSuite, path1.Intersects(path2));
- }
- }
- }
- }
- }
- }
-
- {
- AttributePathParams path1;
- path1.mEndpointId = 1;
- AttributePathParams path2;
- path2.mEndpointId = 2;
- NL_TEST_ASSERT(apSuite, !path1.Intersects(path2));
- }
-
- {
- AttributePathParams path1;
- path1.mClusterId = 1;
- AttributePathParams path2;
- path2.mClusterId = 2;
- NL_TEST_ASSERT(apSuite, !path1.Intersects(path2));
- }
-
- {
- AttributePathParams path1;
- path1.mAttributeId = 1;
- AttributePathParams path2;
- path2.mAttributeId = 2;
- NL_TEST_ASSERT(apSuite, !path1.Intersects(path2));
- }
-}
-
-void TestAttributePathIncludedSameFieldId(nlTestSuite * apSuite, void * apContext)
-{
- AttributePathParams clusterInfo1;
- AttributePathParams clusterInfo2;
- AttributePathParams clusterInfo3;
- clusterInfo1.mAttributeId = 1;
- clusterInfo2.mAttributeId = 1;
- clusterInfo3.mAttributeId = 1;
- NL_TEST_ASSERT(apSuite, clusterInfo1.IsAttributePathSupersetOf(clusterInfo2));
- clusterInfo2.mListIndex = 1;
- NL_TEST_ASSERT(apSuite, clusterInfo1.IsAttributePathSupersetOf(clusterInfo2));
- clusterInfo1.mListIndex = 0;
- NL_TEST_ASSERT(apSuite, !clusterInfo1.IsAttributePathSupersetOf(clusterInfo3));
- clusterInfo3.mListIndex = 0;
- NL_TEST_ASSERT(apSuite, clusterInfo1.IsAttributePathSupersetOf(clusterInfo3));
- clusterInfo3.mListIndex = 1;
- NL_TEST_ASSERT(apSuite, !clusterInfo1.IsAttributePathSupersetOf(clusterInfo3));
-}
-
-void TestAttributePathIncludedDifferentFieldId(nlTestSuite * apSuite, void * apContext)
-{
- {
- AttributePathParams clusterInfo1;
- AttributePathParams clusterInfo2;
- clusterInfo1.mAttributeId = 1;
- clusterInfo2.mAttributeId = 2;
- NL_TEST_ASSERT(apSuite, !clusterInfo1.IsAttributePathSupersetOf(clusterInfo2));
- }
- {
- AttributePathParams clusterInfo1;
- AttributePathParams clusterInfo2;
- clusterInfo2.mAttributeId = 2;
- NL_TEST_ASSERT(apSuite, clusterInfo1.IsAttributePathSupersetOf(clusterInfo2));
- }
- {
- AttributePathParams clusterInfo1;
- AttributePathParams clusterInfo2;
- NL_TEST_ASSERT(apSuite, clusterInfo1.IsAttributePathSupersetOf(clusterInfo2));
- }
- {
- AttributePathParams clusterInfo1;
- AttributePathParams clusterInfo2;
-
- clusterInfo1.mAttributeId = 1;
- NL_TEST_ASSERT(apSuite, !clusterInfo1.IsAttributePathSupersetOf(clusterInfo2));
- }
-}
-
-void TestAttributePathIncludedDifferentEndpointId(nlTestSuite * apSuite, void * apContext)
-{
- AttributePathParams clusterInfo1;
- AttributePathParams clusterInfo2;
- clusterInfo1.mEndpointId = 1;
- clusterInfo2.mEndpointId = 2;
- NL_TEST_ASSERT(apSuite, !clusterInfo1.IsAttributePathSupersetOf(clusterInfo2));
-}
-
-void TestAttributePathIncludedDifferentClusterId(nlTestSuite * apSuite, void * apContext)
-{
- AttributePathParams clusterInfo1;
- AttributePathParams clusterInfo2;
- clusterInfo1.mClusterId = 1;
- clusterInfo2.mClusterId = 2;
- NL_TEST_ASSERT(apSuite, !clusterInfo1.IsAttributePathSupersetOf(clusterInfo2));
-}
-
-/*
-{kInvalidEndpointId, kInvalidClusterId, kInvalidEventId},
-{kInvalidEndpointId, MockClusterId(1), kInvalidEventId},
-{kInvalidEndpointId, MockClusterId(1), MockEventId(1)},
-{kMockEndpoint1, kInvalidClusterId, kInvalidEventId},
-{kMockEndpoint1, MockClusterId(1), kInvalidEventId},
-{kMockEndpoint1, MockClusterId(1), MockEventId(1)},
-*/
-chip::app::EventPathParams validEventpaths[6];
-void InitEventPaths()
-{
- validEventpaths[1].mClusterId = MockClusterId(1);
- validEventpaths[2].mClusterId = MockClusterId(1);
- validEventpaths[2].mEventId = MockEventId(1);
- validEventpaths[3].mEndpointId = kMockEndpoint1;
- validEventpaths[4].mEndpointId = kMockEndpoint1;
- validEventpaths[4].mClusterId = MockClusterId(1);
- validEventpaths[5].mEndpointId = kMockEndpoint1;
- validEventpaths[5].mClusterId = MockClusterId(1);
- validEventpaths[5].mEventId = MockEventId(1);
-}
-
-void TestEventPathSameEventId(nlTestSuite * apSuite, void * apContext)
-{
- ConcreteEventPath testPath(kMockEndpoint1, MockClusterId(1), MockEventId(1));
- for (auto & path : validEventpaths)
- {
- NL_TEST_ASSERT(apSuite, path.IsValidEventPath());
- NL_TEST_ASSERT(apSuite, path.IsEventPathSupersetOf(testPath));
- }
-}
-
-void TestEventPathDifferentEventId(nlTestSuite * apSuite, void * apContext)
-{
- ConcreteEventPath testPath(kMockEndpoint1, MockClusterId(1), MockEventId(2));
- NL_TEST_ASSERT(apSuite, validEventpaths[0].IsEventPathSupersetOf(testPath));
- NL_TEST_ASSERT(apSuite, validEventpaths[1].IsEventPathSupersetOf(testPath));
- NL_TEST_ASSERT(apSuite, !validEventpaths[2].IsEventPathSupersetOf(testPath));
- NL_TEST_ASSERT(apSuite, validEventpaths[3].IsEventPathSupersetOf(testPath));
- NL_TEST_ASSERT(apSuite, validEventpaths[4].IsEventPathSupersetOf(testPath));
- NL_TEST_ASSERT(apSuite, !validEventpaths[5].IsEventPathSupersetOf(testPath));
-}
-
-void TestEventPathDifferentClusterId(nlTestSuite * apSuite, void * apContext)
-{
- ConcreteEventPath testPath(kMockEndpoint1, MockClusterId(2), MockEventId(1));
- NL_TEST_ASSERT(apSuite, validEventpaths[0].IsEventPathSupersetOf(testPath));
- NL_TEST_ASSERT(apSuite, !validEventpaths[1].IsEventPathSupersetOf(testPath));
- NL_TEST_ASSERT(apSuite, !validEventpaths[2].IsEventPathSupersetOf(testPath));
- NL_TEST_ASSERT(apSuite, validEventpaths[3].IsEventPathSupersetOf(testPath));
- NL_TEST_ASSERT(apSuite, !validEventpaths[4].IsEventPathSupersetOf(testPath));
- NL_TEST_ASSERT(apSuite, !validEventpaths[5].IsEventPathSupersetOf(testPath));
-}
-
-void TestEventPathDifferentEndpointId(nlTestSuite * apSuite, void * apContext)
-{
- ConcreteEventPath testPath(kMockEndpoint2, MockClusterId(1), MockEventId(1));
- NL_TEST_ASSERT(apSuite, validEventpaths[0].IsEventPathSupersetOf(testPath));
- NL_TEST_ASSERT(apSuite, validEventpaths[1].IsEventPathSupersetOf(testPath));
- NL_TEST_ASSERT(apSuite, validEventpaths[2].IsEventPathSupersetOf(testPath));
- NL_TEST_ASSERT(apSuite, !validEventpaths[3].IsEventPathSupersetOf(testPath));
- NL_TEST_ASSERT(apSuite, !validEventpaths[4].IsEventPathSupersetOf(testPath));
- NL_TEST_ASSERT(apSuite, !validEventpaths[5].IsEventPathSupersetOf(testPath));
-}
-
-} // namespace TestPath
-} // namespace app
-} // namespace chip
-
-namespace {
-const nlTest sTests[] = {
- NL_TEST_DEF("TestAttributePathIncludedSameFieldId", chip::app::TestPath::TestAttributePathIncludedSameFieldId),
- NL_TEST_DEF("TestAttributePathIncludedDifferentFieldId", chip::app::TestPath::TestAttributePathIncludedDifferentFieldId),
- NL_TEST_DEF("TestAttributePathIncludedDifferentEndpointId", chip::app::TestPath::TestAttributePathIncludedDifferentEndpointId),
- NL_TEST_DEF("TestAttributePathIncludedDifferentClusterId", chip::app::TestPath::TestAttributePathIncludedDifferentClusterId),
- NL_TEST_DEF("TestEventPathSameEventId", chip::app::TestPath::TestEventPathSameEventId),
- NL_TEST_DEF("TestEventPathDifferentEventId", chip::app::TestPath::TestEventPathDifferentEventId),
- NL_TEST_DEF("TestEventPathDifferentClusterId", chip::app::TestPath::TestEventPathDifferentClusterId),
- NL_TEST_DEF("TestEventPathDifferentEndpointId", chip::app::TestPath::TestEventPathDifferentEndpointId),
- NL_TEST_DEF("TestAttributePathIntersect", chip::app::TestPath::TestAttributePathIntersect),
- NL_TEST_SENTINEL()
-};
-}
-
-int TestPath()
-{
- nlTestSuite theSuite = { "TestPath", &sTests[0], nullptr, nullptr };
- chip::app::TestPath::InitEventPaths();
- nlTestRunner(&theSuite, nullptr);
-
- return (nlTestRunnerStats(&theSuite));
-}
-
-CHIP_REGISTER_TEST_SUITE(TestPath)
diff --git a/src/app/tests/TestCommandPathParams.cpp b/src/app/tests/TestCommandPathParams.cpp
index 62b0b29..83a34cb 100644
--- a/src/app/tests/TestCommandPathParams.cpp
+++ b/src/app/tests/TestCommandPathParams.cpp
@@ -23,74 +23,54 @@
*/
#include <app/CommandPathParams.h>
-#include <lib/support/UnitTestRegistration.h>
-#include <nlunit-test.h>
+
+#include <lib/core/StringBuilderAdapters.h>
+#include <pw_unit_test/framework.h>
namespace chip {
namespace app {
namespace TestCommandPathParams {
-void TestSamePath(nlTestSuite * apSuite, void * apContext)
+TEST(TestCommandPathParams, TestSamePath)
{
CommandPathParams commandPathParams1(1, 2, 3, 4, CommandPathFlags::kEndpointIdValid);
CommandPathParams commandPathParams2(1, 2, 3, 4, CommandPathFlags::kEndpointIdValid);
- NL_TEST_ASSERT(apSuite, commandPathParams1.IsSamePath(commandPathParams2));
+ EXPECT_TRUE(commandPathParams1.IsSamePath(commandPathParams2));
}
-void TestDifferentEndpointId(nlTestSuite * apSuite, void * apContext)
+TEST(TestCommandPathParams, TestDifferentEndpointId)
{
CommandPathParams commandPathParams1(1, 2, 3, 4, CommandPathFlags::kEndpointIdValid);
CommandPathParams commandPathParams2(6, 2, 3, 4, CommandPathFlags::kEndpointIdValid);
- NL_TEST_ASSERT(apSuite, !commandPathParams1.IsSamePath(commandPathParams2));
+ EXPECT_FALSE(commandPathParams1.IsSamePath(commandPathParams2));
}
-void TestDifferentGroupId(nlTestSuite * apSuite, void * apContext)
+TEST(TestCommandPathParams, TestDifferentGroupId)
{
CommandPathParams commandPathParams1(1, 2, 3, 4, CommandPathFlags::kGroupIdValid);
CommandPathParams commandPathParams2(1, 6, 3, 4, CommandPathFlags::kGroupIdValid);
- NL_TEST_ASSERT(apSuite, !commandPathParams1.IsSamePath(commandPathParams2));
+ EXPECT_FALSE(commandPathParams1.IsSamePath(commandPathParams2));
}
-void TestDifferentClusterId(nlTestSuite * apSuite, void * apContext)
+TEST(TestCommandPathParams, TestDifferentClusterId)
{
CommandPathParams commandPathParams1(1, 2, 3, 4, CommandPathFlags::kEndpointIdValid);
CommandPathParams commandPathParams2(1, 2, 6, 4, CommandPathFlags::kEndpointIdValid);
- NL_TEST_ASSERT(apSuite, !commandPathParams1.IsSamePath(commandPathParams2));
+ EXPECT_FALSE(commandPathParams1.IsSamePath(commandPathParams2));
}
-void TestDifferentCommandId(nlTestSuite * apSuite, void * apContext)
+TEST(TestCommandPathParams, TestDifferentCommandId)
{
CommandPathParams commandPathParams1(1, 2, 3, 4, CommandPathFlags::kEndpointIdValid);
CommandPathParams commandPathParams2(1, 2, 3, 6, CommandPathFlags::kEndpointIdValid);
- NL_TEST_ASSERT(apSuite, !commandPathParams1.IsSamePath(commandPathParams2));
+ EXPECT_FALSE(commandPathParams1.IsSamePath(commandPathParams2));
}
-void TestDifferentPathFlag(nlTestSuite * apSuite, void * apContext)
+TEST(TestCommandPathParams, TestDifferentPathFlag)
{
CommandPathParams commandPathParams1(1, 2, 3, 4, CommandPathFlags::kEndpointIdValid);
CommandPathParams commandPathParams2(1, 2, 3, 4, CommandPathFlags::kGroupIdValid);
- NL_TEST_ASSERT(apSuite, !commandPathParams1.IsSamePath(commandPathParams2));
+ EXPECT_FALSE(commandPathParams1.IsSamePath(commandPathParams2));
}
} // namespace TestCommandPathParams
} // namespace app
} // namespace chip
-
-namespace {
-const nlTest sTests[] = { NL_TEST_DEF("TestSamePath", chip::app::TestCommandPathParams::TestSamePath),
- NL_TEST_DEF("TestDifferentEndpointId", chip::app::TestCommandPathParams::TestDifferentEndpointId),
- NL_TEST_DEF("TestDifferentGroupId", chip::app::TestCommandPathParams::TestDifferentGroupId),
- NL_TEST_DEF("TestDifferentClusterId", chip::app::TestCommandPathParams::TestDifferentClusterId),
- NL_TEST_DEF("TestDifferentCommandId", chip::app::TestCommandPathParams::TestDifferentCommandId),
- NL_TEST_DEF("TestDifferentPathFlag", chip::app::TestCommandPathParams::TestDifferentPathFlag),
- NL_TEST_SENTINEL() };
-}
-
-int TestCommandPathParams()
-{
- nlTestSuite theSuite = { "CommandPathParams", &sTests[0], nullptr, nullptr };
-
- nlTestRunner(&theSuite, nullptr);
-
- return (nlTestRunnerStats(&theSuite));
-}
-
-CHIP_REGISTER_TEST_SUITE(TestCommandPathParams)
diff --git a/src/app/tests/TestConcreteAttributePath.cpp b/src/app/tests/TestConcreteAttributePath.cpp
index a598c2f..d9f50ab 100644
--- a/src/app/tests/TestConcreteAttributePath.cpp
+++ b/src/app/tests/TestConcreteAttributePath.cpp
@@ -17,36 +17,37 @@
*/
#include <app/ConcreteAttributePath.h>
-#include <lib/support/UnitTestRegistration.h>
-#include <nlunit-test.h>
+
+#include <lib/core/StringBuilderAdapters.h>
+#include <pw_unit_test/framework.h>
using namespace chip;
using namespace chip::app;
namespace {
-void TestConcreteAttributePathEqualityDefaultConstructor(nlTestSuite * aSuite, void * aContext)
+TEST(TestConcreteAttributePath, TestConcreteAttributePathEqualityDefaultConstructor)
{
ConcreteAttributePath path_one;
ConcreteAttributePath path_two;
- NL_TEST_ASSERT(aSuite, path_one == path_two);
+ EXPECT_EQ(path_one, path_two);
}
-void TestConcreteAttributePathEquality(nlTestSuite * aSuite, void * aContext)
+TEST(TestConcreteAttributePath, TestConcreteAttributePathEquality)
{
ConcreteAttributePath path_one(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3);
ConcreteAttributePath path_two(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3);
- NL_TEST_ASSERT(aSuite, path_one == path_two);
+ EXPECT_EQ(path_one, path_two);
}
-void TestConcreteAttributePathInequalityDifferentAttributeId(nlTestSuite * aSuite, void * aContext)
+TEST(TestConcreteAttributePath, TestConcreteAttributePathInequalityDifferentAttributeId)
{
ConcreteAttributePath path_one(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3);
ConcreteAttributePath path_two(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/4);
- NL_TEST_ASSERT(aSuite, path_one != path_two);
+ EXPECT_NE(path_one, path_two);
}
-void TestConcreteDataAttributePathMatchesConcreteAttributePathEquality(nlTestSuite * aSuite, void * aContext)
+TEST(TestConcreteAttributePath, TestConcreteDataAttributePathMatchesConcreteAttributePathEquality)
{
ConcreteAttributePath path(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3);
ConcreteDataAttributePath data_path(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3);
@@ -56,138 +57,96 @@
/*aListOp=*/ConcreteDataAttributePath::ListOperation::ReplaceAll,
/*aListIndex=*/5U);
- NL_TEST_ASSERT(aSuite, data_path.MatchesConcreteAttributePath(path));
- NL_TEST_ASSERT(aSuite, data_path_with_version.MatchesConcreteAttributePath(path));
- NL_TEST_ASSERT(aSuite, data_path_with_list.MatchesConcreteAttributePath(path));
+ EXPECT_TRUE(data_path.MatchesConcreteAttributePath(path));
+ EXPECT_TRUE(data_path_with_version.MatchesConcreteAttributePath(path));
+ EXPECT_TRUE(data_path_with_list.MatchesConcreteAttributePath(path));
}
-void TestConcreteDataAttributePathMatchesConcreteAttributePathInequality(nlTestSuite * aSuite, void * aContext)
+TEST(TestConcreteAttributePath, TestConcreteDataAttributePathMatchesConcreteAttributePathInequality)
{
ConcreteAttributePath path(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3);
ConcreteDataAttributePath data_path(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/4);
- NL_TEST_ASSERT(aSuite, !data_path.MatchesConcreteAttributePath(path));
+ EXPECT_FALSE(data_path.MatchesConcreteAttributePath(path));
}
-void TestConcreteDataAttributePathEqualityDefaultConstructor(nlTestSuite * aSuite, void * aContext)
+TEST(TestConcreteAttributePath, TestConcreteDataAttributePathEqualityDefaultConstructor)
{
ConcreteDataAttributePath one;
ConcreteDataAttributePath two;
- NL_TEST_ASSERT(aSuite, one == two);
+ EXPECT_EQ(one, two);
}
-void TestConcreteDataAttributePathEqualityConcreteAttributePathConstructor(nlTestSuite * aSuite, void * aContext)
+TEST(TestConcreteAttributePath, TestConcreteDataAttributePathEqualityConcreteAttributePathConstructor)
{
ConcreteAttributePath path(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3);
ConcreteDataAttributePath one(path);
ConcreteDataAttributePath two(path);
- NL_TEST_ASSERT(aSuite, one == two);
+ EXPECT_EQ(one, two);
}
-void TestConcreteDataAttributePathInequalityConcreteAttributePathConstructorDifferentAttributeId(nlTestSuite * aSuite,
- void * aContext)
+TEST(TestConcreteAttributePath, TestConcreteDataAttributePathInequalityConcreteAttributePathConstructorDifferentAttributeId)
{
ConcreteAttributePath path_one(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3);
ConcreteAttributePath path_two(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/4);
ConcreteDataAttributePath one(path_one);
ConcreteDataAttributePath two(path_two);
- NL_TEST_ASSERT(aSuite, one != two);
+ EXPECT_NE(one, two);
}
-void TestConcreteDataAttributePathEqualityConcreteAttributePathArgsConstructor(nlTestSuite * aSuite, void * aContext)
+TEST(TestConcreteAttributePath, TestConcreteDataAttributePathEqualityConcreteAttributePathArgsConstructor)
{
ConcreteDataAttributePath one(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3);
ConcreteDataAttributePath two(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3);
- NL_TEST_ASSERT(aSuite, one == two);
+ EXPECT_EQ(one, two);
}
-void TestConcreteDataAttributePathInequalityConcreteAttributePathArgsConstructorDifferentAttributeId(nlTestSuite * aSuite,
- void * aContext)
+TEST(TestConcreteAttributePath, TestConcreteDataAttributePathInequalityConcreteAttributePathArgsConstructorDifferentAttributeId)
{
ConcreteDataAttributePath one(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3);
ConcreteDataAttributePath two(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/4);
- NL_TEST_ASSERT(aSuite, one != two);
+ EXPECT_NE(one, two);
}
-void TestConcreteDataAttributePathEqualityDataVersionConstructor(nlTestSuite * aSuite, void * aContext)
+TEST(TestConcreteAttributePath, TestConcreteDataAttributePathEqualityDataVersionConstructor)
{
ConcreteDataAttributePath one(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3, /*aDataVersion=*/MakeOptional(4U));
ConcreteDataAttributePath two(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3, /*aDataVersion=*/MakeOptional(4U));
- NL_TEST_ASSERT(aSuite, one == two);
+ EXPECT_EQ(one, two);
}
-void TestConcreteDataAttributePathInequalityDataVersionConstructorDifferentDataVersion(nlTestSuite * aSuite, void * aContext)
+TEST(TestConcreteAttributePath, TestConcreteDataAttributePathInequalityDataVersionConstructorDifferentDataVersion)
{
ConcreteDataAttributePath one(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3, /*aDataVersion=*/MakeOptional(4U));
ConcreteDataAttributePath two(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3, /*aDataVersion=*/MakeOptional(5U));
- NL_TEST_ASSERT(aSuite, one != two);
+ EXPECT_NE(one, two);
}
-void TestConcreteDataAttributePathEqualityListConstructor(nlTestSuite * aSuite, void * aContext)
+TEST(TestConcreteAttributePath, TestConcreteDataAttributePathEqualityListConstructor)
{
ConcreteDataAttributePath one(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3,
ConcreteDataAttributePath::ListOperation::ReplaceAll, /*aListIndex=*/5);
ConcreteDataAttributePath two(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3,
ConcreteDataAttributePath::ListOperation::ReplaceAll, /*aListIndex=*/5);
- NL_TEST_ASSERT(aSuite, one == two);
+ EXPECT_EQ(one, two);
}
-void TestConcreteDataAttributePathInequalityListConstructorDifferentListOp(nlTestSuite * aSuite, void * aContext)
+TEST(TestConcreteAttributePath, TestConcreteDataAttributePathInequalityListConstructorDifferentListOp)
{
ConcreteDataAttributePath one(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3,
ConcreteDataAttributePath::ListOperation::ReplaceAll, /*aListIndex=*/5);
ConcreteDataAttributePath two(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3,
ConcreteDataAttributePath::ListOperation::ReplaceItem, /*aListIndex=*/5);
- NL_TEST_ASSERT(aSuite, one != two);
+ EXPECT_NE(one, two);
}
-void TestConcreteDataAttributePathInequalityListConstructorDifferentListIndex(nlTestSuite * aSuite, void * aContext)
+TEST(TestConcreteAttributePath, TestConcreteDataAttributePathInequalityListConstructorDifferentListIndex)
{
ConcreteDataAttributePath one(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3,
ConcreteDataAttributePath::ListOperation::ReplaceAll, /*aListIndex=*/5);
ConcreteDataAttributePath two(/*aEndpointId=*/1, /*aClusterId=*/2, /*aAttributeId=*/3,
ConcreteDataAttributePath::ListOperation::ReplaceAll, /*aListIndex=*/6);
- NL_TEST_ASSERT(aSuite, one != two);
+ EXPECT_NE(one, two);
}
-const nlTest sTests[] = {
- NL_TEST_DEF("TestConcreteAttributePathEqualityDefaultConstructor", TestConcreteAttributePathEqualityDefaultConstructor),
- NL_TEST_DEF("TestConcreteAttributePathEquality", TestConcreteAttributePathEquality),
- NL_TEST_DEF("TestConcreteAttributePathInequalityDifferentAttributeId", TestConcreteAttributePathInequalityDifferentAttributeId),
- NL_TEST_DEF("TestConcreteDataAttributePathMatchesConcreteAttributePathEquality",
- TestConcreteDataAttributePathMatchesConcreteAttributePathEquality),
- NL_TEST_DEF("TestConcreteDataAttributePathMatchesConcreteAttributePathInequality",
- TestConcreteDataAttributePathMatchesConcreteAttributePathInequality),
- NL_TEST_DEF("TestConcreteDataAttributePathEqualityDefaultConstructor", TestConcreteDataAttributePathEqualityDefaultConstructor),
- NL_TEST_DEF("TestConcreteDataAttributePathEqualityConcreteAttributePathConstructor",
- TestConcreteDataAttributePathEqualityConcreteAttributePathConstructor),
- NL_TEST_DEF("TestConcreteDataAttributePathInequalityConcreteAttributePathConstructorDifferentAttributeId",
- TestConcreteDataAttributePathInequalityConcreteAttributePathConstructorDifferentAttributeId),
- NL_TEST_DEF("TestConcreteDataAttributePathEqualityConcreteAttributePathArgsConstructor",
- TestConcreteDataAttributePathEqualityConcreteAttributePathArgsConstructor),
- NL_TEST_DEF("TestConcreteDataAttributePathInequalityConcreteAttributePathArgsConstructorDifferentAttributeId",
- TestConcreteDataAttributePathInequalityConcreteAttributePathArgsConstructorDifferentAttributeId),
- NL_TEST_DEF("TestConcreteDataAttributePathEqualityDataVersionConstructor",
- TestConcreteDataAttributePathEqualityDataVersionConstructor),
- NL_TEST_DEF("TestConcreteDataAttributePathInequalityDataVersionConstructorDifferentDataVersion",
- TestConcreteDataAttributePathInequalityDataVersionConstructorDifferentDataVersion),
- NL_TEST_DEF("TestConcreteDataAttributePathEqualityListConstructor", TestConcreteDataAttributePathEqualityListConstructor),
- NL_TEST_DEF("TestConcreteDataAttributePathInequalityListConstructorDifferentListOp",
- TestConcreteDataAttributePathInequalityListConstructorDifferentListOp),
- NL_TEST_DEF("TestConcreteDataAttributePathInequalityListConstructorDifferentListIndex",
- TestConcreteDataAttributePathInequalityListConstructorDifferentListIndex),
- NL_TEST_SENTINEL()
-};
-
} // anonymous namespace
-
-int TestConcreteAttributePath()
-{
- nlTestSuite theSuite = { "ConcreteAttributePath", &sTests[0], nullptr, nullptr };
-
- nlTestRunner(&theSuite, nullptr);
-
- return (nlTestRunnerStats(&theSuite));
-}
-
-CHIP_REGISTER_TEST_SUITE(TestConcreteAttributePath)
diff --git a/src/app/tests/TestDataModelSerialization.cpp b/src/app/tests/TestDataModelSerialization.cpp
index cdfa656..4c4a54e 100644
--- a/src/app/tests/TestDataModelSerialization.cpp
+++ b/src/app/tests/TestDataModelSerialization.cpp
@@ -16,57 +16,37 @@
* limitations under the License.
*/
-/**
- * @file
- * This file implements unit tests for CHIP Interaction Model Command Interaction
- *
- */
-
#include <app-common/zap-generated/cluster-objects.h>
#include <app/data-model/Decode.h>
#include <app/data-model/Encode.h>
#include <lib/core/TLV.h>
#include <lib/support/CHIPMem.h>
-#include <lib/support/UnitTestRegistration.h>
-#include <nlunit-test.h>
#include <system/SystemPacketBuffer.h>
#include <system/TLVPacketBufferBackingStore.h>
+#include <lib/core/StringBuilderAdapters.h>
+#include <pw_unit_test/framework.h>
+
namespace {
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
-class TestDataModelSerialization
+class TestDataModelSerialization : public ::testing::Test
{
public:
- static void TestDataModelSerialization_EncAndDecSimpleStruct(nlTestSuite * apSuite, void * apContext);
- static void TestDataModelSerialization_EncAndDecSimpleStructNegativeEnum(nlTestSuite * apSuite, void * apContext);
- static void TestDataModelSerialization_EncAndDecNestedStruct(nlTestSuite * apSuite, void * apContext);
- static void TestDataModelSerialization_EncAndDecNestedStructList(nlTestSuite * apSuite, void * apContext);
- static void TestDataModelSerialization_EncAndDecDecodableNestedStructList(nlTestSuite * apSuite, void * apContext);
- static void TestDataModelSerialization_EncAndDecDecodableDoubleNestedStructList(nlTestSuite * apSuite, void * apContext);
+ static void SetUpTestSuite() { ASSERT_EQ(chip::Platform::MemoryInit(), CHIP_NO_ERROR); }
+ static void TearDownTestSuite() { chip::Platform::MemoryShutdown(); }
+ void TearDown() override { System::PacketBufferHandle buf = mStore.Release(); }
- static void TestDataModelSerialization_OptionalFields(nlTestSuite * apSuite, void * apContext);
- static void TestDataModelSerialization_ExtraField(nlTestSuite * apSuite, void * apContext);
- static void TestDataModelSerialization_InvalidSimpleFieldTypes(nlTestSuite * apSuite, void * apContext);
- static void TestDataModelSerialization_InvalidListType(nlTestSuite * apSuite, void * apContext);
-
- static void NullablesOptionalsStruct(nlTestSuite * apSuite, void * apContext);
- static void NullablesOptionalsCommand(nlTestSuite * apSuite, void * apContext);
-
- void Shutdown();
-
-protected:
// Helper functions
template <typename Encodable, typename Decodable>
- static void NullablesOptionalsEncodeDecodeCheck(nlTestSuite * apSuite, void * apContext, bool encodeNulls, bool encodeValues);
+ void NullablesOptionalsEncodeDecodeCheck(bool encodeNulls, bool encodeValues);
template <typename Encodable, typename Decodable>
- static void NullablesOptionalsEncodeDecodeCheck(nlTestSuite * apSuite, void * apContext);
+ void NullablesOptionalsEncodeDecodeCheck();
-private:
void SetupBuf();
void DumpBuf();
void SetupReader();
@@ -74,13 +54,10 @@
System::TLVPacketBufferBackingStore mStore;
TLV::TLVWriter mWriter;
TLV::TLVReader mReader;
- nlTestSuite * mpSuite;
};
using namespace TLV;
-TestDataModelSerialization gTestDataModelSerialization;
-
void TestDataModelSerialization::SetupBuf()
{
System::PacketBufferHandle buf;
@@ -92,11 +69,6 @@
mReader.Init(mStore);
}
-void TestDataModelSerialization::Shutdown()
-{
- System::PacketBufferHandle buf = mStore.Release();
-}
-
void TestDataModelSerialization::DumpBuf()
{
TLV::TLVReader reader;
@@ -112,12 +84,9 @@
void TestDataModelSerialization::SetupReader()
{
- CHIP_ERROR err;
mReader.Init(mStore);
- err = mReader.Next();
-
- NL_TEST_ASSERT(mpSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(mReader.Next(), CHIP_NO_ERROR);
}
template <typename T>
@@ -161,13 +130,9 @@
return (strncmp(str1.data(), str2, str1.size()) == 0);
}
-void TestDataModelSerialization::TestDataModelSerialization_EncAndDecSimpleStruct(nlTestSuite * apSuite, void * apContext)
+TEST_F(TestDataModelSerialization, EncAndDecSimpleStruct)
{
- CHIP_ERROR err;
- auto * _this = static_cast<TestDataModelSerialization *>(apContext);
-
- _this->mpSuite = apSuite;
- _this->SetupBuf();
+ SetupBuf();
//
// Encode
@@ -186,13 +151,11 @@
t.f.Set(Clusters::UnitTesting::SimpleBitmap::kValueC);
- err = DataModel::Encode(_this->mWriter, TLV::AnonymousTag(), t);
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(DataModel::Encode(mWriter, TLV::AnonymousTag(), t), CHIP_NO_ERROR);
- err = _this->mWriter.Finalize();
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(mWriter.Finalize(), CHIP_NO_ERROR);
- _this->DumpBuf();
+ DumpBuf();
}
//
@@ -201,35 +164,31 @@
{
Clusters::UnitTesting::Structs::SimpleStruct::Type t;
- _this->SetupReader();
+ SetupReader();
- err = DataModel::Decode(_this->mReader, t);
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(DataModel::Decode(mReader, t), CHIP_NO_ERROR);
- NL_TEST_ASSERT(apSuite, t.a == 20);
- NL_TEST_ASSERT(apSuite, t.b == true);
- NL_TEST_ASSERT(apSuite, t.c == Clusters::UnitTesting::SimpleEnum::kValueA);
+ EXPECT_EQ(t.a, 20);
+ EXPECT_TRUE(t.b);
+ EXPECT_EQ(t.c, Clusters::UnitTesting::SimpleEnum::kValueA);
- NL_TEST_ASSERT(apSuite, t.d.size() == 4);
+ EXPECT_EQ(t.d.size(), 4u);
for (uint32_t i = 0; i < t.d.size(); i++)
{
- NL_TEST_ASSERT(apSuite, t.d.data()[i] == i);
+ EXPECT_EQ(t.d.data()[i], i);
}
- NL_TEST_ASSERT(apSuite, StringMatches(t.e, "chip"));
- NL_TEST_ASSERT(apSuite, t.f.HasOnly(Clusters::UnitTesting::SimpleBitmap::kValueC));
+ EXPECT_TRUE(StringMatches(t.e, "chip"));
+ EXPECT_TRUE(t.f.HasOnly(Clusters::UnitTesting::SimpleBitmap::kValueC));
}
}
-void TestDataModelSerialization::TestDataModelSerialization_EncAndDecSimpleStructNegativeEnum(nlTestSuite * apSuite,
- void * apContext)
-{
- CHIP_ERROR err;
- auto * _this = static_cast<TestDataModelSerialization *>(apContext);
+TEST_F(TestDataModelSerialization, EncAndDecSimpleStructNegativeEnum)
- _this->mpSuite = apSuite;
- _this->SetupBuf();
+{
+
+ SetupBuf();
//
// Encode
@@ -248,13 +207,11 @@
t.f.Set(Clusters::UnitTesting::SimpleBitmap::kValueC);
- err = DataModel::Encode(_this->mWriter, TLV::AnonymousTag(), t);
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(DataModel::Encode(mWriter, TLV::AnonymousTag(), t), CHIP_NO_ERROR);
- err = _this->mWriter.Finalize();
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(mWriter.Finalize(), CHIP_NO_ERROR);
- _this->DumpBuf();
+ DumpBuf();
}
//
@@ -263,21 +220,17 @@
{
Clusters::UnitTesting::Structs::SimpleStruct::Type t;
- _this->SetupReader();
+ SetupReader();
- err = DataModel::Decode(_this->mReader, t);
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
- NL_TEST_ASSERT(apSuite, to_underlying(t.c) == 4);
+ EXPECT_EQ(DataModel::Decode(mReader, t), CHIP_NO_ERROR);
+ EXPECT_EQ(to_underlying(t.c), 4);
}
}
-void TestDataModelSerialization::TestDataModelSerialization_EncAndDecNestedStruct(nlTestSuite * apSuite, void * apContext)
+TEST_F(TestDataModelSerialization, EncAndDecNestedStruct)
{
- CHIP_ERROR err;
- auto * _this = static_cast<TestDataModelSerialization *>(apContext);
- _this->mpSuite = apSuite;
- _this->SetupBuf();
+ SetupBuf();
//
// Encode
@@ -296,13 +249,10 @@
t.c.e = Span<char>{ strbuf, strlen(strbuf) };
- err = DataModel::Encode(_this->mWriter, TLV::AnonymousTag(), t);
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(DataModel::Encode(mWriter, TLV::AnonymousTag(), t), CHIP_NO_ERROR);
+ EXPECT_EQ(mWriter.Finalize(), CHIP_NO_ERROR);
- err = _this->mWriter.Finalize();
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
-
- _this->DumpBuf();
+ DumpBuf();
}
//
@@ -311,36 +261,30 @@
{
Clusters::UnitTesting::Structs::NestedStruct::DecodableType t;
- _this->SetupReader();
+ SetupReader();
- err = DataModel::Decode(_this->mReader, t);
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(DataModel::Decode(mReader, t), CHIP_NO_ERROR);
- NL_TEST_ASSERT(apSuite, t.a == 20);
- NL_TEST_ASSERT(apSuite, t.b == true);
- NL_TEST_ASSERT(apSuite, t.c.a == 11);
- NL_TEST_ASSERT(apSuite, t.c.b == true);
- NL_TEST_ASSERT(apSuite, t.c.c == Clusters::UnitTesting::SimpleEnum::kValueB);
+ EXPECT_EQ(t.a, 20);
+ EXPECT_TRUE(t.b);
+ EXPECT_EQ(t.c.a, 11);
+ EXPECT_TRUE(t.c.b);
+ EXPECT_EQ(t.c.c, Clusters::UnitTesting::SimpleEnum::kValueB);
- NL_TEST_ASSERT(apSuite, t.c.d.size() == 4);
+ EXPECT_EQ(t.c.d.size(), 4u);
for (uint32_t i = 0; i < t.c.d.size(); i++)
{
- NL_TEST_ASSERT(apSuite, t.c.d.data()[i] == i);
+ EXPECT_EQ(t.c.d.data()[i], i);
}
- NL_TEST_ASSERT(apSuite, StringMatches(t.c.e, "chip"));
+ EXPECT_TRUE(StringMatches(t.c.e, "chip"));
}
}
-
-void TestDataModelSerialization::TestDataModelSerialization_EncAndDecDecodableNestedStructList(nlTestSuite * apSuite,
- void * apContext)
+TEST_F(TestDataModelSerialization, EncAndDecDecodableNestedStructList)
{
- CHIP_ERROR err;
- auto * _this = static_cast<TestDataModelSerialization *>(apContext);
- _this->mpSuite = apSuite;
- _this->SetupBuf();
+ SetupBuf();
//
// Encode
@@ -381,13 +325,10 @@
t.c.e = Span<char>{ strbuf, strlen(strbuf) };
t.d = structList;
- err = DataModel::Encode(_this->mWriter, TLV::AnonymousTag(), t);
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(DataModel::Encode(mWriter, TLV::AnonymousTag(), t), CHIP_NO_ERROR);
+ EXPECT_EQ(mWriter.Finalize(), CHIP_NO_ERROR);
- err = _this->mWriter.Finalize();
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
-
- _this->DumpBuf();
+ DumpBuf();
}
//
@@ -397,18 +338,17 @@
Clusters::UnitTesting::Structs::NestedStructList::DecodableType t;
int i;
- _this->SetupReader();
+ SetupReader();
- err = DataModel::Decode(_this->mReader, t);
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(DataModel::Decode(mReader, t), CHIP_NO_ERROR);
- NL_TEST_ASSERT(apSuite, t.a == 20);
- NL_TEST_ASSERT(apSuite, t.b == true);
- NL_TEST_ASSERT(apSuite, t.c.a == 11);
- NL_TEST_ASSERT(apSuite, t.c.b == true);
- NL_TEST_ASSERT(apSuite, t.c.c == Clusters::UnitTesting::SimpleEnum::kValueB);
+ EXPECT_EQ(t.a, 20);
+ EXPECT_TRUE(t.b);
+ EXPECT_EQ(t.c.a, 11);
+ EXPECT_TRUE(t.c.b);
+ EXPECT_EQ(t.c.c, Clusters::UnitTesting::SimpleEnum::kValueB);
- NL_TEST_ASSERT(apSuite, StringMatches(t.c.e, "chip"));
+ EXPECT_TRUE(StringMatches(t.c.e, "chip"));
{
i = 0;
@@ -416,13 +356,13 @@
while (iter.Next())
{
auto & item = iter.GetValue();
- NL_TEST_ASSERT(apSuite, item.a == static_cast<uint8_t>(i));
- NL_TEST_ASSERT(apSuite, item.b == true);
+ EXPECT_EQ(item.a, static_cast<uint8_t>(i));
+ EXPECT_TRUE(item.b);
i++;
}
- NL_TEST_ASSERT(apSuite, iter.GetStatus() == CHIP_NO_ERROR);
- NL_TEST_ASSERT(apSuite, i == 4);
+ EXPECT_EQ(iter.GetStatus(), CHIP_NO_ERROR);
+ EXPECT_EQ(i, 4);
}
{
@@ -431,12 +371,12 @@
while (iter.Next())
{
auto & item = iter.GetValue();
- NL_TEST_ASSERT(apSuite, item == static_cast<uint32_t>(i + 10000));
+ EXPECT_EQ(item, static_cast<uint32_t>(i + 10000));
i++;
}
- NL_TEST_ASSERT(apSuite, iter.GetStatus() == CHIP_NO_ERROR);
- NL_TEST_ASSERT(apSuite, i == 4);
+ EXPECT_EQ(iter.GetStatus(), CHIP_NO_ERROR);
+ EXPECT_EQ(i, 4);
}
{
@@ -450,15 +390,15 @@
unsigned int j = 0;
for (; j < item.size(); j++)
{
- NL_TEST_ASSERT(apSuite, item.data()[j] == j);
+ EXPECT_EQ(item.data()[j], j);
}
- NL_TEST_ASSERT(apSuite, j == 4);
+ EXPECT_EQ(j, 4u);
i++;
}
- NL_TEST_ASSERT(apSuite, iter.GetStatus() == CHIP_NO_ERROR);
- NL_TEST_ASSERT(apSuite, i == 4);
+ EXPECT_EQ(iter.GetStatus(), CHIP_NO_ERROR);
+ EXPECT_EQ(i, 4);
}
{
@@ -468,24 +408,19 @@
while (iter.Next())
{
auto & item = iter.GetValue();
- NL_TEST_ASSERT(apSuite, item == i);
+ EXPECT_EQ(item, i);
i++;
}
- NL_TEST_ASSERT(apSuite, iter.GetStatus() == CHIP_NO_ERROR);
- NL_TEST_ASSERT(apSuite, i == 4);
+ EXPECT_EQ(iter.GetStatus(), CHIP_NO_ERROR);
+ EXPECT_EQ(i, 4);
}
}
}
-
-void TestDataModelSerialization::TestDataModelSerialization_EncAndDecDecodableDoubleNestedStructList(nlTestSuite * apSuite,
- void * apContext)
+TEST_F(TestDataModelSerialization, EncAndDecDecodableDoubleNestedStructList)
{
- CHIP_ERROR err;
- auto * _this = static_cast<TestDataModelSerialization *>(apContext);
- _this->mpSuite = apSuite;
- _this->SetupBuf();
+ SetupBuf();
//
// Encode
@@ -510,13 +445,10 @@
item.d = structList;
}
- err = DataModel::Encode(_this->mWriter, TLV::AnonymousTag(), t);
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(DataModel::Encode(mWriter, TLV::AnonymousTag(), t), CHIP_NO_ERROR);
+ EXPECT_EQ(mWriter.Finalize(), CHIP_NO_ERROR);
- err = _this->mWriter.Finalize();
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
-
- _this->DumpBuf();
+ DumpBuf();
}
//
@@ -525,10 +457,9 @@
{
Clusters::UnitTesting::Structs::DoubleNestedStructList::DecodableType t;
- _this->SetupReader();
+ SetupReader();
- err = DataModel::Decode(_this->mReader, t);
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(DataModel::Decode(mReader, t), CHIP_NO_ERROR);
uint8_t i = 0;
@@ -543,26 +474,23 @@
{
auto & nestedItem = nestedIter.GetValue();
- NL_TEST_ASSERT(apSuite, nestedItem.a == (static_cast<uint8_t>(35) + j));
+ EXPECT_EQ(nestedItem.a, (static_cast<uint8_t>(35) + j));
j++;
}
- NL_TEST_ASSERT(apSuite, j == 4);
+ EXPECT_EQ(j, 4u);
i++;
}
- NL_TEST_ASSERT(apSuite, iter.GetStatus() == CHIP_NO_ERROR);
- NL_TEST_ASSERT(apSuite, i == 4);
+ EXPECT_EQ(iter.GetStatus(), CHIP_NO_ERROR);
+ EXPECT_EQ(i, 4u);
}
}
-void TestDataModelSerialization::TestDataModelSerialization_OptionalFields(nlTestSuite * apSuite, void * apContext)
+TEST_F(TestDataModelSerialization, OptionalFields)
{
- CHIP_ERROR err;
- auto * _this = static_cast<TestDataModelSerialization *>(apContext);
- _this->mpSuite = apSuite;
- _this->SetupBuf();
+ SetupBuf();
//
// Encode
@@ -581,18 +509,18 @@
// Encode every field manually except a.
{
- err = EncodeStruct(_this->mWriter, TLV::AnonymousTag(),
- MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kB), t.b),
- MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kC), t.c),
- MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kD), t.d),
- MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kE), t.e));
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(
+ EncodeStruct(mWriter, TLV::AnonymousTag(),
+ MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kB), t.b),
+ MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kC), t.c),
+ MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kD), t.d),
+ MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kE), t.e)),
+ CHIP_NO_ERROR);
}
- err = _this->mWriter.Finalize();
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(mWriter.Finalize(), CHIP_NO_ERROR);
- _this->DumpBuf();
+ DumpBuf();
}
//
@@ -601,38 +529,33 @@
{
Clusters::UnitTesting::Structs::SimpleStruct::DecodableType t;
- _this->SetupReader();
+ SetupReader();
// Set the value of a to a specific value, and ensure it is not over-written after decode.
t.a = 150;
- err = DataModel::Decode(_this->mReader, t);
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(DataModel::Decode(mReader, t), CHIP_NO_ERROR);
// Ensure that the decoder did not over-write the value set in the generated object
- NL_TEST_ASSERT(apSuite, t.a == 150);
+ EXPECT_EQ(t.a, 150);
- NL_TEST_ASSERT(apSuite, t.b == true);
- NL_TEST_ASSERT(apSuite, t.c == Clusters::UnitTesting::SimpleEnum::kValueA);
+ EXPECT_TRUE(t.b);
+ EXPECT_EQ(t.c, Clusters::UnitTesting::SimpleEnum::kValueA);
- NL_TEST_ASSERT(apSuite, t.d.size() == 4);
+ EXPECT_EQ(t.d.size(), 4u);
for (uint32_t i = 0; i < t.d.size(); i++)
{
- NL_TEST_ASSERT(apSuite, t.d.data()[i] == i);
+ EXPECT_EQ(t.d.data()[i], i);
}
- NL_TEST_ASSERT(apSuite, StringMatches(t.e, "chip"));
+ EXPECT_TRUE(StringMatches(t.e, "chip"));
}
}
-void TestDataModelSerialization::TestDataModelSerialization_ExtraField(nlTestSuite * apSuite, void * apContext)
+TEST_F(TestDataModelSerialization, ExtraField)
{
- CHIP_ERROR err;
- auto * _this = static_cast<TestDataModelSerialization *>(apContext);
-
- _this->mpSuite = apSuite;
- _this->SetupBuf();
+ SetupBuf();
//
// Encode
@@ -651,22 +574,21 @@
// Encode every field + an extra field.
{
- err = EncodeStruct(
- _this->mWriter, TLV::AnonymousTag(),
- MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kA), t.a),
- MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kB), t.b),
- MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kC), t.c),
- MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kD), t.d),
- MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kE), t.e),
- MakeTagValuePair(TLV::ContextTag(to_underlying(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kE) + 1),
- t.a));
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(EncodeStruct(
+ mWriter, TLV::AnonymousTag(),
+ MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kA), t.a),
+ MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kB), t.b),
+ MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kC), t.c),
+ MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kD), t.d),
+ MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kE), t.e),
+ MakeTagValuePair(
+ TLV::ContextTag(to_underlying(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kE) + 1), t.a)),
+ CHIP_NO_ERROR);
}
- err = _this->mWriter.Finalize();
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(mWriter.Finalize(), CHIP_NO_ERROR);
- _this->DumpBuf();
+ DumpBuf();
}
//
@@ -675,35 +597,29 @@
{
Clusters::UnitTesting::Structs::SimpleStruct::DecodableType t;
- _this->SetupReader();
+ SetupReader();
// Ensure successful decode despite the extra field.
- err = DataModel::Decode(_this->mReader, t);
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(DataModel::Decode(mReader, t), CHIP_NO_ERROR);
- NL_TEST_ASSERT(apSuite, t.a == 20);
- NL_TEST_ASSERT(apSuite, t.b == true);
- NL_TEST_ASSERT(apSuite, t.c == Clusters::UnitTesting::SimpleEnum::kValueA);
+ EXPECT_EQ(t.a, 20);
+ EXPECT_TRUE(t.b);
+ EXPECT_EQ(t.c, Clusters::UnitTesting::SimpleEnum::kValueA);
- NL_TEST_ASSERT(apSuite, t.d.size() == 4);
+ EXPECT_EQ(t.d.size(), 4u);
for (uint32_t i = 0; i < t.d.size(); i++)
{
- NL_TEST_ASSERT(apSuite, t.d.data()[i] == i);
+ EXPECT_EQ(t.d.data()[i], i);
}
- NL_TEST_ASSERT(apSuite, StringMatches(t.e, "chip"));
+ EXPECT_TRUE(StringMatches(t.e, "chip"));
}
}
-void TestDataModelSerialization::TestDataModelSerialization_InvalidSimpleFieldTypes(nlTestSuite * apSuite, void * apContext)
+TEST_F(TestDataModelSerialization, InvalidSimpleFieldTypes)
{
- CHIP_ERROR err;
- auto * _this = static_cast<TestDataModelSerialization *>(apContext);
-
- _this->mpSuite = apSuite;
- _this->SetupBuf();
-
+ SetupBuf();
//
// Case #1: Swap out field a (an integer) with a boolean.
//
@@ -725,37 +641,32 @@
// Encode every field manually except a.
{
- err =
- EncodeStruct(_this->mWriter, TLV::AnonymousTag(),
+ EXPECT_EQ(
+ EncodeStruct(mWriter, TLV::AnonymousTag(),
MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kA), t.b),
MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kB), t.b),
MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kC), t.c),
MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kD), t.d),
- MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kE), t.e));
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kE), t.e)),
+ CHIP_NO_ERROR);
}
- err = _this->mWriter.Finalize();
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
-
- _this->DumpBuf();
+ EXPECT_EQ(mWriter.Finalize(), CHIP_NO_ERROR);
+ DumpBuf();
}
-
//
// Decode
//
{
Clusters::UnitTesting::Structs::SimpleStruct::DecodableType t;
- _this->SetupReader();
+ SetupReader();
- err = DataModel::Decode(_this->mReader, t);
- NL_TEST_ASSERT(apSuite, err != CHIP_NO_ERROR);
+ EXPECT_NE(DataModel::Decode(mReader, t), CHIP_NO_ERROR);
}
}
- _this->SetupBuf();
-
+ SetupBuf();
//
// Case #2: Swap out an octet string with a UTF-8 string.
//
@@ -777,20 +688,19 @@
// Encode every field manually except a.
{
- err =
- EncodeStruct(_this->mWriter, TLV::AnonymousTag(),
+ EXPECT_EQ(
+ EncodeStruct(mWriter, TLV::AnonymousTag(),
MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kA), t.a),
MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kB), t.b),
MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kC), t.c),
MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kD), t.e),
- MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kE), t.e));
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::SimpleStruct::Fields::kE), t.e)),
+ CHIP_NO_ERROR);
}
- err = _this->mWriter.Finalize();
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(mWriter.Finalize(), CHIP_NO_ERROR);
- _this->DumpBuf();
+ DumpBuf();
}
//
@@ -799,21 +709,16 @@
{
Clusters::UnitTesting::Structs::SimpleStruct::DecodableType t;
- _this->SetupReader();
+ SetupReader();
- err = DataModel::Decode(_this->mReader, t);
- NL_TEST_ASSERT(apSuite, err != CHIP_NO_ERROR);
+ EXPECT_NE(DataModel::Decode(mReader, t), CHIP_NO_ERROR);
}
}
}
-void TestDataModelSerialization::TestDataModelSerialization_InvalidListType(nlTestSuite * apSuite, void * apContext)
+TEST_F(TestDataModelSerialization, InvalidListType)
{
- CHIP_ERROR err;
- auto * _this = static_cast<TestDataModelSerialization *>(apContext);
-
- _this->mpSuite = apSuite;
- _this->SetupBuf();
+ SetupBuf();
//
// Encode
@@ -826,16 +731,14 @@
// Encode a list of integers for field d instead of a list of structs.
{
- err =
- EncodeStruct(_this->mWriter, TLV::AnonymousTag(),
- MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::NestedStructList::Fields::kD), t.e));
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(
+ EncodeStruct(mWriter, TLV::AnonymousTag(),
+ MakeTagValuePair(TLV::ContextTag(Clusters::UnitTesting::Structs::NestedStructList::Fields::kD), t.e)),
+ CHIP_NO_ERROR);
}
- err = _this->mWriter.Finalize();
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
-
- _this->DumpBuf();
+ EXPECT_EQ(mWriter.Finalize(), CHIP_NO_ERROR);
+ DumpBuf();
}
//
@@ -844,10 +747,9 @@
{
Clusters::UnitTesting::Structs::NestedStructList::DecodableType t;
- _this->SetupReader();
+ SetupReader();
- err = DataModel::Decode(_this->mReader, t);
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(DataModel::Decode(mReader, t), CHIP_NO_ERROR);
auto iter = t.d.begin();
bool hadItems = false;
@@ -857,8 +759,8 @@
hadItems = true;
}
- NL_TEST_ASSERT(apSuite, iter.GetStatus() != CHIP_NO_ERROR);
- NL_TEST_ASSERT(apSuite, !hadItems);
+ EXPECT_NE(iter.GetStatus(), CHIP_NO_ERROR);
+ EXPECT_FALSE(hadItems);
}
}
@@ -905,13 +807,10 @@
} // anonymous namespace
template <typename Encodable, typename Decodable>
-void TestDataModelSerialization::NullablesOptionalsEncodeDecodeCheck(nlTestSuite * apSuite, void * apContext, bool encodeNulls,
- bool encodeValues)
+void TestDataModelSerialization::NullablesOptionalsEncodeDecodeCheck(bool encodeNulls, bool encodeValues)
{
- auto * _this = static_cast<TestDataModelSerialization *>(apContext);
- _this->mpSuite = apSuite;
- _this->SetupBuf();
+ SetupBuf();
static const char structStr[] = "something";
const uint8_t structBytes[] = { 1, 8, 17 };
@@ -974,161 +873,117 @@
encodable.nullableList.SetNull();
}
- CHIP_ERROR err = DataModel::Encode(_this->mWriter, TLV::AnonymousTag(), encodable);
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
- err = _this->mWriter.Finalize();
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(DataModel::Encode(mWriter, TLV::AnonymousTag(), encodable), CHIP_NO_ERROR);
+ EXPECT_EQ(mWriter.Finalize(), CHIP_NO_ERROR);
}
// Decode
{
- _this->SetupReader();
+ SetupReader();
Decodable decodable;
- CHIP_ERROR err = DataModel::Decode(_this->mReader, decodable);
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+ EXPECT_EQ(DataModel::Decode(mReader, decodable), CHIP_NO_ERROR);
if (encodeNulls)
{
- NL_TEST_ASSERT(apSuite, decodable.nullableInt.IsNull());
- NL_TEST_ASSERT(apSuite, !decodable.optionalInt.HasValue());
- NL_TEST_ASSERT(apSuite, decodable.nullableOptionalInt.HasValue());
- NL_TEST_ASSERT(apSuite, decodable.nullableOptionalInt.Value().IsNull());
+ EXPECT_TRUE(decodable.nullableInt.IsNull());
+ EXPECT_FALSE(decodable.optionalInt.HasValue());
+ EXPECT_TRUE(decodable.nullableOptionalInt.HasValue());
+ EXPECT_TRUE(decodable.nullableOptionalInt.Value().IsNull());
- NL_TEST_ASSERT(apSuite, decodable.nullableString.IsNull());
- NL_TEST_ASSERT(apSuite, !decodable.optionalString.HasValue());
- NL_TEST_ASSERT(apSuite, decodable.nullableOptionalString.HasValue());
- NL_TEST_ASSERT(apSuite, decodable.nullableOptionalString.Value().IsNull());
+ EXPECT_TRUE(decodable.nullableString.IsNull());
+ EXPECT_FALSE(decodable.optionalString.HasValue());
+ EXPECT_TRUE(decodable.nullableOptionalString.HasValue());
+ EXPECT_TRUE(decodable.nullableOptionalString.Value().IsNull());
- NL_TEST_ASSERT(apSuite, decodable.nullableStruct.IsNull());
- NL_TEST_ASSERT(apSuite, !decodable.optionalStruct.HasValue());
- NL_TEST_ASSERT(apSuite, decodable.nullableOptionalStruct.HasValue());
- NL_TEST_ASSERT(apSuite, decodable.nullableOptionalStruct.Value().IsNull());
+ EXPECT_TRUE(decodable.nullableStruct.IsNull());
+ EXPECT_FALSE(decodable.optionalStruct.HasValue());
+ EXPECT_TRUE(decodable.nullableOptionalStruct.HasValue());
+ EXPECT_TRUE(decodable.nullableOptionalStruct.Value().IsNull());
- NL_TEST_ASSERT(apSuite, decodable.nullableList.IsNull());
- NL_TEST_ASSERT(apSuite, !decodable.optionalList.HasValue());
- NL_TEST_ASSERT(apSuite, decodable.nullableOptionalList.HasValue());
- NL_TEST_ASSERT(apSuite, decodable.nullableOptionalList.Value().IsNull());
+ EXPECT_TRUE(decodable.nullableList.IsNull());
+ EXPECT_FALSE(decodable.optionalList.HasValue());
+ EXPECT_TRUE(decodable.nullableOptionalList.HasValue());
+ EXPECT_TRUE(decodable.nullableOptionalList.Value().IsNull());
}
else if (encodeValues)
{
static const char str[] = "abc";
CharSpan strSpan = CharSpan::fromCharString(str);
- NL_TEST_ASSERT(apSuite, !decodable.nullableInt.IsNull());
- NL_TEST_ASSERT(apSuite, decodable.nullableInt.Value() == 5);
- NL_TEST_ASSERT(apSuite, decodable.optionalInt.HasValue());
- NL_TEST_ASSERT(apSuite, decodable.optionalInt.Value() == 6);
- NL_TEST_ASSERT(apSuite, decodable.nullableOptionalInt.HasValue());
- NL_TEST_ASSERT(apSuite, !decodable.nullableOptionalInt.Value().IsNull());
- NL_TEST_ASSERT(apSuite, decodable.nullableOptionalInt.Value().Value() == 7);
+ EXPECT_FALSE(decodable.nullableInt.IsNull());
+ EXPECT_EQ(decodable.nullableInt.Value(), 5);
+ EXPECT_TRUE(decodable.optionalInt.HasValue());
+ EXPECT_EQ(decodable.optionalInt.Value(), 6);
+ EXPECT_TRUE(decodable.nullableOptionalInt.HasValue());
+ EXPECT_FALSE(decodable.nullableOptionalInt.Value().IsNull());
+ EXPECT_EQ(decodable.nullableOptionalInt.Value().Value(), 7);
- NL_TEST_ASSERT(apSuite, !decodable.nullableString.IsNull());
- NL_TEST_ASSERT(apSuite, decodable.nullableString.Value().data_equal(strSpan));
- NL_TEST_ASSERT(apSuite, decodable.optionalString.HasValue());
- NL_TEST_ASSERT(apSuite, decodable.optionalString.Value().data_equal(strSpan));
- NL_TEST_ASSERT(apSuite, decodable.nullableOptionalString.HasValue());
- NL_TEST_ASSERT(apSuite, !decodable.nullableOptionalString.Value().IsNull());
- NL_TEST_ASSERT(apSuite, decodable.nullableOptionalString.Value().Value().data_equal(strSpan));
+ EXPECT_FALSE(decodable.nullableString.IsNull());
+ EXPECT_TRUE(decodable.nullableString.Value().data_equal(strSpan));
+ EXPECT_TRUE(decodable.optionalString.HasValue());
+ EXPECT_TRUE(decodable.optionalString.Value().data_equal(strSpan));
+ EXPECT_TRUE(decodable.nullableOptionalString.HasValue());
+ EXPECT_FALSE(decodable.nullableOptionalString.Value().IsNull());
+ EXPECT_TRUE(decodable.nullableOptionalString.Value().Value().data_equal(strSpan));
- NL_TEST_ASSERT(apSuite, !decodable.nullableStruct.IsNull());
- NL_TEST_ASSERT(apSuite, SimpleStructsEqual(decodable.nullableStruct.Value(), myStruct));
- NL_TEST_ASSERT(apSuite, decodable.optionalStruct.HasValue());
- NL_TEST_ASSERT(apSuite, SimpleStructsEqual(decodable.optionalStruct.Value(), myStruct));
- NL_TEST_ASSERT(apSuite, decodable.nullableOptionalStruct.HasValue());
- NL_TEST_ASSERT(apSuite, !decodable.nullableOptionalStruct.Value().IsNull());
- NL_TEST_ASSERT(apSuite, SimpleStructsEqual(decodable.nullableOptionalStruct.Value().Value(), myStruct));
+ EXPECT_FALSE(decodable.nullableStruct.IsNull());
+ EXPECT_TRUE(SimpleStructsEqual(decodable.nullableStruct.Value(), myStruct));
+ EXPECT_TRUE(decodable.optionalStruct.HasValue());
+ EXPECT_TRUE(SimpleStructsEqual(decodable.optionalStruct.Value(), myStruct));
+ EXPECT_TRUE(decodable.nullableOptionalStruct.HasValue());
+ EXPECT_FALSE(decodable.nullableOptionalStruct.Value().IsNull());
+ EXPECT_TRUE(SimpleStructsEqual(decodable.nullableOptionalStruct.Value().Value(), myStruct));
- NL_TEST_ASSERT(apSuite, !decodable.nullableList.IsNull());
- NL_TEST_ASSERT(apSuite, ListsEqual(decodable.nullableList.Value(), enumList));
- NL_TEST_ASSERT(apSuite, decodable.optionalList.HasValue());
- NL_TEST_ASSERT(apSuite, ListsEqual(decodable.optionalList.Value(), enumList));
- NL_TEST_ASSERT(apSuite, decodable.nullableOptionalList.HasValue());
- NL_TEST_ASSERT(apSuite, !decodable.nullableOptionalList.Value().IsNull());
- NL_TEST_ASSERT(apSuite, ListsEqual(decodable.nullableOptionalList.Value().Value(), enumList));
+ EXPECT_FALSE(decodable.nullableList.IsNull());
+ EXPECT_TRUE(ListsEqual(decodable.nullableList.Value(), enumList));
+ EXPECT_TRUE(decodable.optionalList.HasValue());
+ EXPECT_TRUE(ListsEqual(decodable.optionalList.Value(), enumList));
+ EXPECT_TRUE(decodable.nullableOptionalList.HasValue());
+ EXPECT_FALSE(decodable.nullableOptionalList.Value().IsNull());
+ EXPECT_TRUE(ListsEqual(decodable.nullableOptionalList.Value().Value(), enumList));
}
else
{
- NL_TEST_ASSERT(apSuite, decodable.nullableInt.IsNull());
- NL_TEST_ASSERT(apSuite, !decodable.optionalInt.HasValue());
- NL_TEST_ASSERT(apSuite, !decodable.nullableOptionalInt.HasValue());
+ EXPECT_TRUE(decodable.nullableInt.IsNull());
+ EXPECT_FALSE(decodable.optionalInt.HasValue());
+ EXPECT_FALSE(decodable.nullableOptionalInt.HasValue());
- NL_TEST_ASSERT(apSuite, decodable.nullableString.IsNull());
- NL_TEST_ASSERT(apSuite, !decodable.optionalString.HasValue());
- NL_TEST_ASSERT(apSuite, !decodable.nullableOptionalString.HasValue());
+ EXPECT_TRUE(decodable.nullableString.IsNull());
+ EXPECT_FALSE(decodable.optionalString.HasValue());
+ EXPECT_FALSE(decodable.nullableOptionalString.HasValue());
- NL_TEST_ASSERT(apSuite, decodable.nullableStruct.IsNull());
- NL_TEST_ASSERT(apSuite, !decodable.optionalStruct.HasValue());
- NL_TEST_ASSERT(apSuite, !decodable.nullableOptionalStruct.HasValue());
+ EXPECT_TRUE(decodable.nullableStruct.IsNull());
+ EXPECT_FALSE(decodable.optionalStruct.HasValue());
+ EXPECT_FALSE(decodable.nullableOptionalStruct.HasValue());
- NL_TEST_ASSERT(apSuite, decodable.nullableList.IsNull());
- NL_TEST_ASSERT(apSuite, !decodable.optionalList.HasValue());
- NL_TEST_ASSERT(apSuite, !decodable.nullableOptionalList.HasValue());
+ EXPECT_TRUE(decodable.nullableList.IsNull());
+ EXPECT_FALSE(decodable.optionalList.HasValue());
+ EXPECT_FALSE(decodable.nullableOptionalList.HasValue());
}
}
}
template <typename Encodable, typename Decodable>
-void TestDataModelSerialization::NullablesOptionalsEncodeDecodeCheck(nlTestSuite * apSuite, void * apContext)
+void TestDataModelSerialization::NullablesOptionalsEncodeDecodeCheck()
{
- NullablesOptionalsEncodeDecodeCheck<Encodable, Decodable>(apSuite, apContext, false, false);
- NullablesOptionalsEncodeDecodeCheck<Encodable, Decodable>(apSuite, apContext, true, false);
- NullablesOptionalsEncodeDecodeCheck<Encodable, Decodable>(apSuite, apContext, false, true);
+ NullablesOptionalsEncodeDecodeCheck<Encodable, Decodable>(false, false);
+ NullablesOptionalsEncodeDecodeCheck<Encodable, Decodable>(true, false);
+ NullablesOptionalsEncodeDecodeCheck<Encodable, Decodable>(false, true);
}
-void TestDataModelSerialization::NullablesOptionalsStruct(nlTestSuite * apSuite, void * apContext)
+TEST_F(TestDataModelSerialization, NullablesOptionalsStruct)
{
using EncType = Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type;
using DecType = Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::DecodableType;
- NullablesOptionalsEncodeDecodeCheck<EncType, DecType>(apSuite, apContext);
+ NullablesOptionalsEncodeDecodeCheck<EncType, DecType>();
}
-void TestDataModelSerialization::NullablesOptionalsCommand(nlTestSuite * apSuite, void * apContext)
+TEST_F(TestDataModelSerialization, NullablesOptionalsCommand)
{
using EncType = Clusters::UnitTesting::Commands::TestComplexNullableOptionalRequest::Type;
using DecType = Clusters::UnitTesting::Commands::TestComplexNullableOptionalRequest::DecodableType;
- NullablesOptionalsEncodeDecodeCheck<EncType, DecType>(apSuite, apContext);
-}
-
-int Initialize(void * apSuite)
-{
- VerifyOrReturnError(chip::Platform::MemoryInit() == CHIP_NO_ERROR, FAILURE);
- return SUCCESS;
-}
-
-int Finalize(void * aContext)
-{
- gTestDataModelSerialization.Shutdown();
- chip::Platform::MemoryShutdown();
- return SUCCESS;
+ NullablesOptionalsEncodeDecodeCheck<EncType, DecType>();
}
} // namespace
-
-// clang-format off
-const nlTest sTests[] =
-{
- NL_TEST_DEF("TestDataModelSerialization_EncAndDecSimple", TestDataModelSerialization::TestDataModelSerialization_EncAndDecSimpleStruct),
- NL_TEST_DEF("TestDataModelSerialization_EncAndDecSimpleStructNegativeEnum", TestDataModelSerialization::TestDataModelSerialization_EncAndDecSimpleStructNegativeEnum),
- NL_TEST_DEF("TestDataModelSerialization_EncAndDecNestedStruct", TestDataModelSerialization::TestDataModelSerialization_EncAndDecNestedStruct),
- NL_TEST_DEF("TestDataModelSerialization_EncAndDecDecodableNestedStructList", TestDataModelSerialization::TestDataModelSerialization_EncAndDecDecodableNestedStructList),
- NL_TEST_DEF("TestDataModelSerialization_EncAndDecDecodableDoubleNestedStructList", TestDataModelSerialization::TestDataModelSerialization_EncAndDecDecodableDoubleNestedStructList),
- NL_TEST_DEF("TestDataModelSerialization_OptionalFields", TestDataModelSerialization::TestDataModelSerialization_OptionalFields),
- NL_TEST_DEF("TestDataModelSerialization_ExtraField", TestDataModelSerialization::TestDataModelSerialization_ExtraField),
- NL_TEST_DEF("TestDataModelSerialization_InvalidSimpleFieldTypes", TestDataModelSerialization::TestDataModelSerialization_InvalidSimpleFieldTypes),
- NL_TEST_DEF("TestDataModelSerialization_InvalidListType", TestDataModelSerialization::TestDataModelSerialization_InvalidListType),
- NL_TEST_DEF("TestDataModelSerialization_NullablesOptionalsStruct", TestDataModelSerialization::NullablesOptionalsStruct),
- NL_TEST_DEF("TestDataModelSerialization_NullablesOptionalsCommand", TestDataModelSerialization::NullablesOptionalsCommand),
- NL_TEST_SENTINEL()
-};
-// clang-format on
-
-nlTestSuite theSuite = { "TestDataModelSerialization", &sTests[0], Initialize, Finalize };
-
-int DataModelSerializationTest()
-{
- nlTestRunner(&theSuite, &gTestDataModelSerialization);
- return (nlTestRunnerStats(&theSuite));
-}
-
-CHIP_REGISTER_TEST_SUITE(DataModelSerializationTest)
diff --git a/src/app/tests/TestDefaultOTARequestorStorage.cpp b/src/app/tests/TestDefaultOTARequestorStorage.cpp
index 1b4e9b0..53ee108 100644
--- a/src/app/tests/TestDefaultOTARequestorStorage.cpp
+++ b/src/app/tests/TestDefaultOTARequestorStorage.cpp
@@ -19,16 +19,16 @@
#include <app/clusters/ota-requestor/OTARequestorInterface.h>
#include <lib/core/CHIPPersistentStorageDelegate.h>
#include <lib/support/TestPersistentStorageDelegate.h>
-#include <lib/support/UnitTestRegistration.h>
-#include <nlunit-test.h>
+#include <lib/core/StringBuilderAdapters.h>
+#include <pw_unit_test/framework.h>
using namespace chip;
using namespace chip::DeviceLayer;
namespace {
-void TestDefaultProviders(nlTestSuite * inSuite, void * inContext)
+TEST(TestDefaultOTARequestorStorage, TestDefaultProviders)
{
TestPersistentStorageDelegate persistentStorage;
DefaultOTARequestorStorage otaStorage;
@@ -43,49 +43,49 @@
};
ProviderLocationList providers = {};
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == providers.Add(makeProvider(FabricIndex(1), NodeId(0x11111111), EndpointId(1))));
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == providers.Add(makeProvider(FabricIndex(2), NodeId(0x22222222), EndpointId(2))));
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == providers.Add(makeProvider(FabricIndex(3), NodeId(0x33333333), EndpointId(3))));
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == otaStorage.StoreDefaultProviders(providers));
+ EXPECT_EQ(CHIP_NO_ERROR, providers.Add(makeProvider(FabricIndex(1), NodeId(0x11111111), EndpointId(1))));
+ EXPECT_EQ(CHIP_NO_ERROR, providers.Add(makeProvider(FabricIndex(2), NodeId(0x22222222), EndpointId(2))));
+ EXPECT_EQ(CHIP_NO_ERROR, providers.Add(makeProvider(FabricIndex(3), NodeId(0x33333333), EndpointId(3))));
+ EXPECT_EQ(CHIP_NO_ERROR, otaStorage.StoreDefaultProviders(providers));
providers = {};
- NL_TEST_ASSERT(inSuite, !providers.Begin().Next());
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == otaStorage.LoadDefaultProviders(providers));
+ EXPECT_FALSE(providers.Begin().Next());
+ EXPECT_EQ(CHIP_NO_ERROR, otaStorage.LoadDefaultProviders(providers));
auto provider = providers.Begin();
bool hasNext;
- NL_TEST_ASSERT(inSuite, hasNext = provider.Next());
+ EXPECT_TRUE(hasNext = provider.Next());
if (hasNext)
{
- NL_TEST_ASSERT(inSuite, provider.GetValue().fabricIndex == 1);
- NL_TEST_ASSERT(inSuite, provider.GetValue().providerNodeID == 0x11111111);
- NL_TEST_ASSERT(inSuite, provider.GetValue().endpoint == 1);
+ EXPECT_EQ(provider.GetValue().fabricIndex, 1);
+ EXPECT_EQ(provider.GetValue().providerNodeID, 0x11111111u);
+ EXPECT_EQ(provider.GetValue().endpoint, 1);
}
- NL_TEST_ASSERT(inSuite, hasNext = provider.Next());
+ EXPECT_TRUE(hasNext = provider.Next());
if (hasNext)
{
- NL_TEST_ASSERT(inSuite, provider.GetValue().fabricIndex == 2);
- NL_TEST_ASSERT(inSuite, provider.GetValue().providerNodeID == 0x22222222);
- NL_TEST_ASSERT(inSuite, provider.GetValue().endpoint == 2);
+ EXPECT_EQ(provider.GetValue().fabricIndex, 2);
+ EXPECT_EQ(provider.GetValue().providerNodeID, 0x22222222u);
+ EXPECT_EQ(provider.GetValue().endpoint, 2);
}
- NL_TEST_ASSERT(inSuite, hasNext = provider.Next());
+ EXPECT_TRUE(hasNext = provider.Next());
if (hasNext)
{
- NL_TEST_ASSERT(inSuite, provider.GetValue().fabricIndex == 3);
- NL_TEST_ASSERT(inSuite, provider.GetValue().providerNodeID == 0x33333333);
- NL_TEST_ASSERT(inSuite, provider.GetValue().endpoint == 3);
+ EXPECT_EQ(provider.GetValue().fabricIndex, 3);
+ EXPECT_EQ(provider.GetValue().providerNodeID, 0x33333333u);
+ EXPECT_EQ(provider.GetValue().endpoint, 3);
}
- NL_TEST_ASSERT(inSuite, !provider.Next());
+ EXPECT_FALSE(provider.Next());
}
-void TestDefaultProvidersEmpty(nlTestSuite * inSuite, void * inContext)
+TEST(TestDefaultOTARequestorStorage, TestDefaultProvidersEmpty)
{
TestPersistentStorageDelegate persistentStorage;
DefaultOTARequestorStorage otaStorage;
@@ -93,11 +93,11 @@
ProviderLocationList providers = {};
- NL_TEST_ASSERT(inSuite, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND == otaStorage.LoadDefaultProviders(providers));
- NL_TEST_ASSERT(inSuite, !providers.Begin().Next());
+ EXPECT_EQ(CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND, otaStorage.LoadDefaultProviders(providers));
+ EXPECT_FALSE(providers.Begin().Next());
}
-void TestCurrentProviderLocation(nlTestSuite * inSuite, void * inContext)
+TEST(TestDefaultOTARequestorStorage, TestCurrentProviderLocation)
{
TestPersistentStorageDelegate persistentStorage;
DefaultOTARequestorStorage otaStorage;
@@ -108,19 +108,19 @@
provider.providerNodeID = 0x12344321;
provider.endpoint = 10;
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == otaStorage.StoreCurrentProviderLocation(provider));
+ EXPECT_EQ(CHIP_NO_ERROR, otaStorage.StoreCurrentProviderLocation(provider));
provider = {};
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == otaStorage.LoadCurrentProviderLocation(provider));
- NL_TEST_ASSERT(inSuite, provider.fabricIndex == 1);
- NL_TEST_ASSERT(inSuite, provider.providerNodeID == 0x12344321);
- NL_TEST_ASSERT(inSuite, provider.endpoint == 10);
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == otaStorage.ClearCurrentProviderLocation());
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR != otaStorage.LoadCurrentProviderLocation(provider));
+ EXPECT_EQ(CHIP_NO_ERROR, otaStorage.LoadCurrentProviderLocation(provider));
+ EXPECT_EQ(provider.fabricIndex, 1);
+ EXPECT_EQ(provider.providerNodeID, 0x12344321u);
+ EXPECT_EQ(provider.endpoint, 10);
+ EXPECT_EQ(CHIP_NO_ERROR, otaStorage.ClearCurrentProviderLocation());
+ EXPECT_NE(CHIP_NO_ERROR, otaStorage.LoadCurrentProviderLocation(provider));
}
-void TestUpdateToken(nlTestSuite * inSuite, void * inContext)
+TEST(TestDefaultOTARequestorStorage, TestUpdateToken)
{
TestPersistentStorageDelegate persistentStorage;
DefaultOTARequestorStorage otaStorage;
@@ -133,21 +133,21 @@
for (uint8_t i = 0; i < updateTokenLength; ++i)
updateTokenBuffer[i] = i;
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == otaStorage.StoreUpdateToken(updateToken));
+ EXPECT_EQ(CHIP_NO_ERROR, otaStorage.StoreUpdateToken(updateToken));
uint8_t readBuffer[updateTokenLength + 10];
MutableByteSpan readUpdateToken(readBuffer);
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == otaStorage.LoadUpdateToken(readUpdateToken));
- NL_TEST_ASSERT(inSuite, readUpdateToken.size() == updateTokenLength);
+ EXPECT_EQ(CHIP_NO_ERROR, otaStorage.LoadUpdateToken(readUpdateToken));
+ EXPECT_EQ(readUpdateToken.size(), updateTokenLength);
for (uint8_t i = 0; i < updateTokenLength; ++i)
- NL_TEST_ASSERT(inSuite, readBuffer[i] == i);
+ EXPECT_EQ(readBuffer[i], i);
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == otaStorage.ClearUpdateToken());
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR != otaStorage.LoadUpdateToken(readUpdateToken));
+ EXPECT_EQ(CHIP_NO_ERROR, otaStorage.ClearUpdateToken());
+ EXPECT_NE(CHIP_NO_ERROR, otaStorage.LoadUpdateToken(readUpdateToken));
}
-void TestCurrentUpdateState(nlTestSuite * inSuite, void * inContext)
+TEST(TestDefaultOTARequestorStorage, TestCurrentUpdateState)
{
TestPersistentStorageDelegate persistentStorage;
DefaultOTARequestorStorage otaStorage;
@@ -155,17 +155,17 @@
OTARequestorStorage::OTAUpdateStateEnum updateState = OTARequestorStorage::OTAUpdateStateEnum::kApplying;
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == otaStorage.StoreCurrentUpdateState(updateState));
+ EXPECT_EQ(CHIP_NO_ERROR, otaStorage.StoreCurrentUpdateState(updateState));
updateState = OTARequestorStorage::OTAUpdateStateEnum::kUnknown;
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == otaStorage.LoadCurrentUpdateState(updateState));
- NL_TEST_ASSERT(inSuite, updateState == OTARequestorStorage::OTAUpdateStateEnum::kApplying);
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == otaStorage.ClearCurrentUpdateState());
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR != otaStorage.LoadCurrentUpdateState(updateState));
+ EXPECT_EQ(CHIP_NO_ERROR, otaStorage.LoadCurrentUpdateState(updateState));
+ EXPECT_EQ(updateState, OTARequestorStorage::OTAUpdateStateEnum::kApplying);
+ EXPECT_EQ(CHIP_NO_ERROR, otaStorage.ClearCurrentUpdateState());
+ EXPECT_NE(CHIP_NO_ERROR, otaStorage.LoadCurrentUpdateState(updateState));
}
-void TestTargetVersion(nlTestSuite * inSuite, void * inContext)
+TEST(TestDefaultOTARequestorStorage, TestTargetVersion)
{
TestPersistentStorageDelegate persistentStorage;
DefaultOTARequestorStorage otaStorage;
@@ -173,43 +173,14 @@
uint32_t targetVersion = 2;
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == otaStorage.StoreTargetVersion(targetVersion));
+ EXPECT_EQ(CHIP_NO_ERROR, otaStorage.StoreTargetVersion(targetVersion));
targetVersion = 0;
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == otaStorage.LoadTargetVersion(targetVersion));
- NL_TEST_ASSERT(inSuite, targetVersion == 2);
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == otaStorage.ClearTargetVersion());
- NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR != otaStorage.LoadTargetVersion(targetVersion));
-}
-
-const nlTest sTests[] = { NL_TEST_DEF("Test default providers", TestDefaultProviders),
- NL_TEST_DEF("Test default providers (empty list)", TestDefaultProvidersEmpty),
- NL_TEST_DEF("Test current provider location", TestCurrentProviderLocation),
- NL_TEST_DEF("Test update token", TestUpdateToken),
- NL_TEST_DEF("Test current update state", TestCurrentUpdateState),
- NL_TEST_DEF("Test target version", TestTargetVersion),
- NL_TEST_SENTINEL() };
-
-int TestSetup(void * inContext)
-{
- return SUCCESS;
-}
-
-int TestTearDown(void * inContext)
-{
- return SUCCESS;
+ EXPECT_EQ(CHIP_NO_ERROR, otaStorage.LoadTargetVersion(targetVersion));
+ EXPECT_EQ(targetVersion, 2u);
+ EXPECT_EQ(CHIP_NO_ERROR, otaStorage.ClearTargetVersion());
+ EXPECT_NE(CHIP_NO_ERROR, otaStorage.LoadTargetVersion(targetVersion));
}
} // namespace
-
-int TestDefaultOTARequestorStorage()
-{
- nlTestSuite theSuite = { "OTA Storage tests", &sTests[0], TestSetup, TestTearDown };
-
- // Run test suite against one context.
- nlTestRunner(&theSuite, nullptr);
- return nlTestRunnerStats(&theSuite);
-}
-
-CHIP_REGISTER_TEST_SUITE(TestDefaultOTARequestorStorage)
diff --git a/src/app/tests/TestEventPathParams.cpp b/src/app/tests/TestEventPathParams.cpp
index da0b331..a962a6b 100644
--- a/src/app/tests/TestEventPathParams.cpp
+++ b/src/app/tests/TestEventPathParams.cpp
@@ -16,65 +16,120 @@
* limitations under the License.
*/
-/**
- * @file
- * This file implements unit tests for EventPathParams
- *
- */
-
#include <app/EventPathParams.h>
-#include <lib/support/UnitTestRegistration.h>
-#include <nlunit-test.h>
+#include <app/util/mock/Constants.h>
+#include <lib/core/StringBuilderAdapters.h>
+#include <pw_unit_test/framework.h>
+
+using namespace chip::Test;
namespace chip {
namespace app {
namespace TestEventPathParams {
-void TestSamePath(nlTestSuite * apSuite, void * apContext)
+
+class TestEventPathParams : public ::testing::Test
+{
+public:
+ static void SetUpTestSuite() { InitEventPaths(); }
+
+ static void InitEventPaths();
+
+ static chip::app::EventPathParams validEventpaths[6];
+};
+
+chip::app::EventPathParams TestEventPathParams::validEventpaths[6];
+
+TEST_F(TestEventPathParams, SamePath)
{
EventPathParams eventPathParams1(2, 3, 4);
EventPathParams eventPathParams2(2, 3, 4);
- NL_TEST_ASSERT(apSuite, eventPathParams1.IsSamePath(eventPathParams2));
+ EXPECT_TRUE(eventPathParams1.IsSamePath(eventPathParams2));
}
-void TestDifferentEndpointId(nlTestSuite * apSuite, void * apContext)
+TEST_F(TestEventPathParams, DifferentEndpointId)
{
EventPathParams eventPathParams1(2, 3, 4);
EventPathParams eventPathParams2(6, 3, 4);
- NL_TEST_ASSERT(apSuite, !eventPathParams1.IsSamePath(eventPathParams2));
+ EXPECT_FALSE(eventPathParams1.IsSamePath(eventPathParams2));
}
-void TestDifferentClusterId(nlTestSuite * apSuite, void * apContext)
+TEST_F(TestEventPathParams, DifferentClusterId)
{
EventPathParams eventPathParams1(2, 3, 4);
EventPathParams eventPathParams2(2, 6, 4);
- NL_TEST_ASSERT(apSuite, !eventPathParams1.IsSamePath(eventPathParams2));
+ EXPECT_FALSE(eventPathParams1.IsSamePath(eventPathParams2));
}
-void TestDifferentEventId(nlTestSuite * apSuite, void * apContext)
+TEST_F(TestEventPathParams, DifferentEventId)
{
EventPathParams eventPathParams1(2, 3, 4);
EventPathParams eventPathParams2(2, 3, 6);
- NL_TEST_ASSERT(apSuite, !eventPathParams1.IsSamePath(eventPathParams2));
+ EXPECT_FALSE(eventPathParams1.IsSamePath(eventPathParams2));
}
+
+/* after Init, validEventpaths array will have the following values:
+{kInvalidEndpointId, kInvalidClusterId, kInvalidEventId},
+{kInvalidEndpointId, MockClusterId(1), kInvalidEventId},
+{kInvalidEndpointId, MockClusterId(1), MockEventId(1)},
+{kMockEndpoint1, kInvalidClusterId, kInvalidEventId},
+{kMockEndpoint1, MockClusterId(1), kInvalidEventId},
+{kMockEndpoint1, MockClusterId(1), MockEventId(1)},
+*/
+void TestEventPathParams::InitEventPaths()
+{
+ validEventpaths[1].mClusterId = MockClusterId(1);
+ validEventpaths[2].mClusterId = MockClusterId(1);
+ validEventpaths[2].mEventId = MockEventId(1);
+ validEventpaths[3].mEndpointId = kMockEndpoint1;
+ validEventpaths[4].mEndpointId = kMockEndpoint1;
+ validEventpaths[4].mClusterId = MockClusterId(1);
+ validEventpaths[5].mEndpointId = kMockEndpoint1;
+ validEventpaths[5].mClusterId = MockClusterId(1);
+ validEventpaths[5].mEventId = MockEventId(1);
+}
+
+TEST_F(TestEventPathParams, ConcreteEventPathSameEventId)
+{
+ ConcreteEventPath testPath(kMockEndpoint1, MockClusterId(1), MockEventId(1));
+ for (auto & path : validEventpaths)
+ {
+ EXPECT_TRUE(path.IsValidEventPath());
+ EXPECT_TRUE(path.IsEventPathSupersetOf(testPath));
+ }
+}
+TEST_F(TestEventPathParams, ConcreteEventPathDifferentEndpointId)
+{
+ ConcreteEventPath testPath(kMockEndpoint2, MockClusterId(1), MockEventId(1));
+ EXPECT_TRUE(validEventpaths[0].IsEventPathSupersetOf(testPath));
+ EXPECT_TRUE(validEventpaths[1].IsEventPathSupersetOf(testPath));
+ EXPECT_TRUE(validEventpaths[2].IsEventPathSupersetOf(testPath));
+ EXPECT_FALSE(validEventpaths[3].IsEventPathSupersetOf(testPath));
+ EXPECT_FALSE(validEventpaths[4].IsEventPathSupersetOf(testPath));
+ EXPECT_FALSE(validEventpaths[5].IsEventPathSupersetOf(testPath));
+}
+
+TEST_F(TestEventPathParams, ConcreteEventPathDifferentClusterId)
+{
+ ConcreteEventPath testPath(kMockEndpoint1, MockClusterId(2), MockEventId(1));
+ EXPECT_TRUE(validEventpaths[0].IsEventPathSupersetOf(testPath));
+ EXPECT_FALSE(validEventpaths[1].IsEventPathSupersetOf(testPath));
+ EXPECT_FALSE(validEventpaths[2].IsEventPathSupersetOf(testPath));
+ EXPECT_TRUE(validEventpaths[3].IsEventPathSupersetOf(testPath));
+ EXPECT_FALSE(validEventpaths[4].IsEventPathSupersetOf(testPath));
+ EXPECT_FALSE(validEventpaths[5].IsEventPathSupersetOf(testPath));
+}
+
+TEST_F(TestEventPathParams, ConcreteEventPathDifferentEventId)
+{
+ ConcreteEventPath testPath(kMockEndpoint1, MockClusterId(1), MockEventId(2));
+ EXPECT_TRUE(validEventpaths[0].IsEventPathSupersetOf(testPath));
+ EXPECT_TRUE(validEventpaths[1].IsEventPathSupersetOf(testPath));
+ EXPECT_FALSE(validEventpaths[2].IsEventPathSupersetOf(testPath));
+ EXPECT_TRUE(validEventpaths[3].IsEventPathSupersetOf(testPath));
+ EXPECT_TRUE(validEventpaths[4].IsEventPathSupersetOf(testPath));
+ EXPECT_FALSE(validEventpaths[5].IsEventPathSupersetOf(testPath));
+}
+
} // namespace TestEventPathParams
} // namespace app
} // namespace chip
-
-namespace {
-const nlTest sTests[] = { NL_TEST_DEF("TestSamePath", chip::app::TestEventPathParams::TestSamePath),
- NL_TEST_DEF("TestDifferentEndpointId", chip::app::TestEventPathParams::TestDifferentEndpointId),
- NL_TEST_DEF("TestDifferentClusterId", chip::app::TestEventPathParams::TestDifferentClusterId),
- NL_TEST_DEF("TestDifferentEventId", chip::app::TestEventPathParams::TestDifferentEventId),
- NL_TEST_SENTINEL() };
-}
-
-int TestEventPathParams()
-{
- nlTestSuite theSuite = { "EventPathParams", &sTests[0], nullptr, nullptr };
-
- nlTestRunner(&theSuite, nullptr);
-
- return (nlTestRunnerStats(&theSuite));
-}
-
-CHIP_REGISTER_TEST_SUITE(TestEventPathParams)
diff --git a/src/app/tests/TestExtensionFieldSets.cpp b/src/app/tests/TestExtensionFieldSets.cpp
index 2c7fb4e..66b4e9e 100644
--- a/src/app/tests/TestExtensionFieldSets.cpp
+++ b/src/app/tests/TestExtensionFieldSets.cpp
@@ -19,8 +19,9 @@
#include <app/clusters/scenes-server/ExtensionFieldSetsImpl.h>
#include <lib/core/TLV.h>
#include <lib/support/Span.h>
-#include <lib/support/UnitTestRegistration.h>
-#include <nlunit-test.h>
+
+#include <lib/core/StringBuilderAdapters.h>
+#include <pw_unit_test/framework.h>
using namespace chip;
@@ -53,7 +54,14 @@
static scenes::ExtensionFieldSetsImpl sEFSets;
-void TestInsertExtensionFieldSet(nlTestSuite * aSuite, void * aContext)
+class TestExtensionFieldSets : public ::testing::Test
+{
+public:
+ static void SetUpTestSuite() { ASSERT_EQ(chip::Platform::MemoryInit(), CHIP_NO_ERROR); }
+ static void TearDownTestSuite() { chip::Platform::MemoryShutdown(); }
+};
+
+TEST_F(TestExtensionFieldSets, TestInsertExtensionFieldSet)
{
scenes::ExtensionFieldSetsImpl * EFS = &sEFSets;
scenes::ExtensionFieldSetsImpl testEFS1;
@@ -68,118 +76,118 @@
memset(double_size_buffer, static_cast<uint8_t>(1), sizeof(double_size_buffer));
- NL_TEST_ASSERT(aSuite, true == EFS->IsEmpty());
+ EXPECT_TRUE(EFS->IsEmpty());
// Test creators of single ExtensionFieldSet
- NL_TEST_ASSERT(aSuite, EFS1.mID == kOnOffClusterId);
- NL_TEST_ASSERT(aSuite, EFS1.mUsedBytes == kOnOffSize);
- NL_TEST_ASSERT(aSuite, !memcmp(onOffBuffer, EFS1.mBytesBuffer, EFS1.mUsedBytes));
+ EXPECT_EQ(EFS1.mID, kOnOffClusterId);
+ EXPECT_EQ(EFS1.mUsedBytes, kOnOffSize);
+ EXPECT_EQ(memcmp(onOffBuffer, EFS1.mBytesBuffer, EFS1.mUsedBytes), 0);
- NL_TEST_ASSERT(aSuite, EFS2.mID == kLevelControlClusterId);
- NL_TEST_ASSERT(aSuite, EFS2.mUsedBytes == kLevelControlSize);
- NL_TEST_ASSERT(aSuite, !memcmp(levelControlBuffer, EFS2.mBytesBuffer, EFS2.mUsedBytes));
+ EXPECT_EQ(EFS2.mID, kLevelControlClusterId);
+ EXPECT_EQ(EFS2.mUsedBytes, kLevelControlSize);
+ EXPECT_EQ(memcmp(levelControlBuffer, EFS2.mBytesBuffer, EFS2.mUsedBytes), 0);
- NL_TEST_ASSERT(aSuite, EFS3.mID == kColorControlClusterId);
- NL_TEST_ASSERT(aSuite, EFS3.mUsedBytes == kColorControlSize);
- NL_TEST_ASSERT(aSuite, !memcmp(colorControlBuffer, EFS3.mBytesBuffer, EFS3.mUsedBytes));
+ EXPECT_EQ(EFS3.mID, kColorControlClusterId);
+ EXPECT_EQ(EFS3.mUsedBytes, kColorControlSize);
+ EXPECT_EQ(memcmp(colorControlBuffer, EFS3.mBytesBuffer, EFS3.mUsedBytes), 0);
// operator tests single EFS
tempEFS = EFS1;
- NL_TEST_ASSERT(aSuite, tempEFS == EFS1);
+ EXPECT_EQ(tempEFS, EFS1);
tempEFS = EFS2;
- NL_TEST_ASSERT(aSuite, tempEFS == EFS2);
+ EXPECT_EQ(tempEFS, EFS2);
tempEFS = EFS3;
- NL_TEST_ASSERT(aSuite, tempEFS == EFS3);
+ EXPECT_EQ(tempEFS, EFS3);
// Test clear EFS
tempEFS.Clear();
- NL_TEST_ASSERT(aSuite, tempEFS.IsEmpty());
- NL_TEST_ASSERT(aSuite, tempEFS.mID == kInvalidClusterId);
- NL_TEST_ASSERT(aSuite, tempEFS.mUsedBytes == 0);
- NL_TEST_ASSERT(aSuite, !memcmp(empty_buffer, tempEFS.mBytesBuffer, sizeof(tempEFS.mBytesBuffer)));
+ EXPECT_TRUE(tempEFS.IsEmpty());
+ EXPECT_EQ(tempEFS.mID, kInvalidClusterId);
+ EXPECT_EQ(tempEFS.mUsedBytes, 0);
+ EXPECT_EQ(memcmp(empty_buffer, tempEFS.mBytesBuffer, sizeof(tempEFS.mBytesBuffer)), 0);
// Test creation of EFS from Array and ByteSpan that are to big
tempEFS = scenes::ExtensionFieldSet(kOnOffClusterId, double_size_buffer, sizeof(double_size_buffer));
- NL_TEST_ASSERT(aSuite, tempEFS.mID == kOnOffClusterId);
+ EXPECT_EQ(tempEFS.mID, kOnOffClusterId);
// Confirm EFS empty
- NL_TEST_ASSERT(aSuite, tempEFS.mUsedBytes == 0);
- NL_TEST_ASSERT(aSuite, !memcmp(empty_buffer, tempEFS.mBytesBuffer, sizeof(empty_buffer)));
+ EXPECT_EQ(tempEFS.mUsedBytes, 0);
+ EXPECT_EQ(memcmp(empty_buffer, tempEFS.mBytesBuffer, sizeof(empty_buffer)), 0);
tempEFS = scenes::ExtensionFieldSet(kLevelControlClusterId, bufferSpan);
- NL_TEST_ASSERT(aSuite, tempEFS.mID == kLevelControlClusterId);
+ EXPECT_EQ(tempEFS.mID, kLevelControlClusterId);
// Confirm EFS empty
- NL_TEST_ASSERT(aSuite, tempEFS.mUsedBytes == 0);
- NL_TEST_ASSERT(aSuite, !memcmp(empty_buffer, tempEFS.mBytesBuffer, sizeof(empty_buffer)));
+ EXPECT_EQ(tempEFS.mUsedBytes, 0);
+ EXPECT_EQ(memcmp(empty_buffer, tempEFS.mBytesBuffer, sizeof(empty_buffer)), 0);
// Test creation of EFS from truncating an Array
tempEFS = scenes::ExtensionFieldSet(kColorControlClusterId, double_size_buffer, sizeof(tempEFS.mBytesBuffer));
- NL_TEST_ASSERT(aSuite, tempEFS.mID == kColorControlClusterId);
+ EXPECT_EQ(tempEFS.mID, kColorControlClusterId);
// Confirm EFS was written
- NL_TEST_ASSERT(aSuite, tempEFS.mUsedBytes == static_cast<uint8_t>(sizeof(tempEFS.mBytesBuffer)));
- NL_TEST_ASSERT(aSuite, !memcmp(double_size_buffer, tempEFS.mBytesBuffer, sizeof(tempEFS.mBytesBuffer)));
+ EXPECT_EQ(tempEFS.mUsedBytes, static_cast<uint8_t>(sizeof(tempEFS.mBytesBuffer)));
+ EXPECT_EQ(memcmp(double_size_buffer, tempEFS.mBytesBuffer, sizeof(tempEFS.mBytesBuffer)), 0);
tempEFS.Clear();
- NL_TEST_ASSERT(aSuite, tempEFS.IsEmpty());
+ EXPECT_TRUE(tempEFS.IsEmpty());
// Test insertion of uninitialized EFS
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_INVALID_ARGUMENT == EFS->InsertFieldSet(tempEFS));
- NL_TEST_ASSERT(aSuite, 0 == EFS->GetFieldSetCount());
+ EXPECT_EQ(CHIP_ERROR_INVALID_ARGUMENT, EFS->InsertFieldSet(tempEFS));
+ EXPECT_EQ(0, EFS->GetFieldSetCount());
// Test insertion of empty EFS
tempEFS.mID = kOnOffClusterId;
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_INVALID_ARGUMENT == EFS->InsertFieldSet(tempEFS));
- NL_TEST_ASSERT(aSuite, 0 == EFS->GetFieldSetCount());
+ EXPECT_EQ(CHIP_ERROR_INVALID_ARGUMENT, EFS->InsertFieldSet(tempEFS));
+ EXPECT_EQ(0, EFS->GetFieldSetCount());
// test operators on multiple EFS struct
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == testEFS1.InsertFieldSet(EFS1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == testEFS1.InsertFieldSet(EFS2));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == testEFS1.InsertFieldSet(EFS3));
+ EXPECT_EQ(CHIP_NO_ERROR, testEFS1.InsertFieldSet(EFS1));
+ EXPECT_EQ(CHIP_NO_ERROR, testEFS1.InsertFieldSet(EFS2));
+ EXPECT_EQ(CHIP_NO_ERROR, testEFS1.InsertFieldSet(EFS3));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == testEFS2.InsertFieldSet(EFS3));
+ EXPECT_EQ(CHIP_NO_ERROR, testEFS2.InsertFieldSet(EFS3));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == testEFS3.InsertFieldSet(EFS1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == testEFS3.InsertFieldSet(EFS2));
+ EXPECT_EQ(CHIP_NO_ERROR, testEFS3.InsertFieldSet(EFS1));
+ EXPECT_EQ(CHIP_NO_ERROR, testEFS3.InsertFieldSet(EFS2));
tempTestEFS = testEFS1;
- NL_TEST_ASSERT(aSuite, tempTestEFS == testEFS1);
- NL_TEST_ASSERT(aSuite, !(tempTestEFS == testEFS2));
- NL_TEST_ASSERT(aSuite, !(tempTestEFS == testEFS3));
+ EXPECT_EQ(tempTestEFS, testEFS1);
+ EXPECT_FALSE(tempTestEFS == testEFS2);
+ EXPECT_FALSE(tempTestEFS == testEFS3);
tempTestEFS = testEFS2;
- NL_TEST_ASSERT(aSuite, tempTestEFS == testEFS2);
- NL_TEST_ASSERT(aSuite, !(tempTestEFS == testEFS1));
- NL_TEST_ASSERT(aSuite, !(tempTestEFS == testEFS3));
+ EXPECT_EQ(tempTestEFS, testEFS2);
+ EXPECT_FALSE(tempTestEFS == testEFS1);
+ EXPECT_FALSE(tempTestEFS == testEFS3);
tempTestEFS = testEFS3;
- NL_TEST_ASSERT(aSuite, tempTestEFS == testEFS3);
- NL_TEST_ASSERT(aSuite, !(tempTestEFS == testEFS1));
- NL_TEST_ASSERT(aSuite, !(tempTestEFS == testEFS2));
+ EXPECT_EQ(tempTestEFS, testEFS3);
+ EXPECT_FALSE(tempTestEFS == testEFS1);
+ EXPECT_FALSE(tempTestEFS == testEFS2);
// test clear multipler efs struct
tempTestEFS.Clear();
- NL_TEST_ASSERT(aSuite, tempTestEFS.IsEmpty());
- NL_TEST_ASSERT(aSuite, 0 == tempTestEFS.GetFieldSetCount());
+ EXPECT_TRUE(tempTestEFS.IsEmpty());
+ EXPECT_EQ(0, tempTestEFS.GetFieldSetCount());
// Test insert
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->InsertFieldSet(EFS1));
- NL_TEST_ASSERT(aSuite, 1 == EFS->GetFieldSetCount());
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->InsertFieldSet(EFS1));
+ EXPECT_EQ(1, EFS->GetFieldSetCount());
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->InsertFieldSet(EFS2));
- NL_TEST_ASSERT(aSuite, 2 == EFS->GetFieldSetCount());
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->InsertFieldSet(EFS2));
+ EXPECT_EQ(2, EFS->GetFieldSetCount());
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->InsertFieldSet(EFS3));
- NL_TEST_ASSERT(aSuite, 3 == EFS->GetFieldSetCount());
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->InsertFieldSet(EFS3));
+ EXPECT_EQ(3, EFS->GetFieldSetCount());
// Test get
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->GetFieldSetAtPosition(tempEFS, 0));
- NL_TEST_ASSERT(aSuite, tempEFS == EFS1);
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->GetFieldSetAtPosition(tempEFS, 0));
+ EXPECT_EQ(tempEFS, EFS1);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->GetFieldSetAtPosition(tempEFS, 1));
- NL_TEST_ASSERT(aSuite, tempEFS == EFS2);
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->GetFieldSetAtPosition(tempEFS, 1));
+ EXPECT_EQ(tempEFS, EFS2);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->GetFieldSetAtPosition(tempEFS, 2));
- NL_TEST_ASSERT(aSuite, tempEFS == EFS3);
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->GetFieldSetAtPosition(tempEFS, 2));
+ EXPECT_EQ(tempEFS, EFS3);
}
-void TestSerializeDerializeExtensionFieldSet(nlTestSuite * aSuite, void * aContext)
+TEST_F(TestExtensionFieldSets, TestSerializeDerializeExtensionFieldSet)
{
scenes::ExtensionFieldSetsImpl * EFS = &sEFSets;
scenes::ExtensionFieldSetsImpl testSceneEFS;
@@ -203,148 +211,105 @@
// Individual Field Sets serialize / deserialize
writer.Init(EFS1Buffer);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS1.Serialize(writer));
+ EXPECT_EQ(CHIP_NO_ERROR, EFS1.Serialize(writer));
EFS1_serialized_length = writer.GetLengthWritten();
- NL_TEST_ASSERT(aSuite, EFS1_serialized_length <= scenes::kMaxFieldBytesPerCluster);
+ EXPECT_LE(EFS1_serialized_length, scenes::kMaxFieldBytesPerCluster);
writer.Init(EFS2Buffer);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS2.Serialize(writer));
+ EXPECT_EQ(CHIP_NO_ERROR, EFS2.Serialize(writer));
EFS2_serialized_length = writer.GetLengthWritten();
- NL_TEST_ASSERT(aSuite, EFS2_serialized_length <= scenes::kMaxFieldBytesPerCluster);
+ EXPECT_LE(EFS2_serialized_length, scenes::kMaxFieldBytesPerCluster);
writer.Init(EFS3Buffer);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS3.Serialize(writer));
+ EXPECT_EQ(CHIP_NO_ERROR, EFS3.Serialize(writer));
EFS3_serialized_length = writer.GetLengthWritten();
- NL_TEST_ASSERT(aSuite, EFS3_serialized_length <= scenes::kMaxFieldBytesPerCluster);
+ EXPECT_LE(EFS3_serialized_length, scenes::kMaxFieldBytesPerCluster);
reader.Init(EFS1Buffer);
reader.Next(TLV::AnonymousTag());
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == tempEFS.Deserialize(reader));
- NL_TEST_ASSERT(aSuite, EFS1 == tempEFS);
+ EXPECT_EQ(CHIP_NO_ERROR, tempEFS.Deserialize(reader));
+ EXPECT_EQ(EFS1, tempEFS);
reader.Init(EFS2Buffer);
reader.Next(TLV::AnonymousTag());
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == tempEFS.Deserialize(reader));
- NL_TEST_ASSERT(aSuite, EFS2 == tempEFS);
+ EXPECT_EQ(CHIP_NO_ERROR, tempEFS.Deserialize(reader));
+ EXPECT_EQ(EFS2, tempEFS);
reader.Init(EFS3Buffer);
reader.Next(TLV::AnonymousTag());
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == tempEFS.Deserialize(reader));
- NL_TEST_ASSERT(aSuite, EFS3 == tempEFS);
+ EXPECT_EQ(CHIP_NO_ERROR, tempEFS.Deserialize(reader));
+ EXPECT_EQ(EFS3, tempEFS);
// All ExtensionFieldSets serialize / deserialize
writer.Init(sceneEFSBuffer);
writer.StartContainer(TLV::AnonymousTag(), TLV::kTLVType_Structure, outer);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->Serialize(writer));
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->Serialize(writer));
writer.EndContainer(outer);
sceneEFS_serialized_length = writer.GetLengthWritten();
- NL_TEST_ASSERT(aSuite, sceneEFS_serialized_length <= kPersistentSceneBufferMax);
+ EXPECT_LE(sceneEFS_serialized_length, kPersistentSceneBufferMax);
reader.Init(sceneEFSBuffer);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == reader.Next());
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == reader.EnterContainer(outerRead));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == testSceneEFS.Deserialize(reader));
+ EXPECT_EQ(CHIP_NO_ERROR, reader.Next());
+ EXPECT_EQ(CHIP_NO_ERROR, reader.EnterContainer(outerRead));
+ EXPECT_EQ(CHIP_NO_ERROR, testSceneEFS.Deserialize(reader));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == reader.ExitContainer(outerRead));
- NL_TEST_ASSERT(aSuite, *EFS == testSceneEFS);
+ EXPECT_EQ(CHIP_NO_ERROR, reader.ExitContainer(outerRead));
+ EXPECT_EQ(*EFS, testSceneEFS);
}
-void TestRemoveExtensionFieldSet(nlTestSuite * aSuite, void * aContext)
+TEST_F(TestExtensionFieldSets, TestRemoveExtensionFieldSet)
{
scenes::ExtensionFieldSetsImpl * EFS = &sEFSets;
scenes::ExtensionFieldSet tempEFS;
// Order in EFS at this point: [EFS1, EFS2, EFS3]
// Removal at beginning
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->RemoveFieldAtPosition(0));
- NL_TEST_ASSERT(aSuite, 2 == EFS->GetFieldSetCount());
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->InsertFieldSet(EFS1));
- NL_TEST_ASSERT(aSuite, 3 == EFS->GetFieldSetCount());
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->RemoveFieldAtPosition(0));
+ EXPECT_EQ(2, EFS->GetFieldSetCount());
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->InsertFieldSet(EFS1));
+ EXPECT_EQ(3, EFS->GetFieldSetCount());
// Verify order
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->GetFieldSetAtPosition(tempEFS, 0));
- NL_TEST_ASSERT(aSuite, tempEFS == EFS2);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->GetFieldSetAtPosition(tempEFS, 1));
- NL_TEST_ASSERT(aSuite, tempEFS == EFS3);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->GetFieldSetAtPosition(tempEFS, 2));
- NL_TEST_ASSERT(aSuite, tempEFS == EFS1);
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->GetFieldSetAtPosition(tempEFS, 0));
+ EXPECT_EQ(tempEFS, EFS2);
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->GetFieldSetAtPosition(tempEFS, 1));
+ EXPECT_EQ(tempEFS, EFS3);
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->GetFieldSetAtPosition(tempEFS, 2));
+ EXPECT_EQ(tempEFS, EFS1);
// Order in EFS at this point: [EFS2, EFS3, EFS1]
// Removal at middle
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->RemoveFieldAtPosition(1));
- NL_TEST_ASSERT(aSuite, 2 == EFS->GetFieldSetCount());
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->InsertFieldSet(EFS3));
- NL_TEST_ASSERT(aSuite, 3 == EFS->GetFieldSetCount());
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->RemoveFieldAtPosition(1));
+ EXPECT_EQ(2, EFS->GetFieldSetCount());
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->InsertFieldSet(EFS3));
+ EXPECT_EQ(3, EFS->GetFieldSetCount());
// Verify order
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->GetFieldSetAtPosition(tempEFS, 0));
- NL_TEST_ASSERT(aSuite, tempEFS == EFS2);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->GetFieldSetAtPosition(tempEFS, 1));
- NL_TEST_ASSERT(aSuite, tempEFS == EFS1);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->GetFieldSetAtPosition(tempEFS, 2));
- NL_TEST_ASSERT(aSuite, tempEFS == EFS3);
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->GetFieldSetAtPosition(tempEFS, 0));
+ EXPECT_EQ(tempEFS, EFS2);
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->GetFieldSetAtPosition(tempEFS, 1));
+ EXPECT_EQ(tempEFS, EFS1);
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->GetFieldSetAtPosition(tempEFS, 2));
+ EXPECT_EQ(tempEFS, EFS3);
// Order in EFS at this point: [EFS2, EFS1, EFS3]
// Removal at end
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->RemoveFieldAtPosition(2));
- NL_TEST_ASSERT(aSuite, 2 == EFS->GetFieldSetCount());
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->InsertFieldSet(EFS3));
- NL_TEST_ASSERT(aSuite, 3 == EFS->GetFieldSetCount());
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->RemoveFieldAtPosition(2));
+ EXPECT_EQ(2, EFS->GetFieldSetCount());
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->InsertFieldSet(EFS3));
+ EXPECT_EQ(3, EFS->GetFieldSetCount());
// Verify order
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->GetFieldSetAtPosition(tempEFS, 0));
- NL_TEST_ASSERT(aSuite, tempEFS == EFS2);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->GetFieldSetAtPosition(tempEFS, 1));
- NL_TEST_ASSERT(aSuite, tempEFS == EFS1);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == EFS->GetFieldSetAtPosition(tempEFS, 2));
- NL_TEST_ASSERT(aSuite, tempEFS == EFS3);
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->GetFieldSetAtPosition(tempEFS, 0));
+ EXPECT_EQ(tempEFS, EFS2);
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->GetFieldSetAtPosition(tempEFS, 1));
+ EXPECT_EQ(tempEFS, EFS1);
+ EXPECT_EQ(CHIP_NO_ERROR, EFS->GetFieldSetAtPosition(tempEFS, 2));
+ EXPECT_EQ(tempEFS, EFS3);
// Emptying the table
EFS->Clear();
- NL_TEST_ASSERT(aSuite, true == EFS->IsEmpty());
+ EXPECT_TRUE(EFS->IsEmpty());
}
} // namespace TestEFS
-/**
- * Tear down the test suite.
- */
-int TestSetup(void * inContext)
-{
- VerifyOrReturnError(CHIP_NO_ERROR == chip::Platform::MemoryInit(), FAILURE);
-
- return SUCCESS;
-}
-
-namespace {
-/**
- * Setup the test suite.
- */
-int TestTeardown(void * inContext)
-{
- chip::Platform::MemoryShutdown();
-
- return SUCCESS;
-}
-} // namespace
-
-int TestExtensionFieldSets()
-{
- static nlTest sTests[] = { NL_TEST_DEF("TestInsertExtensionFieldSet", TestEFS::TestInsertExtensionFieldSet),
- NL_TEST_DEF("TestSerializeDerializeExtensionFieldSet",
- TestEFS::TestSerializeDerializeExtensionFieldSet),
- NL_TEST_DEF("TestRemoveExtensionFieldSet", TestEFS::TestRemoveExtensionFieldSet),
-
- NL_TEST_SENTINEL() };
-
- nlTestSuite theSuite = {
- "SceneTable",
- &sTests[0],
- TestSetup,
- TestTeardown,
- };
-
- nlTestRunner(&theSuite, nullptr);
- return (nlTestRunnerStats(&theSuite));
-}
-
-CHIP_REGISTER_TEST_SUITE(TestExtensionFieldSets)
diff --git a/src/app/tests/TestSceneTable.cpp b/src/app/tests/TestSceneTable.cpp
index 1ce2583..1563c28 100644
--- a/src/app/tests/TestSceneTable.cpp
+++ b/src/app/tests/TestSceneTable.cpp
@@ -22,9 +22,9 @@
#include <lib/core/TLV.h>
#include <lib/support/Span.h>
#include <lib/support/TestPersistentStorageDelegate.h>
-#include <lib/support/UnitTestRegistration.h>
-#include <nlunit-test.h>
+#include <lib/core/StringBuilderAdapters.h>
+#include <pw_unit_test/framework.h>
using namespace chip;
using SceneTable = scenes::SceneTable<scenes::ExtensionFieldSetsImpl>;
@@ -425,10 +425,42 @@
uint8_t GetClusterCountFromEndpoint() override { return 3; }
};
-// Storage
-static chip::TestPersistentStorageDelegate testStorage;
-// Scene
-static TestSceneHandler sHandler;
+// Test Fixture Class
+class TestSceneTable : public ::testing::Test
+{
+public:
+ static void SetUpTestSuite()
+ {
+ mpTestStorage = new chip::TestPersistentStorageDelegate;
+ mpSceneHandler = new TestSceneHandler;
+
+ ASSERT_EQ(chip::Platform::MemoryInit(), CHIP_NO_ERROR);
+
+ // Initialize Scene Table
+ SceneTable * sceneTable = scenes::GetSceneTableImpl();
+ ASSERT_NE(sceneTable, nullptr);
+ ASSERT_EQ(sceneTable->Init(mpTestStorage), CHIP_NO_ERROR);
+ }
+
+ static void TearDownTestSuite()
+ {
+ // Terminate Scene Table
+ SceneTable * sceneTable = scenes::GetSceneTableImpl();
+ ASSERT_NE(sceneTable, nullptr);
+ sceneTable->Finish();
+ delete mpTestStorage;
+ delete mpSceneHandler;
+ chip::Platform::MemoryShutdown();
+ }
+
+ // Storage
+ static chip::TestPersistentStorageDelegate * mpTestStorage;
+ // Scene
+ static TestSceneHandler * mpSceneHandler;
+};
+
+chip::TestPersistentStorageDelegate * TestSceneTable::mpTestStorage = nullptr;
+TestSceneHandler * TestSceneTable::mpSceneHandler = nullptr;
void ResetSceneTable(SceneTable * sceneTable)
{
@@ -437,11 +469,10 @@
sceneTable->RemoveFabric(kFabric3);
}
-void TestHandlerRegistration(nlTestSuite * aSuite, void * aContext)
+TEST_F(TestSceneTable, TestHandlerRegistration)
{
SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
+ ASSERT_NE(nullptr, sceneTable);
TestSceneHandler tmpHandler[scenes::kMaxClustersPerScene];
for (uint8_t i = 0; i < scenes::kMaxClustersPerScene; i++)
@@ -453,7 +484,7 @@
sceneTable->UnregisterAllHandlers();
// Verify the handler num has been updated properly
- NL_TEST_ASSERT(aSuite, sceneTable->HandlerListEmpty());
+ EXPECT_TRUE(sceneTable->HandlerListEmpty());
for (uint8_t i = 0; i < scenes::kMaxClustersPerScene; i++)
{
@@ -462,40 +493,38 @@
// Hanlder order in table : [H0, H1, H2]
- NL_TEST_ASSERT(aSuite, !sceneTable->HandlerListEmpty());
+ EXPECT_FALSE(sceneTable->HandlerListEmpty());
// Removal at beginning
sceneTable->UnregisterHandler(&tmpHandler[0]);
- NL_TEST_ASSERT(aSuite, !sceneTable->HandlerListEmpty());
+ EXPECT_FALSE(sceneTable->HandlerListEmpty());
// Re-insert
sceneTable->RegisterHandler(&tmpHandler[0]);
- NL_TEST_ASSERT(aSuite, !sceneTable->HandlerListEmpty());
+ EXPECT_FALSE(sceneTable->HandlerListEmpty());
// Hanlder order in table : [H0, H1, H2]
// Removal at the middle
sceneTable->UnregisterHandler(&tmpHandler[2]);
- NL_TEST_ASSERT(aSuite, !sceneTable->HandlerListEmpty());
+ EXPECT_FALSE(sceneTable->HandlerListEmpty());
// Re-insert
sceneTable->RegisterHandler(&tmpHandler[2]);
- NL_TEST_ASSERT(aSuite, !sceneTable->HandlerListEmpty());
+ EXPECT_FALSE(sceneTable->HandlerListEmpty());
// Hanlder order in table : [H1, H0, H2]
// Removal at the end
sceneTable->UnregisterHandler(&tmpHandler[2]);
- NL_TEST_ASSERT(aSuite, !sceneTable->HandlerListEmpty());
+ EXPECT_FALSE(sceneTable->HandlerListEmpty());
// Emptying Handler array
sceneTable->UnregisterAllHandlers();
// Verify the handler num has been updated properly
- NL_TEST_ASSERT(aSuite, sceneTable->HandlerListEmpty());
+ EXPECT_TRUE(sceneTable->HandlerListEmpty());
}
-void TestHandlerFunctions(nlTestSuite * aSuite, void * aContext)
+TEST_F(TestSceneTable, TestHandlerFunctions)
{
SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
-
+ ASSERT_NE(nullptr, sceneTable);
app::Clusters::ScenesManagement::Structs::ExtensionFieldSet::Type extensionFieldSetOut;
app::Clusters::ScenesManagement::Structs::ExtensionFieldSet::DecodableType extensionFieldSetIn;
@@ -548,99 +577,91 @@
// Serialize Extension Field sets as if they were recovered from memory
writer.Init(OO_buffer);
- NL_TEST_ASSERT(aSuite,
- CHIP_NO_ERROR == app::DataModel::Encode(writer, TLV::AnonymousTag(), OOextensionFieldSet.attributeValueList));
+ EXPECT_EQ(CHIP_NO_ERROR, app::DataModel::Encode(writer, TLV::AnonymousTag(), OOextensionFieldSet.attributeValueList));
OO_buffer_serialized_length = writer.GetLengthWritten();
writer.Init(LC_buffer);
- NL_TEST_ASSERT(aSuite,
- CHIP_NO_ERROR == app::DataModel::Encode(writer, TLV::AnonymousTag(), LCextensionFieldSet.attributeValueList));
+ EXPECT_EQ(CHIP_NO_ERROR, app::DataModel::Encode(writer, TLV::AnonymousTag(), LCextensionFieldSet.attributeValueList));
LC_buffer_serialized_length = writer.GetLengthWritten();
writer.Init(CC_buffer);
- NL_TEST_ASSERT(aSuite,
- CHIP_NO_ERROR == app::DataModel::Encode(writer, TLV::AnonymousTag(), CCextensionFieldSet.attributeValueList));
+ EXPECT_EQ(CHIP_NO_ERROR, app::DataModel::Encode(writer, TLV::AnonymousTag(), CCextensionFieldSet.attributeValueList));
CC_buffer_serialized_length = writer.GetLengthWritten();
// Test Registering SceneHandler
- sceneTable->RegisterHandler(&sHandler);
- NL_TEST_ASSERT(aSuite, !sceneTable->HandlerListEmpty());
+ sceneTable->RegisterHandler(mpSceneHandler);
+ EXPECT_FALSE(sceneTable->HandlerListEmpty());
// Setup the On Off Extension field set in the expected state from a command
reader.Init(OO_list);
extensionFieldSetIn.clusterID = kOnOffClusterId;
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == reader.Next());
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == extensionFieldSetIn.attributeValueList.Decode(reader));
+ EXPECT_EQ(CHIP_NO_ERROR, reader.Next());
+ EXPECT_EQ(CHIP_NO_ERROR, extensionFieldSetIn.attributeValueList.Decode(reader));
- NL_TEST_ASSERT(aSuite, sHandler.SupportsCluster(kTestEndpoint1, extensionFieldSetIn.clusterID));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sHandler.SerializeAdd(kTestEndpoint1, extensionFieldSetIn, buff_span));
+ EXPECT_TRUE(mpSceneHandler->SupportsCluster(kTestEndpoint1, extensionFieldSetIn.clusterID));
+ EXPECT_EQ(CHIP_NO_ERROR, mpSceneHandler->SerializeAdd(kTestEndpoint1, extensionFieldSetIn, buff_span));
// Verify the handler extracted buffer matches the initial field sets
- NL_TEST_ASSERT(aSuite, 0 == memcmp(OO_list.data(), buff_span.data(), buff_span.size()));
+ EXPECT_EQ(0, memcmp(OO_list.data(), buff_span.data(), buff_span.size()));
memset(buffer, 0, buff_span.size());
buff_span = MutableByteSpan(buffer);
// Setup the Level Control Extension field set in the expected state from a command
reader.Init(LC_list);
extensionFieldSetIn.clusterID = kLevelControlClusterId;
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == reader.Next());
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == extensionFieldSetIn.attributeValueList.Decode(reader));
+ EXPECT_EQ(CHIP_NO_ERROR, reader.Next());
+ EXPECT_EQ(CHIP_NO_ERROR, extensionFieldSetIn.attributeValueList.Decode(reader));
- NL_TEST_ASSERT(aSuite, sHandler.SupportsCluster(kTestEndpoint1, extensionFieldSetIn.clusterID));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sHandler.SerializeAdd(kTestEndpoint1, extensionFieldSetIn, buff_span));
+ EXPECT_TRUE(mpSceneHandler->SupportsCluster(kTestEndpoint1, extensionFieldSetIn.clusterID));
+ EXPECT_EQ(CHIP_NO_ERROR, mpSceneHandler->SerializeAdd(kTestEndpoint1, extensionFieldSetIn, buff_span));
// Verify the handler extracted buffer matches the initial field sets
- NL_TEST_ASSERT(aSuite, 0 == memcmp(LC_list.data(), buff_span.data(), buff_span.size()));
+ EXPECT_EQ(0, memcmp(LC_list.data(), buff_span.data(), buff_span.size()));
memset(buffer, 0, buff_span.size());
buff_span = MutableByteSpan(buffer);
// Setup the Color control Extension field set in the expected state from a command
reader.Init(CC_list);
extensionFieldSetIn.clusterID = kColorControlClusterId;
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == reader.Next());
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == extensionFieldSetIn.attributeValueList.Decode(reader));
+ EXPECT_EQ(CHIP_NO_ERROR, reader.Next());
+ EXPECT_EQ(CHIP_NO_ERROR, extensionFieldSetIn.attributeValueList.Decode(reader));
- NL_TEST_ASSERT(aSuite, sHandler.SupportsCluster(kTestEndpoint1, extensionFieldSetIn.clusterID));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sHandler.SerializeAdd(kTestEndpoint1, extensionFieldSetIn, buff_span));
+ EXPECT_TRUE(mpSceneHandler->SupportsCluster(kTestEndpoint1, extensionFieldSetIn.clusterID));
+ EXPECT_EQ(CHIP_NO_ERROR, mpSceneHandler->SerializeAdd(kTestEndpoint1, extensionFieldSetIn, buff_span));
// Verify the handler extracted buffer matches the initial field sets
- NL_TEST_ASSERT(aSuite, 0 == memcmp(CC_list.data(), buff_span.data(), buff_span.size()));
+ EXPECT_EQ(0, memcmp(CC_list.data(), buff_span.data(), buff_span.size()));
memset(buffer, 0, buff_span.size());
buff_span = MutableByteSpan(buffer);
// Verify Deserializing is properly filling out output extension field set for on off
- NL_TEST_ASSERT(aSuite, sHandler.SupportsCluster(kTestEndpoint1, kOnOffClusterId));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sHandler.Deserialize(kTestEndpoint1, kOnOffClusterId, OO_list, extensionFieldSetOut));
+ EXPECT_TRUE(mpSceneHandler->SupportsCluster(kTestEndpoint1, kOnOffClusterId));
+ EXPECT_EQ(CHIP_NO_ERROR, mpSceneHandler->Deserialize(kTestEndpoint1, kOnOffClusterId, OO_list, extensionFieldSetOut));
// Verify Encoding the Extension field set returns the same data as the one serialized for on off previously
writer.Init(buff_span);
- NL_TEST_ASSERT(aSuite,
- CHIP_NO_ERROR == app::DataModel::Encode(writer, TLV::AnonymousTag(), extensionFieldSetOut.attributeValueList));
- NL_TEST_ASSERT(aSuite, 0 == memcmp(OO_list.data(), buff_span.data(), buff_span.size()));
+ EXPECT_EQ(CHIP_NO_ERROR, app::DataModel::Encode(writer, TLV::AnonymousTag(), extensionFieldSetOut.attributeValueList));
+ EXPECT_EQ(0, memcmp(OO_list.data(), buff_span.data(), buff_span.size()));
memset(buffer, 0, buff_span.size());
// Verify Deserializing is properly filling out output extension field set for level control
- NL_TEST_ASSERT(aSuite, sHandler.SupportsCluster(kTestEndpoint1, kLevelControlClusterId));
- NL_TEST_ASSERT(aSuite,
- CHIP_NO_ERROR == sHandler.Deserialize(kTestEndpoint1, kLevelControlClusterId, LC_list, extensionFieldSetOut));
+ EXPECT_TRUE(mpSceneHandler->SupportsCluster(kTestEndpoint1, kLevelControlClusterId));
+ EXPECT_EQ(CHIP_NO_ERROR, mpSceneHandler->Deserialize(kTestEndpoint1, kLevelControlClusterId, LC_list, extensionFieldSetOut));
// Verify Encoding the Extension field set returns the same data as the one serialized for level control previously
writer.Init(buff_span);
- NL_TEST_ASSERT(aSuite,
- CHIP_NO_ERROR == app::DataModel::Encode(writer, TLV::AnonymousTag(), extensionFieldSetOut.attributeValueList));
- NL_TEST_ASSERT(aSuite, 0 == memcmp(LC_list.data(), buff_span.data(), buff_span.size()));
+ EXPECT_EQ(CHIP_NO_ERROR, app::DataModel::Encode(writer, TLV::AnonymousTag(), extensionFieldSetOut.attributeValueList));
+ EXPECT_EQ(0, memcmp(LC_list.data(), buff_span.data(), buff_span.size()));
memset(buffer, 0, buff_span.size());
// Verify Deserializing is properly filling out output extension field set for color control
- NL_TEST_ASSERT(aSuite, sHandler.SupportsCluster(kTestEndpoint1, kColorControlClusterId));
- NL_TEST_ASSERT(aSuite,
- CHIP_NO_ERROR == sHandler.Deserialize(kTestEndpoint1, kColorControlClusterId, CC_list, extensionFieldSetOut));
+ EXPECT_TRUE(mpSceneHandler->SupportsCluster(kTestEndpoint1, kColorControlClusterId));
+ EXPECT_EQ(CHIP_NO_ERROR, mpSceneHandler->Deserialize(kTestEndpoint1, kColorControlClusterId, CC_list, extensionFieldSetOut));
// Verify Encoding the Extension field set returns the same data as the one serialized for color control previously
writer.Init(buff_span);
- NL_TEST_ASSERT(aSuite,
- CHIP_NO_ERROR == app::DataModel::Encode(writer, TLV::AnonymousTag(), extensionFieldSetOut.attributeValueList));
- NL_TEST_ASSERT(aSuite, 0 == memcmp(CC_list.data(), buff_span.data(), buff_span.size()));
+ EXPECT_EQ(CHIP_NO_ERROR, app::DataModel::Encode(writer, TLV::AnonymousTag(), extensionFieldSetOut.attributeValueList));
+ EXPECT_EQ(0, memcmp(CC_list.data(), buff_span.data(), buff_span.size()));
memset(buffer, 0, buff_span.size());
// To test failure on serialize and deserialize when too many pairs are in the field sets
@@ -663,52 +684,46 @@
// Serialize Extension Field sets as if they were recovered from memory
writer.Init(failBuffer);
- NL_TEST_ASSERT(
- aSuite, CHIP_NO_ERROR == app::DataModel::Encode(writer, TLV::AnonymousTag(), extensionFieldFailTestOut.attributeValueList));
+ EXPECT_EQ(CHIP_NO_ERROR, app::DataModel::Encode(writer, TLV::AnonymousTag(), extensionFieldFailTestOut.attributeValueList));
// Setup the On Off Extension field set in the expected state from a command
reader.Init(fail_list);
extensionFieldFailTestIn.clusterID = kColorControlClusterId;
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == reader.Next());
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == extensionFieldFailTestIn.attributeValueList.Decode(reader));
+ EXPECT_EQ(CHIP_NO_ERROR, reader.Next());
+ EXPECT_EQ(CHIP_NO_ERROR, extensionFieldFailTestIn.attributeValueList.Decode(reader));
// Verify failure on both serialize and deserialize
- NL_TEST_ASSERT(aSuite,
- CHIP_ERROR_BUFFER_TOO_SMALL == sHandler.SerializeAdd(kTestEndpoint1, extensionFieldFailTestIn, buff_span));
- NL_TEST_ASSERT(aSuite,
- CHIP_ERROR_BUFFER_TOO_SMALL ==
- sHandler.Deserialize(kTestEndpoint1, kColorControlClusterId, fail_list, extensionFieldFailTestOut));
+ EXPECT_EQ(CHIP_ERROR_BUFFER_TOO_SMALL, mpSceneHandler->SerializeAdd(kTestEndpoint1, extensionFieldFailTestIn, buff_span));
+ EXPECT_EQ(CHIP_ERROR_BUFFER_TOO_SMALL,
+ mpSceneHandler->Deserialize(kTestEndpoint1, kColorControlClusterId, fail_list, extensionFieldFailTestOut));
memset(failBuffer, 0, fail_list.size());
memset(buffer, 0, buff_span.size());
};
-void TestHandlerHelpers(nlTestSuite * aSuite, void * aContext) {}
-
-void TestStoreScenes(nlTestSuite * aSuite, void * aContext)
+TEST_F(TestSceneTable, TestStoreScenes)
{
SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
+ ASSERT_NE(nullptr, sceneTable);
SceneId sceneList[defaultTestFabricCapacity];
// Reset test
ResetSceneTable(sceneTable);
// Populate scene1's EFS (Endpoint1)
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SceneSaveEFS(scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SceneSaveEFS(scene1));
// Populate scene2's EFS (Endpoint1)
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SceneSaveEFS(scene2));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SceneSaveEFS(scene2));
// Populate scene3's EFS (Endpoint2)
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SceneSaveEFS(scene3));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SceneSaveEFS(scene3));
// Populate scene4's EFS (Endpoint2)
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SceneSaveEFS(scene4));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SceneSaveEFS(scene4));
// Populate scene8's EFS (Endpoint3)
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SceneSaveEFS(scene8));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SceneSaveEFS(scene8));
SceneTableEntry scene;
Span<SceneId> sceneListSpan = Span<SceneId>(sceneList);
@@ -716,272 +731,266 @@
Span<SceneId> smallListSpan = Span<SceneId>(sceneList, 1);
// Test Get All scenes in Group in empty scene table
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup1, emptyListSpan));
- NL_TEST_ASSERT(aSuite, 0 == emptyListSpan.size());
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup1, emptyListSpan));
+ EXPECT_EQ(0u, emptyListSpan.size());
// Set test
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene1));
// Test single scene in table with 0 size span
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_BUFFER_TOO_SMALL == sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup1, emptyListSpan));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup1, smallListSpan));
- NL_TEST_ASSERT(aSuite, 1 == smallListSpan.size());
+ EXPECT_EQ(CHIP_ERROR_BUFFER_TOO_SMALL, sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup1, emptyListSpan));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup1, smallListSpan));
+ EXPECT_EQ(1u, smallListSpan.size());
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene2));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene3));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene4));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene5));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene6));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene7));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene2));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene3));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene4));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene5));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene6));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene7));
// Too many scenes for 1 fabric
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NO_MEMORY == sceneTable->SetSceneTableEntry(kFabric1, scene9));
+ EXPECT_EQ(CHIP_ERROR_NO_MEMORY, sceneTable->SetSceneTableEntry(kFabric1, scene9));
// Not Found
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId9, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_BUFFER_TOO_SMALL == sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup1, emptyListSpan));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId9, scene));
+ EXPECT_EQ(CHIP_ERROR_BUFFER_TOO_SMALL, sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup1, emptyListSpan));
// Get test
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, scene == scene1);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SceneApplyEFS(scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
+ EXPECT_EQ(scene, scene1);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SceneApplyEFS(scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, scene == scene2);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SceneApplyEFS(scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
+ EXPECT_EQ(scene, scene2);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SceneApplyEFS(scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, scene == scene3);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SceneApplyEFS(scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
+ EXPECT_EQ(scene, scene3);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SceneApplyEFS(scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, scene == scene4);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SceneApplyEFS(scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
+ EXPECT_EQ(scene, scene4);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SceneApplyEFS(scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, scene == scene5);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
- NL_TEST_ASSERT(aSuite, scene == scene6);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
- NL_TEST_ASSERT(aSuite, scene == scene7);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SceneApplyEFS(scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
+ EXPECT_EQ(scene, scene5);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
+ EXPECT_EQ(scene, scene6);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
+ EXPECT_EQ(scene, scene7);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SceneApplyEFS(scene));
// Test error when list too small in a full table
// Test failure for 3 spaces in 4 scenes list
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_BUFFER_TOO_SMALL == sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup1, smallListSpan));
+ EXPECT_EQ(CHIP_ERROR_BUFFER_TOO_SMALL, sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup1, smallListSpan));
// Test failure for no space in a 4 scenes list
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_BUFFER_TOO_SMALL == sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup1, emptyListSpan));
+ EXPECT_EQ(CHIP_ERROR_BUFFER_TOO_SMALL, sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup1, emptyListSpan));
// Test failure for no space in a 1 scene list
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_BUFFER_TOO_SMALL == sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup3, emptyListSpan));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup3, smallListSpan));
- NL_TEST_ASSERT(aSuite, 1 == smallListSpan.size());
+ EXPECT_EQ(CHIP_ERROR_BUFFER_TOO_SMALL, sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup3, emptyListSpan));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup3, smallListSpan));
+ EXPECT_EQ(1u, smallListSpan.size());
// Test successfully getting Ids from various groups
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup1, sceneListSpan));
- NL_TEST_ASSERT(aSuite, 4 == sceneListSpan.size());
- NL_TEST_ASSERT(aSuite, kScene1 == sceneList[0]);
- NL_TEST_ASSERT(aSuite, kScene2 == sceneList[1]);
- NL_TEST_ASSERT(aSuite, kScene3 == sceneList[2]);
- NL_TEST_ASSERT(aSuite, kScene4 == sceneList[3]);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup1, sceneListSpan));
+ EXPECT_EQ(4u, sceneListSpan.size());
+ EXPECT_EQ(kScene1, sceneList[0]);
+ EXPECT_EQ(kScene2, sceneList[1]);
+ EXPECT_EQ(kScene3, sceneList[2]);
+ EXPECT_EQ(kScene4, sceneList[3]);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup2, sceneListSpan));
- NL_TEST_ASSERT(aSuite, 2 == sceneListSpan.size());
- NL_TEST_ASSERT(aSuite, kScene5 == sceneList[0]);
- NL_TEST_ASSERT(aSuite, kScene6 == sceneList[1]);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup2, sceneListSpan));
+ EXPECT_EQ(2u, sceneListSpan.size());
+ EXPECT_EQ(kScene5, sceneList[0]);
+ EXPECT_EQ(kScene6, sceneList[1]);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup3, sceneListSpan));
- NL_TEST_ASSERT(aSuite, 1 == sceneListSpan.size());
- NL_TEST_ASSERT(aSuite, kScene7 == sceneList[0]);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetAllSceneIdsInGroup(kFabric1, kGroup3, sceneListSpan));
+ EXPECT_EQ(1u, sceneListSpan.size());
+ EXPECT_EQ(kScene7, sceneList[0]);
uint8_t sceneCount = 0;
sceneTable->GetEndpointSceneCount(sceneCount);
sceneTable->GetFabricSceneCount(kFabric1, sceneCount);
}
-void TestOverwriteScenes(nlTestSuite * aSuite, void * aContext)
+TEST_F(TestSceneTable, TestOverwriteScenes)
{
SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
+ ASSERT_NE(nullptr, sceneTable);
uint8_t sceneCount = 0;
sceneTable->GetEndpointSceneCount(sceneCount);
sceneTable->GetFabricSceneCount(kFabric1, sceneCount);
SceneTableEntry scene;
// Overwriting the first entry
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene10));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene10));
// Overwriting in the middle
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene11));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene11));
// Overwriting the last entry
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene12));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene12));
// Scene 10 has the same sceneId as scene 1, Get->sceneId1 should thus return scene 10, etc.
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, scene == scene10);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
+ EXPECT_EQ(scene, scene10);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, scene == scene11);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
+ EXPECT_EQ(scene, scene11);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
- NL_TEST_ASSERT(aSuite, scene == scene12);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
+ EXPECT_EQ(scene, scene12);
}
-void TestIterateScenes(nlTestSuite * aSuite, void * aContext)
+TEST_F(TestSceneTable, TestIterateScenes)
{
SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
+ ASSERT_NE(nullptr, sceneTable);
SceneTableEntry scene;
auto * iterator = sceneTable->IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, iterator != nullptr);
+ ASSERT_NE(iterator, nullptr);
if (iterator)
{
- NL_TEST_ASSERT(aSuite, iterator->Count() == 7);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene10);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene2);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene3);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene4);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene11);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene6);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene12);
+ EXPECT_EQ(iterator->Count(), 7u);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene10);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene2);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene3);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene4);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene11);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene6);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene12);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene) == false);
+ EXPECT_FALSE(iterator->Next(scene));
iterator->Release();
}
}
-void TestRemoveScenes(nlTestSuite * aSuite, void * aContext)
+TEST_F(TestSceneTable, TestRemoveScenes)
{
SceneTableImpl * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
+ ASSERT_NE(nullptr, sceneTable);
SceneTableEntry scene;
// Removing non-existing entry should not return errors
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntry(kFabric1, scene9.mStorageId));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveSceneTableEntry(kFabric1, scene9.mStorageId));
// Remove middle
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntry(kFabric1, scene5.mStorageId));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveSceneTableEntry(kFabric1, scene5.mStorageId));
auto * iterator = sceneTable->IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, iterator->Count() == 6);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene10);
+ EXPECT_EQ(iterator->Count(), 6u);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene10);
iterator->Release();
// Add scene in middle, a spot should have been freed
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene9));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene9));
iterator = sceneTable->IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, iterator->Count() == 7);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId9, scene));
- NL_TEST_ASSERT(aSuite, scene == scene9);
+ EXPECT_EQ(iterator->Count(), 7u);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId9, scene));
+ EXPECT_EQ(scene, scene9);
iterator->Release();
// Remove the recently added scene 9
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntry(kFabric1, scene9.mStorageId));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveSceneTableEntry(kFabric1, scene9.mStorageId));
iterator = sceneTable->IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, iterator->Count() == 6);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene10);
+ EXPECT_EQ(iterator->Count(), 6u);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene10);
iterator->Release();
// Remove first
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntryAtPosition(kTestEndpoint1, kFabric1, 0));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveSceneTableEntryAtPosition(kTestEndpoint1, kFabric1, 0));
iterator = sceneTable->IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, iterator->Count() == 5);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene2);
+ EXPECT_EQ(iterator->Count(), 5u);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene2);
iterator->Release();
// Remove Next
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntry(kFabric1, scene3.mStorageId));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveSceneTableEntry(kFabric1, scene3.mStorageId));
iterator = sceneTable->IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, iterator->Count() == 4);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene2);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene4);
+ EXPECT_EQ(iterator->Count(), 4u);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene2);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene4);
iterator->Release();
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntry(kFabric1, scene2.mStorageId));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveSceneTableEntry(kFabric1, scene2.mStorageId));
iterator = sceneTable->IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, iterator->Count() == 3);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene4);
+ EXPECT_EQ(iterator->Count(), 3u);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene4);
iterator->Release();
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntry(kFabric1, scene4.mStorageId));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveSceneTableEntry(kFabric1, scene4.mStorageId));
iterator = sceneTable->IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, iterator->Count() == 2);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene6);
+ EXPECT_EQ(iterator->Count(), 2u);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene6);
iterator->Release();
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntry(kFabric1, scene6.mStorageId));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveSceneTableEntry(kFabric1, scene6.mStorageId));
iterator = sceneTable->IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, iterator->Count() == 1);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene12);
+ EXPECT_EQ(iterator->Count(), 1u);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene12);
iterator->Release();
// Remove last
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntry(kFabric1, scene7.mStorageId));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveSceneTableEntry(kFabric1, scene7.mStorageId));
iterator = sceneTable->IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, iterator->Count() == 0);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene) == false);
+ EXPECT_EQ(iterator->Count(), 0u);
+ EXPECT_FALSE(iterator->Next(scene));
iterator->Release();
// Remove at empty position, shouldn't trigger error
- NL_TEST_ASSERT(aSuite,
- CHIP_NO_ERROR ==
- sceneTable->RemoveSceneTableEntryAtPosition(kTestEndpoint1, kFabric1, defaultTestFabricCapacity - 1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveSceneTableEntryAtPosition(kTestEndpoint1, kFabric1, defaultTestFabricCapacity - 1));
iterator = sceneTable->IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, iterator->Count() == 0);
+ EXPECT_EQ(iterator->Count(), 0u);
iterator->Release();
// Test Remove all scenes in Group
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene2));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene3));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene4));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene5));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene6));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene2));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene3));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene4));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene5));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene6));
iterator = sceneTable->IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, iterator->Count() == 6);
+ EXPECT_EQ(iterator->Count(), 6u);
iterator->Release();
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->DeleteAllScenesInGroup(kFabric1, kGroup1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->DeleteAllScenesInGroup(kFabric1, kGroup1));
iterator = sceneTable->IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, iterator->Count() == 2);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene5);
- NL_TEST_ASSERT(aSuite, iterator->Next(scene));
- NL_TEST_ASSERT(aSuite, scene == scene6);
+ EXPECT_EQ(iterator->Count(), 2u);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene5);
+ EXPECT_TRUE(iterator->Next(scene));
+ EXPECT_EQ(scene, scene6);
iterator->Release();
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->DeleteAllScenesInGroup(kFabric1, kGroup2));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->DeleteAllScenesInGroup(kFabric1, kGroup2));
iterator = sceneTable->IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, iterator->Count() == 0);
+ EXPECT_EQ(iterator->Count(), 0u);
iterator->Release();
}
-void TestFabricScenes(nlTestSuite * aSuite, void * aContext)
+TEST_F(TestSceneTable, TestFabricScenes)
{
SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
+ ASSERT_NE(nullptr, sceneTable);
// Reset test
ResetSceneTable(sceneTable);
@@ -990,234 +999,233 @@
uint8_t fabric_capacity = 0;
// Verify capacities are at max
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
// Fabric 1 inserts
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene2));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene3));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene4));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene5));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene6));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene7));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene2));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene3));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene4));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene5));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene6));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene7));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
uint8_t scene_count = 0;
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetFabricSceneCount(kFabric1, scene_count));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetFabricSceneCount(kFabric1, scene_count));
+ EXPECT_EQ(defaultTestFabricCapacity, scene_count);
// Fabric 2 inserts
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene2));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene3));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene4));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, (defaultTestFabricCapacity - 4) == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetFabricSceneCount(kFabric2, scene_count));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(scene_count));
- NL_TEST_ASSERT(aSuite, 11 == scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene2));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene3));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene4));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ((defaultTestFabricCapacity - 4), fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetFabricSceneCount(kFabric2, scene_count));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(scene_count));
+ EXPECT_EQ(11, scene_count);
// Fabric 3 inserts, should only be 4 spaces left at this point since 12 got taken
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestTableSize - 11 == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric3, scene1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric3, scene2));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric3, scene3));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric3, scene4));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric3, scene5));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetFabricSceneCount(kFabric3, scene_count));
- NL_TEST_ASSERT(aSuite, 5 == scene_count);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(scene_count));
- NL_TEST_ASSERT(aSuite, defaultTestTableSize == scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity));
+ EXPECT_EQ(defaultTestTableSize - 11, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric3, scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric3, scene2));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric3, scene3));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric3, scene4));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric3, scene5));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetFabricSceneCount(kFabric3, scene_count));
+ EXPECT_EQ(5, scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(scene_count));
+ EXPECT_EQ(defaultTestTableSize, scene_count);
// Checks capacity is now 0 accross all fabrics
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
// To many scenes accross fabrics (Max scenes accross fabrics == 16)
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NO_MEMORY == sceneTable->SetSceneTableEntry(kFabric3, scene6));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NO_MEMORY == sceneTable->SetSceneTableEntry(kFabric2, scene5));
+ EXPECT_EQ(CHIP_ERROR_NO_MEMORY, sceneTable->SetSceneTableEntry(kFabric3, scene6));
+ EXPECT_EQ(CHIP_ERROR_NO_MEMORY, sceneTable->SetSceneTableEntry(kFabric2, scene5));
// Verifying all inserted scenes are accessible
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, scene == scene1);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, scene == scene2);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, scene == scene3);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, scene == scene4);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, scene == scene5);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
- NL_TEST_ASSERT(aSuite, scene == scene6);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
- NL_TEST_ASSERT(aSuite, scene == scene7);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
+ EXPECT_EQ(scene, scene1);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
+ EXPECT_EQ(scene, scene2);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
+ EXPECT_EQ(scene, scene3);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
+ EXPECT_EQ(scene, scene4);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
+ EXPECT_EQ(scene, scene5);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
+ EXPECT_EQ(scene, scene6);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
+ EXPECT_EQ(scene, scene7);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, scene == scene1);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, scene == scene2);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, scene == scene3);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, scene == scene4);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene));
+ EXPECT_EQ(scene, scene1);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId2, scene));
+ EXPECT_EQ(scene, scene2);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId3, scene));
+ EXPECT_EQ(scene, scene3);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId4, scene));
+ EXPECT_EQ(scene, scene4);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric3, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, scene == scene1);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric3, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, scene == scene2);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric3, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, scene == scene3);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric3, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, scene == scene4);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric3, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, scene == scene5);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric3, sceneId1, scene));
+ EXPECT_EQ(scene, scene1);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric3, sceneId2, scene));
+ EXPECT_EQ(scene, scene2);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric3, sceneId3, scene));
+ EXPECT_EQ(scene, scene3);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric3, sceneId4, scene));
+ EXPECT_EQ(scene, scene4);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric3, sceneId5, scene));
+ EXPECT_EQ(scene, scene5);
// Remove Fabric 1
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveFabric(kFabric1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveFabric(kFabric1));
// Verify Fabric 1 removed
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetFabricSceneCount(kFabric1, scene_count));
- NL_TEST_ASSERT(aSuite, 0 == scene_count);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(scene_count));
- NL_TEST_ASSERT(aSuite, 9 == scene_count);
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId8, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetFabricSceneCount(kFabric1, scene_count));
+ EXPECT_EQ(0, scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(scene_count));
+ EXPECT_EQ(9, scene_count);
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId8, scene));
// Verify Fabric 2 still there
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetFabricSceneCount(kFabric2, scene_count));
- NL_TEST_ASSERT(aSuite, 4 == scene_count);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, scene == scene1);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, scene == scene2);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, scene == scene3);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, scene == scene4);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetFabricSceneCount(kFabric2, scene_count));
+ EXPECT_EQ(4, scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene));
+ EXPECT_EQ(scene, scene1);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId2, scene));
+ EXPECT_EQ(scene, scene2);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId3, scene));
+ EXPECT_EQ(scene, scene3);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId4, scene));
+ EXPECT_EQ(scene, scene4);
// Verify capacity updated for all fabrics
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 4 == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 5 == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity - 4, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity - 5, fabric_capacity);
// Verify we can now write more scenes in scene fabric 2
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene5));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene6));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene7));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, scene == scene5);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId6, scene));
- NL_TEST_ASSERT(aSuite, scene == scene6);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId7, scene));
- NL_TEST_ASSERT(aSuite, scene == scene7);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetFabricSceneCount(kFabric2, scene_count));
- NL_TEST_ASSERT(aSuite, 7 == scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene5));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene6));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene7));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId5, scene));
+ EXPECT_EQ(scene, scene5);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId6, scene));
+ EXPECT_EQ(scene, scene6);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId7, scene));
+ EXPECT_EQ(scene, scene7);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetFabricSceneCount(kFabric2, scene_count));
+ EXPECT_EQ(7, scene_count);
// Verify capacity updated properly
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 4 == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 5 == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(4, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity - 5, fabric_capacity);
// Verify Fabric 3 still there
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric3, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, scene == scene1);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric3, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, scene == scene2);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric3, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, scene == scene3);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric3, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, scene == scene4);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric3, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, scene == scene5);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric3, sceneId1, scene));
+ EXPECT_EQ(scene, scene1);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric3, sceneId2, scene));
+ EXPECT_EQ(scene, scene2);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric3, sceneId3, scene));
+ EXPECT_EQ(scene, scene3);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric3, sceneId4, scene));
+ EXPECT_EQ(scene, scene4);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric3, sceneId5, scene));
+ EXPECT_EQ(scene, scene5);
// Remove Fabric 2
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveFabric(kFabric2));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveFabric(kFabric2));
// Verify Fabric 2 removed
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetFabricSceneCount(kFabric2, scene_count));
- NL_TEST_ASSERT(aSuite, 0 == scene_count);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(scene_count));
- NL_TEST_ASSERT(aSuite, 5 == scene_count);
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId6, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId7, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetFabricSceneCount(kFabric2, scene_count));
+ EXPECT_EQ(0, scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(scene_count));
+ EXPECT_EQ(5, scene_count);
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId2, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId3, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId4, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId5, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId6, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId7, scene));
// Verify Fabric 3 still there
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetFabricSceneCount(kFabric3, scene_count));
- NL_TEST_ASSERT(aSuite, 5 == scene_count);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric3, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, scene == scene1);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric3, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, scene == scene2);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric3, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, scene == scene3);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric3, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, scene == scene4);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric3, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, scene == scene5);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetFabricSceneCount(kFabric3, scene_count));
+ EXPECT_EQ(5, scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric3, sceneId1, scene));
+ EXPECT_EQ(scene, scene1);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric3, sceneId2, scene));
+ EXPECT_EQ(scene, scene2);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric3, sceneId3, scene));
+ EXPECT_EQ(scene, scene3);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric3, sceneId4, scene));
+ EXPECT_EQ(scene, scene4);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric3, sceneId5, scene));
+ EXPECT_EQ(scene, scene5);
// Remove Fabric 3
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveFabric(kFabric3));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveFabric(kFabric3));
// Verify Fabric 3 removed
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetFabricSceneCount(kFabric2, scene_count));
- NL_TEST_ASSERT(aSuite, 0 == scene_count);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(scene_count));
- NL_TEST_ASSERT(aSuite, 0 == scene_count);
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric3, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric3, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric3, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric3, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric3, sceneId5, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetFabricSceneCount(kFabric2, scene_count));
+ EXPECT_EQ(0, scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(scene_count));
+ EXPECT_EQ(0, scene_count);
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric3, sceneId1, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric3, sceneId2, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric3, sceneId3, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric3, sceneId4, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric3, sceneId5, scene));
// Confirm all counts are at 0
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetFabricSceneCount(kFabric1, scene_count));
- NL_TEST_ASSERT(aSuite, 0 == scene_count);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetFabricSceneCount(kFabric2, scene_count));
- NL_TEST_ASSERT(aSuite, 0 == scene_count);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetFabricSceneCount(kFabric3, scene_count));
- NL_TEST_ASSERT(aSuite, 0 == scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetFabricSceneCount(kFabric1, scene_count));
+ EXPECT_EQ(0, scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetFabricSceneCount(kFabric2, scene_count));
+ EXPECT_EQ(0, scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetFabricSceneCount(kFabric3, scene_count));
+ EXPECT_EQ(0, scene_count);
// Verify capacity updated for all fabrics
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
}
-void TestEndpointScenes(nlTestSuite * aSuite, void * aContext)
+TEST_F(TestSceneTable, TestEndpointScenes)
{
// Get Count for Endpoint 1
SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
+ ASSERT_NE(nullptr, sceneTable);
// Reset test
ResetSceneTable(sceneTable);
@@ -1228,401 +1236,360 @@
// Get Count for Endpoint 1
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count));
- NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(endpoint_scene_count));
+ EXPECT_EQ(0, endpoint_scene_count);
// Get Count for Endpoint 2
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count));
- NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(endpoint_scene_count));
+ EXPECT_EQ(0, endpoint_scene_count);
// Get Count for Endpoint 3
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count));
- NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(endpoint_scene_count));
+ EXPECT_EQ(0, endpoint_scene_count);
// Test Scenes insertion not accessible accross all endpoints
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count));
- NL_TEST_ASSERT(aSuite, 2 == endpoint_scene_count);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(endpoint_scene_count));
+ EXPECT_EQ(2, endpoint_scene_count);
uint8_t fabric_capacity = 0;
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 1 == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 1 == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity - 1, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity - 1, fabric_capacity);
// Endpoint2
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count));
- NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(endpoint_scene_count));
+ EXPECT_EQ(0, endpoint_scene_count);
// Endpoint3
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count));
- NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(endpoint_scene_count));
+ EXPECT_EQ(0, endpoint_scene_count);
// Check if scene present in Endpoint 1
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, scene == scene1);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, scene == scene1);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
+ EXPECT_EQ(scene, scene1);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene));
+ EXPECT_EQ(scene, scene1);
// Check if scene present in Endpoint 2
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene));
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene));
// Check if scene present in Endpoint 3
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene));
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene));
// Test removal on different endpoints do not affect each endpoints
// Insertion on Endpoint2
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, scene == scene1);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
+ EXPECT_EQ(scene, scene1);
// Removal on Endpoint1
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntry(kFabric1, sceneId1));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveSceneTableEntry(kFabric1, sceneId1));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
// Scene present on Endpoint2
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, scene == scene1);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
+ EXPECT_EQ(scene, scene1);
// Removal on Endpoint 2
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntry(kFabric1, sceneId1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveSceneTableEntry(kFabric1, sceneId1));
// Removal on Endpoint 1
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntry(kFabric2, sceneId1));
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveSceneTableEntry(kFabric2, sceneId1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count));
- NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(endpoint_scene_count));
+ EXPECT_EQ(0, endpoint_scene_count);
// Endpoint 2
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count));
- NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(endpoint_scene_count));
+ EXPECT_EQ(0, endpoint_scene_count);
// Endpoint 3
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count));
- NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(endpoint_scene_count));
+ EXPECT_EQ(0, endpoint_scene_count);
// Test the fabric capacity accross endpoint
// Fill fabric 1 endpoint 1
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene2));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene3));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene4));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene5));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene6));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene7));
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene2));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene3));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene4));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene5));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene6));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene7));
// Fill fabric 2 endpoint 1
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene2));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene3));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene4));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene5));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene6));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene7));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene2));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene3));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene4));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene5));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene6));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene7));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
// Endpoints 2 and 3 should be unaffected
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
// Verify filling Fabric on endpoint 2 does not affect on endpoint 3 despite Max per fabric being reached by adding Endpoint1
// and Endpoint2
// Fill fabric 1 endpoint 2
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene2));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene3));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene4));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene5));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene6));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene7));
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene2));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene3));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene4));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene5));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene6));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene7));
// Fill fabric 2 endpoint 2
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene2));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene3));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene4));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene5));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene6));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene7));
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene2));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene3));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene4));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene5));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene6));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene7));
// scene count to Endpoint
// Endpoint 3 still unafected
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
// Fill fabric 1 endpoint 3
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene2));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene3));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene4));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene5));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene6));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene7));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene2));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene3));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene4));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene5));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene6));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene7));
// Test removal of Endpoint clears scene on all fabrics for that endpoint
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveEndpoint());
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->RemoveEndpoint());
// Check Fabric1 on Endpoint 2
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId6, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId7, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId2, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId3, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId4, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId5, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId6, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId7, scene));
// Check Fabric 1 and 2 on Endpoint 1
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId6, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId7, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId2, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId3, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId4, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId5, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId6, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric2, sceneId7, scene));
// Check Fabric 1 on Endpoint 3
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
// Test removal of fabric clears scene fabric on all endpoints
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
+ ASSERT_NE(nullptr, sceneTable);
sceneTable->RemoveFabric(kFabric1);
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId4, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId5, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId6, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene));
sceneTable->RemoveFabric(kFabric2);
// Validate endpoints are empty
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count));
- NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(endpoint_scene_count));
+ EXPECT_EQ(0, endpoint_scene_count);
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count));
- NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(endpoint_scene_count));
+ EXPECT_EQ(0, endpoint_scene_count);
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count));
- NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(endpoint_scene_count));
+ EXPECT_EQ(0, endpoint_scene_count);
// Validate Fabric capacities at maximum accross all endpoints
// Endpoint 1
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
// Endpoint 2
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
// Endpoint 3
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
// Test of Get with changes to Endpoint capacity
// Endpoint 1
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize - 2);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 1 == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 1 == fabric_capacity);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity - 1, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity - 1, fabric_capacity);
// Test Endpoint 2's capacity remains unaffected
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity, fabric_capacity);
+ ASSERT_NE(nullptr, sceneTable);
// Test Insertion then change of capacity
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene2));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene3));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene4));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 4 == fabric_capacity);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene2));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene3));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene4));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity - 4, fabric_capacity);
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestFabricCapacity - 2);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 6 == fabric_capacity);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(defaultTestFabricCapacity - 6, fabric_capacity);
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestFabricCapacity - 4);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
// Test making the endpoint scene table smaller than the actual number of scenes on it
sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestFabricCapacity - 5);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
+ ASSERT_NE(nullptr, sceneTable);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
}
-void TestOTAChanges(nlTestSuite * aSuite, void * aContext)
+TEST_F(TestSceneTable, TestOTAChanges)
{
SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize);
- NL_TEST_ASSERT(aSuite, nullptr != sceneTable);
- VerifyOrReturn(nullptr != sceneTable);
+ ASSERT_NE(nullptr, sceneTable);
// Reset test
ResetSceneTable(sceneTable);
@@ -1633,88 +1600,85 @@
// Fill scene table
// Fill fabric 1 to capacity
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene2));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene3));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene4));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene5));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene6));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene7));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene2));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene3));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene4));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene5));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene6));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric1, scene7));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
uint8_t scene_table_fabric1_capacity = fabric_capacity;
auto * iterator = sceneTable->IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == iterator->Count());
+ EXPECT_EQ(defaultTestFabricCapacity, iterator->Count());
iterator->Release();
// Fill fabric 2 to capacity
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene1));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene2));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene3));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene4));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene5));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene6));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene7));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene1));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene2));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene3));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene4));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene5));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene6));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->SetSceneTableEntry(kFabric2, scene7));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
uint8_t scene_table_fabric2_capacity = fabric_capacity;
iterator = sceneTable->IterateSceneEntries(kFabric2);
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == iterator->Count());
+ EXPECT_EQ(defaultTestFabricCapacity, iterator->Count());
iterator->Release();
// SceneTable should be full at this point
uint8_t scene_count;
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(scene_count));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetEndpointSceneCount(scene_count));
// Global count should not have been modified
- NL_TEST_ASSERT(aSuite, fabricsFullCount == scene_count);
+ EXPECT_EQ(fabricsFullCount, scene_count);
// Create a scene table with a greater capacity than the original one (Max allowed capacity from gen_config.h)
TestSceneTableImpl ExpandedSceneTable(scenes::kMaxScenesPerFabric, scenes::kMaxScenesPerEndpoint);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.Init(&testStorage));
+ EXPECT_EQ(CHIP_NO_ERROR, ExpandedSceneTable.Init(mpTestStorage));
ExpandedSceneTable.SetEndpoint(kTestEndpoint1);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite,
- scene_table_fabric1_capacity + (scenes::kMaxScenesPerFabric - defaultTestFabricCapacity) == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite,
- scene_table_fabric2_capacity + (scenes::kMaxScenesPerFabric - defaultTestFabricCapacity) == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, ExpandedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(scene_table_fabric1_capacity + (scenes::kMaxScenesPerFabric - defaultTestFabricCapacity), fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, ExpandedSceneTable.GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(scene_table_fabric2_capacity + (scenes::kMaxScenesPerFabric - defaultTestFabricCapacity), fabric_capacity);
// We should be able to insert 4 scenes into fabric 2
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.SetSceneTableEntry(kFabric2, scene9));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.SetSceneTableEntry(kFabric2, scene13));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.SetSceneTableEntry(kFabric2, scene14));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.SetSceneTableEntry(kFabric2, scene15));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, ExpandedSceneTable.SetSceneTableEntry(kFabric2, scene9));
+ EXPECT_EQ(CHIP_NO_ERROR, ExpandedSceneTable.SetSceneTableEntry(kFabric2, scene13));
+ EXPECT_EQ(CHIP_NO_ERROR, ExpandedSceneTable.SetSceneTableEntry(kFabric2, scene14));
+ EXPECT_EQ(CHIP_NO_ERROR, ExpandedSceneTable.SetSceneTableEntry(kFabric2, scene15));
+ EXPECT_EQ(CHIP_NO_ERROR, ExpandedSceneTable.GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
// Fabric 1's capacity should have remain unchanged
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite,
- scene_table_fabric1_capacity + (scenes::kMaxScenesPerFabric - defaultTestFabricCapacity) == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, ExpandedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(scene_table_fabric1_capacity + (scenes::kMaxScenesPerFabric - defaultTestFabricCapacity), fabric_capacity);
// Global count should have increased by (scenes::kMaxScenesPerFarbic - defaultTestFabricCapacity)
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.GetEndpointSceneCount(scene_count));
- NL_TEST_ASSERT(aSuite, fabricsFullCount + (scenes::kMaxScenesPerFabric - defaultTestFabricCapacity) == scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, ExpandedSceneTable.GetEndpointSceneCount(scene_count));
+ EXPECT_EQ(fabricsFullCount + (scenes::kMaxScenesPerFabric - defaultTestFabricCapacity), scene_count);
// Same test for 4 insertion in fabric 1
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.SetSceneTableEntry(kFabric1, scene9));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.SetSceneTableEntry(kFabric1, scene13));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.SetSceneTableEntry(kFabric1, scene14));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.SetSceneTableEntry(kFabric1, scene15));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, ExpandedSceneTable.SetSceneTableEntry(kFabric1, scene9));
+ EXPECT_EQ(CHIP_NO_ERROR, ExpandedSceneTable.SetSceneTableEntry(kFabric1, scene13));
+ EXPECT_EQ(CHIP_NO_ERROR, ExpandedSceneTable.SetSceneTableEntry(kFabric1, scene14));
+ EXPECT_EQ(CHIP_NO_ERROR, ExpandedSceneTable.SetSceneTableEntry(kFabric1, scene15));
+ EXPECT_EQ(CHIP_NO_ERROR, ExpandedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
// Global count should be at defaultTestTableSize + (scenes::kMaxScenesPerEndpoint - defaultTestTableSize)
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.GetEndpointSceneCount(scene_count));
- NL_TEST_ASSERT(aSuite, fabricsFullCount + (scenes::kMaxScenesPerEndpoint - defaultTestTableSize) == scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, ExpandedSceneTable.GetEndpointSceneCount(scene_count));
+ EXPECT_EQ(fabricsFullCount + (scenes::kMaxScenesPerEndpoint - defaultTestTableSize), scene_count);
// Test failure to init a SceneTable with sizes above the defined max scenes per fabric or globaly
TestSceneTableImpl SceneTableTooManyPerFabric(scenes::kMaxScenesPerFabric + 1, scenes::kMaxScenesPerEndpoint);
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_INVALID_INTEGER_VALUE == SceneTableTooManyPerFabric.Init(&testStorage));
+ EXPECT_EQ(CHIP_ERROR_INVALID_INTEGER_VALUE, SceneTableTooManyPerFabric.Init(mpTestStorage));
SceneTableTooManyPerFabric.Finish();
TestSceneTableImpl SceneTableTooManyGlobal(scenes::kMaxScenesPerFabric, scenes::kMaxScenesPerEndpoint + 1);
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_INVALID_INTEGER_VALUE == SceneTableTooManyGlobal.Init(&testStorage));
+ EXPECT_EQ(CHIP_ERROR_INVALID_INTEGER_VALUE, SceneTableTooManyGlobal.Init(mpTestStorage));
SceneTableTooManyGlobal.Finish();
// Create a new table with a lower limit of scenes per fabric
@@ -1722,148 +1686,90 @@
uint8_t newTableSize = defaultTestTableSize - 2;
uint8_t capacityDifference = static_cast<uint8_t>(scenes::kMaxScenesPerFabric - newCapacity);
TestSceneTableImpl ReducedSceneTable(newCapacity, newTableSize);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.Init(&testStorage));
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.Init(mpTestStorage));
ReducedSceneTable.SetEndpoint(kTestEndpoint1);
// Global count should not have been modified
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetEndpointSceneCount(scene_count));
- NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerEndpoint - 2 == scene_count);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.GetEndpointSceneCount(scene_count));
+ EXPECT_EQ(scenes::kMaxScenesPerEndpoint - 2, scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
// Load a scene from fabric 1, this should adjust fabric 1 scene count in flash
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetSceneTableEntry(kFabric1, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, scene == scene1);
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.GetSceneTableEntry(kFabric1, sceneId1, scene));
+ EXPECT_EQ(scene, scene1);
// The number count of scenes in Fabric 1 should have been adjusted here
iterator = ReducedSceneTable.IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, newCapacity == iterator->Count());
+ EXPECT_EQ(newCapacity, iterator->Count());
iterator->Release();
// Capacity should still be 0 in fabric 1
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetEndpointSceneCount(scene_count));
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.GetEndpointSceneCount(scene_count));
// Global count should have been reduced by the difference between the max fabric capacity of a fabric and the
// new fabric capacity since we haven't loaded from fabric 2 yet
- NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerEndpoint - 2 - capacityDifference == scene_count);
+ EXPECT_EQ(scenes::kMaxScenesPerEndpoint - 2 - capacityDifference, scene_count);
// Remove a Scene from the Fabric 1
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.RemoveSceneTableEntry(kFabric1, scene1.mStorageId));
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.RemoveSceneTableEntry(kFabric1, scene1.mStorageId));
// Check count updated for fabric
iterator = ReducedSceneTable.IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, static_cast<uint8_t>(newCapacity - 1) == iterator->Count());
+ EXPECT_EQ(static_cast<uint8_t>(newCapacity - 1), iterator->Count());
iterator->Release();
// Check fabric still doesn't have capacity because fabric 2 still have a higher number of scene than allowed
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
// Remove another scene from fabric 1
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.RemoveSceneTableEntry(kFabric1, scene2.mStorageId));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.RemoveSceneTableEntry(kFabric1, scene3.mStorageId));
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.RemoveSceneTableEntry(kFabric1, scene4.mStorageId));
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.RemoveSceneTableEntry(kFabric1, scene2.mStorageId));
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.RemoveSceneTableEntry(kFabric1, scene3.mStorageId));
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.RemoveSceneTableEntry(kFabric1, scene4.mStorageId));
// Check count updated for fabric
iterator = ReducedSceneTable.IterateSceneEntries(kFabric1);
- NL_TEST_ASSERT(aSuite, 2 == iterator->Count());
+ EXPECT_EQ(2u, iterator->Count());
iterator->Release();
// Confirm global count has been updated
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetEndpointSceneCount(scene_count));
- NL_TEST_ASSERT(aSuite, 13 == scene_count);
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.GetEndpointSceneCount(scene_count));
+ EXPECT_EQ(13, scene_count);
// Confirm we now have capacity in fabric one
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 1 == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(1, fabric_capacity);
// Load a scene from fabric 2, this should adjust fabric 2 scene count in flash
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetSceneTableEntry(kFabric2, sceneId1, scene));
- NL_TEST_ASSERT(aSuite, scene == scene1);
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.GetSceneTableEntry(kFabric2, sceneId1, scene));
+ EXPECT_EQ(scene, scene1);
// The number count of scenes in Fabric 2 should have been adjusted here
iterator = ReducedSceneTable.IterateSceneEntries(kFabric2);
- NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 1 == iterator->Count());
+ EXPECT_EQ(defaultTestFabricCapacity - 1u, iterator->Count());
iterator->Release();
// Global count should also have been adjusted
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetEndpointSceneCount(scene_count));
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.GetEndpointSceneCount(scene_count));
// had 22 scenes, truncated 5 from both (10) and deleted 4 from fabric 1: 8 scenes left
- NL_TEST_ASSERT(aSuite, 8 == scene_count);
+ EXPECT_EQ(8, scene_count);
// Confirm we now have capacity of 6 in the first fabric since we previously removed 6 scenes form there
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 4 == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(4, fabric_capacity);
// Fabric 2 should still be at capacity
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 0 == fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, ReducedSceneTable.GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(0, fabric_capacity);
ReducedSceneTable.Finish();
// The Scene 8 should now have been truncated from the memory and thus not be accessible from both fabrics in the
// original scene table
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId8, scene));
- NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId8, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric1, sceneId8, scene));
+ EXPECT_EQ(CHIP_ERROR_NOT_FOUND, sceneTable->GetSceneTableEntry(kFabric2, sceneId8, scene));
// The Remaining capacity in the original scene table therefore have been modified as well
// Fabric 2 should still be almost at capacity
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 5 == fabric_capacity);
- NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity));
+ EXPECT_EQ(5, fabric_capacity);
+ EXPECT_EQ(CHIP_NO_ERROR, sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity));
- NL_TEST_ASSERT(aSuite, 1 == fabric_capacity);
+ EXPECT_EQ(1, fabric_capacity);
}
} // namespace TestScenes
-
-namespace {
-/**
- * Setup the test suite.
- */
-int TestSetup(void * inContext)
-{
- VerifyOrReturnError(CHIP_NO_ERROR == chip::Platform::MemoryInit(), FAILURE);
-
- // Initialize Scene Table
- SceneTable * sceneTable = scenes::GetSceneTableImpl();
- VerifyOrReturnError(nullptr != sceneTable, FAILURE);
- VerifyOrReturnError(CHIP_NO_ERROR == sceneTable->Init(&TestScenes::testStorage), FAILURE);
-
- return SUCCESS;
-}
-
-/**
- * Tear down the test suite.
- */
-int TestTeardown(void * inContext)
-{
- // Terminate Scene Table
- SceneTable * sceneTable = scenes::GetSceneTableImpl();
- VerifyOrReturnError(nullptr != sceneTable, FAILURE);
- sceneTable->Finish();
- chip::Platform::MemoryShutdown();
-
- return SUCCESS;
-}
-} // namespace
-
-int TestSceneTable()
-{
- static nlTest sTests[] = { NL_TEST_DEF("TestHandlerRegistration", TestScenes::TestHandlerRegistration),
- NL_TEST_DEF("TestHandlerFunctions", TestScenes::TestHandlerFunctions),
- NL_TEST_DEF("TestStoreScenes", TestScenes::TestStoreScenes),
- NL_TEST_DEF("TestOverwriteScenes", TestScenes::TestOverwriteScenes),
- NL_TEST_DEF("TestIterateScenes", TestScenes::TestIterateScenes),
- NL_TEST_DEF("TestRemoveScenes", TestScenes::TestRemoveScenes),
- NL_TEST_DEF("TestFabricScenes", TestScenes::TestFabricScenes),
- NL_TEST_DEF("TestEndpointScenes", TestScenes::TestEndpointScenes),
- NL_TEST_DEF("TestOTAChanges", TestScenes::TestOTAChanges),
-
- NL_TEST_SENTINEL() };
-
- nlTestSuite theSuite = {
- "SceneTable",
- &sTests[0],
- TestSetup,
- TestTeardown,
- };
-
- nlTestRunner(&theSuite, nullptr);
- return (nlTestRunnerStats(&theSuite));
-}
-
-CHIP_REGISTER_TEST_SUITE(TestSceneTable)