Skip to content

Commit

Permalink
Added the initialisation of valueReadBack and added a new templated f…
Browse files Browse the repository at this point in the history
…unction for nullable types to avoid the error: The left operand of '==' is a garbage value, on some platforms.
  • Loading branch information
hicklin committed Jul 7, 2023
1 parent 09488ec commit 582b92c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/app/tests/TestAttributePersistenceProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T>
void testHelperStorageAndRetrivalScalarValues(nlTestSuite * inSuite, DefaultAttributePersistenceProvider & persistenceProvider,
DataModel::Nullable<T> testValue)
{
CHIP_ERROR err = persistenceProvider.WriteScalarValue(TestConcretePath, testValue);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

DataModel::Nullable<T> valueReadBack(0);
err = persistenceProvider.ReadScalarValue(TestConcretePath, valueReadBack);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

Expand Down

0 comments on commit 582b92c

Please sign in to comment.