From 39f67e1703281cb70db7df671cbf0a28104737c5 Mon Sep 17 00:00:00 2001 From: chrisdecenzo Date: Mon, 16 May 2022 17:12:13 -0700 Subject: [PATCH] fix boundary test case --- .../tests/TestUdcMessages.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/protocols/user_directed_commissioning/tests/TestUdcMessages.cpp b/src/protocols/user_directed_commissioning/tests/TestUdcMessages.cpp index ad9831e8eb772c..7b3c03cf049b6d 100644 --- a/src/protocols/user_directed_commissioning/tests/TestUdcMessages.cpp +++ b/src/protocols/user_directed_commissioning/tests/TestUdcMessages.cpp @@ -300,11 +300,16 @@ void TestUDCClientState(nlTestSuite * inSuite, void * inContext) char rotatingIdLongString[chip::Dnssd::kMaxRotatingIdLen * 2 + 1]; uint8_t rotatingIdLong[chip::Dnssd::kMaxRotatingIdLen]; size_t rotatingIdLongLen; - strcpy(rotatingIdLongString, - "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); - GetRotatingDeviceId(GetSpan(rotatingIdLongString), rotatingIdLong, &rotatingIdLongLen); + strcpy( + rotatingIdLongString, + "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); - printf(" max length %zu, long length %zu\n", chip::Dnssd::kMaxRotatingIdLen, rotatingIdLongLen); + const ByteSpan & value = GetSpan(rotatingIdLongString); + rotatingIdLongLen = Encoding::HexToBytes(reinterpret_cast(value.data()), value.size(), rotatingIdLong, + chip::Dnssd::kMaxRotatingIdLen * 2); + + printf("str len=%zu max length %zu, long length %zu\n", strlen(rotatingIdLongString), chip::Dnssd::kMaxRotatingIdLen, + rotatingIdLongLen); NL_TEST_ASSERT(inSuite, rotatingIdLongLen > chip::Dnssd::kMaxRotatingIdLen); // test base case