40
40
#include < messaging/ExchangeContext.h>
41
41
#include < messaging/ExchangeMgr.h>
42
42
#include < messaging/Flags.h>
43
+ #include < optional>
43
44
#include < platform/CHIPDeviceLayer.h>
44
45
#include < protocols/interaction_model/Constants.h>
45
46
#include < system/SystemPacketBuffer.h>
@@ -392,7 +393,7 @@ class TestCommandInteraction
392
393
const Optional<uint16_t > & aRef) :
393
394
CommandHandler (apCallback)
394
395
{
395
- GetCommandPathRegistry ().Add (aRequestCommandPath, aRef);
396
+ GetCommandPathRegistry ().Add (aRequestCommandPath, aRef. std_optional () );
396
397
SetExchangeInterface (&mMockCommandResponder );
397
398
}
398
399
MockCommandResponder mMockCommandResponder ;
@@ -407,7 +408,8 @@ class TestCommandInteraction
407
408
// payload will be included. Otherwise no payload will be included.
408
409
static void GenerateInvokeResponse (nlTestSuite * apSuite, void * apContext, System::PacketBufferHandle & aPayload,
409
410
CommandId aCommandId, ClusterId aClusterId = kTestClusterId ,
410
- EndpointId aEndpointId = kTestEndpointId , Optional<uint16_t > aCommandRef = NullOptional);
411
+ EndpointId aEndpointId = kTestEndpointId ,
412
+ std::optional<uint16_t > aCommandRef = std::nullopt);
411
413
static void AddInvokeRequestData (nlTestSuite * apSuite, void * apContext, CommandSender * apCommandSender,
412
414
CommandId aCommandId = kTestCommandIdWithData );
413
415
static void AddInvalidInvokeRequestData (nlTestSuite * apSuite, void * apContext, CommandSender * apCommandSender,
@@ -494,7 +496,7 @@ void TestCommandInteraction::GenerateInvokeRequest(nlTestSuite * apSuite, void *
494
496
495
497
void TestCommandInteraction::GenerateInvokeResponse (nlTestSuite * apSuite, void * apContext, System::PacketBufferHandle & aPayload,
496
498
CommandId aCommandId, ClusterId aClusterId, EndpointId aEndpointId,
497
- Optional <uint16_t > aCommandRef)
499
+ std::optional <uint16_t > aCommandRef)
498
500
499
501
{
500
502
CHIP_ERROR err = CHIP_NO_ERROR;
@@ -536,9 +538,9 @@ void TestCommandInteraction::GenerateInvokeResponse(nlTestSuite * apSuite, void
536
538
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
537
539
}
538
540
539
- if (aCommandRef.HasValue ())
541
+ if (aCommandRef.has_value ())
540
542
{
541
- NL_TEST_ASSERT (apSuite, commandDataIBBuilder.Ref (aCommandRef. Value () ) == CHIP_NO_ERROR);
543
+ NL_TEST_ASSERT (apSuite, commandDataIBBuilder.Ref (* aCommandRef) == CHIP_NO_ERROR);
542
544
}
543
545
544
546
commandDataIBBuilder.EndOfCommandDataIB ();
@@ -633,9 +635,9 @@ uint32_t TestCommandInteraction::GetAddResponseDataOverheadSizeForPath(nlTestSui
633
635
ConcreteCommandPath requestCommandPath1 = { kTestEndpointId , kTestClusterId , kTestCommandIdFillResponseMessage };
634
636
ConcreteCommandPath requestCommandPath2 = { kTestEndpointId , kTestClusterId , kTestCommandIdCommandSpecificResponse };
635
637
636
- CHIP_ERROR err = basicCommandPathRegistry.Add (requestCommandPath1, MakeOptional <uint16_t >(static_cast <uint16_t >(1 )));
638
+ CHIP_ERROR err = basicCommandPathRegistry.Add (requestCommandPath1, std::make_optional <uint16_t >(static_cast <uint16_t >(1 )));
637
639
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
638
- err = basicCommandPathRegistry.Add (requestCommandPath2, MakeOptional <uint16_t >(static_cast <uint16_t >(2 )));
640
+ err = basicCommandPathRegistry.Add (requestCommandPath2, std::make_optional <uint16_t >(static_cast <uint16_t >(2 )));
639
641
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
640
642
641
643
err = commandHandler.AllocateBuffer ();
@@ -823,7 +825,7 @@ void TestCommandInteraction::TestCommandSenderExtendableApiWithProcessReceivedMs
823
825
824
826
uint16_t invalidResponseCommandRef = 2 ;
825
827
GenerateInvokeResponse (apSuite, apContext, buf, kTestCommandIdWithData , kTestClusterId , kTestEndpointId ,
826
- MakeOptional (invalidResponseCommandRef));
828
+ std::make_optional (invalidResponseCommandRef));
827
829
bool moreChunkedMessages = false ;
828
830
err = commandSender.ProcessInvokeResponse (std::move (buf), moreChunkedMessages);
829
831
NL_TEST_ASSERT (apSuite, err == CHIP_ERROR_KEY_NOT_FOUND);
@@ -1948,9 +1950,9 @@ void TestCommandInteraction::TestCommandHandler_FillUpInvokeResponseMessageWhere
1948
1950
ConcreteCommandPath requestCommandPath1 = { kTestEndpointId , kTestClusterId , kTestCommandIdFillResponseMessage };
1949
1951
ConcreteCommandPath requestCommandPath2 = { kTestEndpointId , kTestClusterId , kTestCommandIdCommandSpecificResponse };
1950
1952
1951
- CHIP_ERROR err = basicCommandPathRegistry.Add (requestCommandPath1, MakeOptional <uint16_t >(static_cast <uint16_t >(1 )));
1953
+ CHIP_ERROR err = basicCommandPathRegistry.Add (requestCommandPath1, std::make_optional <uint16_t >(static_cast <uint16_t >(1 )));
1952
1954
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
1953
- err = basicCommandPathRegistry.Add (requestCommandPath2, MakeOptional <uint16_t >(static_cast <uint16_t >(2 )));
1955
+ err = basicCommandPathRegistry.Add (requestCommandPath2, std::make_optional <uint16_t >(static_cast <uint16_t >(2 )));
1954
1956
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
1955
1957
1956
1958
uint32_t sizeToLeave = 0 ;
@@ -1977,9 +1979,9 @@ void TestCommandInteraction::TestCommandHandler_FillUpInvokeResponseMessageWhere
1977
1979
ConcreteCommandPath requestCommandPath1 = { kTestEndpointId , kTestClusterId , kTestCommandIdFillResponseMessage };
1978
1980
ConcreteCommandPath requestCommandPath2 = { kTestEndpointId , kTestClusterId , kTestCommandIdCommandSpecificResponse };
1979
1981
1980
- CHIP_ERROR err = basicCommandPathRegistry.Add (requestCommandPath1, MakeOptional <uint16_t >(static_cast <uint16_t >(1 )));
1982
+ CHIP_ERROR err = basicCommandPathRegistry.Add (requestCommandPath1, std::make_optional <uint16_t >(static_cast <uint16_t >(1 )));
1981
1983
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
1982
- err = basicCommandPathRegistry.Add (requestCommandPath2, MakeOptional <uint16_t >(static_cast <uint16_t >(2 )));
1984
+ err = basicCommandPathRegistry.Add (requestCommandPath2, std::make_optional <uint16_t >(static_cast <uint16_t >(2 )));
1983
1985
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
1984
1986
1985
1987
uint32_t sizeToLeave = 0 ;
@@ -2005,9 +2007,9 @@ void TestCommandInteraction::TestCommandHandler_FillUpInvokeResponseMessageWhere
2005
2007
ConcreteCommandPath requestCommandPath1 = { kTestEndpointId , kTestClusterId , kTestCommandIdFillResponseMessage };
2006
2008
ConcreteCommandPath requestCommandPath2 = { kTestEndpointId , kTestClusterId , kTestCommandIdCommandSpecificResponse };
2007
2009
2008
- CHIP_ERROR err = basicCommandPathRegistry.Add (requestCommandPath1, MakeOptional <uint16_t >(static_cast <uint16_t >(1 )));
2010
+ CHIP_ERROR err = basicCommandPathRegistry.Add (requestCommandPath1, std::make_optional <uint16_t >(static_cast <uint16_t >(1 )));
2009
2011
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
2010
- err = basicCommandPathRegistry.Add (requestCommandPath2, MakeOptional <uint16_t >(static_cast <uint16_t >(2 )));
2012
+ err = basicCommandPathRegistry.Add (requestCommandPath2, std::make_optional <uint16_t >(static_cast <uint16_t >(2 )));
2011
2013
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
2012
2014
2013
2015
uint32_t sizeToLeave = 0 ;
0 commit comments