From e289e60e90621b1414525a062304076fae64119e Mon Sep 17 00:00:00 2001 From: William Hicklin Date: Fri, 7 Jul 2023 10:04:37 +0100 Subject: [PATCH] Added tests got GetNull functions --- .../tests/TestAttributePersistenceProvider.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/app/tests/TestAttributePersistenceProvider.cpp b/src/app/tests/TestAttributePersistenceProvider.cpp index d531e744890fb3..045ef77be69d9f 100644 --- a/src/app/tests/TestAttributePersistenceProvider.cpp +++ b/src/app/tests/TestAttributePersistenceProvider.cpp @@ -198,6 +198,21 @@ void TestStorageAndRetrivalSignedScalarValues(nlTestSuite * inSuite, void * inCo persistenceProvider.Shutdown(); } +void TestGetNullFunctions(nlTestSuite * inSuite, void * inContext) +{ + NL_TEST_ASSERT(inSuite, AttributePersistenceProvider::GetNullValueForNullableType() == uint8_t(0xff)); + + NL_TEST_ASSERT(inSuite, AttributePersistenceProvider::GetNullValueForNullableType() == uint8_t(0xff)); + NL_TEST_ASSERT(inSuite, AttributePersistenceProvider::GetNullValueForNullableType() == uint16_t(0xffff)); + NL_TEST_ASSERT(inSuite, AttributePersistenceProvider::GetNullValueForNullableType() == uint32_t(0xffffffff)); + NL_TEST_ASSERT(inSuite, AttributePersistenceProvider::GetNullValueForNullableType() == uint64_t(0xffffffffffffffff)); + + NL_TEST_ASSERT(inSuite, AttributePersistenceProvider::GetNullValueForNullableType() == int8_t(0x80)); + NL_TEST_ASSERT(inSuite, AttributePersistenceProvider::GetNullValueForNullableType() == int16_t(0x8000)); + NL_TEST_ASSERT(inSuite, AttributePersistenceProvider::GetNullValueForNullableType() == int32_t(0x80000000)); + NL_TEST_ASSERT(inSuite, AttributePersistenceProvider::GetNullValueForNullableType() == int64_t(0x8000000000000000)); +} + /** * Tests the storage and retrival of data from the KVS of DataModel::Nullable types bool, uint8_t, uint16_t, uint32_t, uint64_t. */ @@ -370,6 +385,7 @@ const nlTest sTests[] = { NL_TEST_DEF("Storage and retrival of ByteSpans", TestStorageAndRetrivalByteSpans), NL_TEST_DEF("Storage and retrival of unsigned scalar values", TestStorageAndRetrivalScalarValues), NL_TEST_DEF("Storage and retrival of signed scalar values", TestStorageAndRetrivalSignedScalarValues), + NL_TEST_DEF("Check GetNullValueForNullableType return values", TestGetNullFunctions), NL_TEST_DEF("Storage and retrival of unsigned nullable scalar values", TestStorageAndRetrivalNullableScalarValues), NL_TEST_DEF("Storage and retrival of signed nullable scalar values", TestStorageAndRetrivalSignedNullableScalarValues), NL_TEST_DEF("Small buffer errors", TestBufferTooSmallErrors),