diff --git a/src/app/tests/TestAttributePersistenceProvider.cpp b/src/app/tests/TestAttributePersistenceProvider.cpp index 9a19a725ffd75b..7721ff6d8c04f1 100644 --- a/src/app/tests/TestAttributePersistenceProvider.cpp +++ b/src/app/tests/TestAttributePersistenceProvider.cpp @@ -95,7 +95,26 @@ void testHelperStorageAndRetrivalScalarValues(nlTestSuite * inSuite, DefaultAttr CHIP_ERROR err = persistenceProvider.WriteScalarValue(TestConcretePath, testValue); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - T valueReadBack; + T valueReadBack = 0; + err = persistenceProvider.ReadScalarValue(TestConcretePath, valueReadBack); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + + NL_TEST_ASSERT(inSuite, valueReadBack == testValue); +} + +/** + * Helper to test the storage and retrival of various nullable types from persistent storage. + * @tparam T The type of the value to store and retrieve + * @param testValue The test value to store and retrieve + */ +template +void testHelperStorageAndRetrivalScalarValues(nlTestSuite * inSuite, DefaultAttributePersistenceProvider & persistenceProvider, + DataModel::Nullable testValue) +{ + CHIP_ERROR err = persistenceProvider.WriteScalarValue(TestConcretePath, testValue); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + + DataModel::Nullable valueReadBack(0); err = persistenceProvider.ReadScalarValue(TestConcretePath, valueReadBack); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);