Skip to content

Commit

Permalink
Fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
jadhavrohit924 committed Sep 24, 2024
1 parent 4d6825c commit e9ac903
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ using Status = chip::Protocols::InteractionModel::Status;
namespace {

const auto loginTempAccountIdentifierFieldId =
to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kTempAccountIdentifier));
const auto loginSetupPINFieldId = to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kSetupPIN));
const auto loginNodeFieldId = to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kNode));
const auto logoutNodeFieldId = to_string(chip::to_underlying(AccountLogin::Commands::Logout::Fields::kNode));
std::to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kTempAccountIdentifier));
const auto loginSetupPINFieldId = std::to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kSetupPIN));
const auto loginNodeFieldId = std::to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kNode));
const auto logoutNodeFieldId = std::to_string(chip::to_underlying(AccountLogin::Commands::Logout::Fields::kNode));

string charSpanToString(const CharSpan & charSpan)
{
Expand All @@ -44,12 +44,12 @@ std::string serializeLoginCommand(AccountLogin::Commands::Login::Type cmd)
{
return R"({")" + loginTempAccountIdentifierFieldId + R"(":")" + charSpanToString(cmd.tempAccountIdentifier) + R"(",)" + R"(")" +
loginSetupPINFieldId + R"(":")" + charSpanToString(cmd.setupPIN) + R"(",)" + R"(")" + loginNodeFieldId + R"(":")" +
to_string(cmd.node.Value()) + R"("})";
std::to_string(cmd.node.Value()) + R"("})";
}

std::string serializeLogoutCommand(AccountLogin::Commands::Logout::Type cmd)
{
return R"({")" + logoutNodeFieldId + R"(":")" + to_string(cmd.node.Value()) + R"("})";
return R"({")" + logoutNodeFieldId + R"(":")" + std::to_string(cmd.node.Value()) + R"("})";
}

} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ CHIP_ERROR AppContentLauncherManager::HandleGetAcceptHeaderList(AttributeValueEn
Json::Value value;
if (reader.parse(resStr, value))
{
std::string attrId = to_string(chip::app::Clusters::ContentLauncher::Attributes::AcceptHeader::Id);
std::string attrId = std::to_string(chip::app::Clusters::ContentLauncher::Attributes::AcceptHeader::Id);
ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetAcceptHeaderList response parsing done. reading attr %s",
attrId.c_str());
if (value[attrId].isArray())
Expand Down Expand Up @@ -145,7 +145,7 @@ uint32_t AppContentLauncherManager::HandleGetSupportedStreamingProtocols()
{
return mSupportedStreamingProtocols;
}
std::string attrId = to_string(chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::Id);
std::string attrId = std::to_string(chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::Id);
ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetSupportedStreamingProtocols response parsing done. reading attr %s",
attrId.c_str());
if (!value[attrId].empty() && value[attrId].isInt())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ uint64_t AppMediaPlaybackManager::HandleMediaRequestGetAttribute(chip::Attribute
Json::Value value;
if (reader.parse(resStr, value))
{
std::string attrId = to_string(attributeId);
std::string attrId = std::to_string(attributeId);
ChipLogProgress(Zcl, "AppMediaPlaybackManager::HandleMediaRequestGetAttribute response parsing done. reading attr %s",
attrId.c_str());
if (!value[attrId].empty() && value[attrId].isUInt())
Expand Down Expand Up @@ -249,14 +249,14 @@ CHIP_ERROR AppMediaPlaybackManager::HandleGetSampledPosition(AttributeValueEncod
Json::Value value;
if (reader.parse(resStr, value))
{
std::string attrId = to_string(chip::app::Clusters::MediaPlayback::Attributes::SampledPosition::Id);
std::string attrId = std::to_string(chip::app::Clusters::MediaPlayback::Attributes::SampledPosition::Id);
ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetSampledPosition response parsing done. reading attr %s",
attrId.c_str());
if (!value[attrId].empty() && value[attrId].isObject())
{
std::string updatedAt = to_string(
std::string updatedAt = std::to_string(
static_cast<uint32_t>(chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::Fields::kUpdatedAt));
std::string position = to_string(
std::string position = std::to_string(
static_cast<uint32_t>(chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::Fields::kPosition));
if (!value[attrId][updatedAt].empty() && !value[attrId][position].empty() && value[attrId][updatedAt].isUInt() &&
value[attrId][position].isUInt())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ CHIP_ERROR TargetNavigatorManager::HandleGetTargetList(AttributeValueEncoder & a
Json::Value value;
if (reader.parse(resStr, value))
{
std::string attrId = to_string(chip::app::Clusters::TargetNavigator::Attributes::TargetList::Id);
std::string attrId = std::to_string(chip::app::Clusters::TargetNavigator::Attributes::TargetList::Id);
ChipLogProgress(Zcl, "TargetNavigatorManager::HandleNavigateTarget response parsing done. reading attr %s",
attrId.c_str());
if (value[attrId].isArray())
{
return aEncoder.EncodeList([&](const auto & encoder) -> CHIP_ERROR {
int i = 0;
std::string targetId = to_string(static_cast<uint32_t>(
std::string targetId = std::to_string(static_cast<uint32_t>(
chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Fields::kIdentifier));
std::string targetName = to_string(
std::string targetName = std::to_string(
static_cast<uint32_t>(chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Fields::kName));
for (Json::Value & entry : value[attrId])
{
Expand Down Expand Up @@ -117,7 +117,7 @@ uint8_t TargetNavigatorManager::HandleGetCurrentTarget()
Json::Value value;
if (reader.parse(resStr, value))
{
std::string attrId = to_string(chip::app::Clusters::TargetNavigator::Attributes::CurrentTarget::Id);
std::string attrId = std::to_string(chip::app::Clusters::TargetNavigator::Attributes::CurrentTarget::Id);
ChipLogProgress(Zcl, "TargetNavigatorManager::HandleGetCurrentTarget response parsing done. reading attr %s",
attrId.c_str());
if (value[attrId].isUInt() && value[attrId].asUInt() < 256)
Expand Down
54 changes: 27 additions & 27 deletions src/setup_payload/tests/TestQRCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ TEST(TestQRCode, TestPayloadByteArrayRep)
{
SetupPayload payload = GetDefaultPayload();

string expected = " 0000 000000000000000100000000000 000010000000 00000001 00 0000000000000001 0000000000001100 000";
std::string expected = " 0000 000000000000000100000000000 000010000000 00000001 00 0000000000000001 0000000000001100 000";
EXPECT_TRUE(CompareBinary(payload, expected));
}

Expand All @@ -129,7 +129,7 @@ TEST(TestQRCode, TestPayloadBase38Rep)
SetupPayload payload = GetDefaultPayload();

QRCodeSetupPayloadGenerator generator(payload);
string result;
std::string result;
CHIP_ERROR err = generator.payloadBase38Representation(result);
bool didSucceed = err == CHIP_NO_ERROR;
EXPECT_EQ(didSucceed, true);
Expand Down Expand Up @@ -240,10 +240,10 @@ TEST(TestQRCode, TestBase38)
base38Encode(ByteSpan((uint8_t *) "Hello World!", sizeof("Hello World!") - 1), encodedSpan);
EXPECT_STREQ(encodedBuf, "KKHF3W2S013OPM3EJX11");

vector<uint8_t> decoded = vector<uint8_t>();
std::vector<uint8_t> decoded = std::vector<uint8_t>();
EXPECT_EQ(base38Decode("KKHF3W2S013OPM3EJX11", decoded), CHIP_NO_ERROR);

string hello_world;
std::string hello_world;
for (uint8_t b : decoded)
{
hello_world += static_cast<char>(b);
Expand Down Expand Up @@ -346,8 +346,8 @@ TEST(TestQRCode, TestSetupPayloadVerify)

TEST(TestQRCode, TestInvalidQRCodePayload_WrongCharacterSet)
{
string invalidString = kDefaultPayloadQRCode;
invalidString.back() = ' '; // space is not contained in the base38 alphabet
std::string invalidString = kDefaultPayloadQRCode;
invalidString.back() = ' '; // space is not contained in the base38 alphabet

QRCodeSetupPayloadParser parser = QRCodeSetupPayloadParser(invalidString);
SetupPayload payload;
Expand All @@ -359,7 +359,7 @@ TEST(TestQRCode, TestInvalidQRCodePayload_WrongCharacterSet)

TEST(TestQRCode, TestInvalidQRCodePayload_WrongLength)
{
string invalidString = kDefaultPayloadQRCode;
std::string invalidString = kDefaultPayloadQRCode;
invalidString.pop_back();

QRCodeSetupPayloadParser parser = QRCodeSetupPayloadParser(invalidString);
Expand Down Expand Up @@ -394,7 +394,7 @@ TEST(TestQRCode, TestQRCodeToPayloadGeneration)
SetupPayload payload = GetDefaultPayload();

QRCodeSetupPayloadGenerator generator(payload);
string base38Rep;
std::string base38Rep;
CHIP_ERROR err = generator.payloadBase38Representation(base38Rep);
bool didSucceed = err == CHIP_NO_ERROR;
EXPECT_EQ(didSucceed, true);
Expand All @@ -421,7 +421,7 @@ TEST(TestQRCode, TestGenerateWithShortDiscriminatorInvalid)
EXPECT_FALSE(payload.isValidQRCodePayload());

// QRCodeSetupPayloadGenerator should therefore return an error
string base38Rep;
std::string base38Rep;
QRCodeSetupPayloadGenerator generator(payload);
EXPECT_EQ(generator.payloadBase38Representation(base38Rep), CHIP_ERROR_INVALID_ARGUMENT);

Expand All @@ -440,7 +440,7 @@ TEST(TestQRCode, TestGenerateWithoutRendezvousInformation)
EXPECT_FALSE(payload.isValidQRCodePayload());

// QRCodeSetupPayloadGenerator should therefore return an error
string base38Rep;
std::string base38Rep;
QRCodeSetupPayloadGenerator generator(payload);
EXPECT_EQ(generator.payloadBase38Representation(base38Rep), CHIP_ERROR_INVALID_ARGUMENT);

Expand All @@ -451,23 +451,23 @@ TEST(TestQRCode, TestGenerateWithoutRendezvousInformation)

TEST(TestQRCode, TestExtractPayload)
{
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("MT:ABC")), string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("MT:")), string(""));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("H:")), string(""));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("ASMT:")), string(""));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("Z%MT:ABC%")), string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("Z%MT:ABC")), string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("%Z%MT:ABC")), string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("%Z%MT:ABC%")), string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("%Z%MT:ABC%DDD")), string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("MT:ABC%DDD")), string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("MT:ABC%")), string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("%MT:")), string(""));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("%MT:%")), string(""));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("A%")), string(""));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("MT:%")), string(""));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("%MT:ABC")), string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("ABC")), string(""));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("MT:ABC")), std::string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("MT:")), std::string(""));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("H:")), std::string(""));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("ASMT:")), std::string(""));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("Z%MT:ABC%")), std::string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("Z%MT:ABC")), std::string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("%Z%MT:ABC")), std::string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("%Z%MT:ABC%")), std::string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("%Z%MT:ABC%DDD")), std::string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("MT:ABC%DDD")), std::string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("MT:ABC%")), std::string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("%MT:")), std::string(""));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("%MT:%")), std::string(""));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("A%")), std::string(""));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("MT:%")), std::string(""));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("%MT:ABC")), std::string("ABC"));
EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("ABC")), std::string(""));
}

} // namespace
24 changes: 12 additions & 12 deletions src/setup_payload/tests/TestQRCodeTLV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TestQRCodeTLV : public ::testing::Test
TEST_F(TestQRCodeTLV, TestOptionalDataAddRemove)
{
SetupPayload payload = GetDefaultPayload();
vector<OptionalQRCodeInfo> optionalData;
std::vector<OptionalQRCodeInfo> optionalData;
CHIP_ERROR err;

optionalData = payload.getAllOptionalVendorData();
Expand Down Expand Up @@ -85,11 +85,11 @@ TEST_F(TestQRCodeTLV, TestSimpleWrite)
SetupPayload inPayload = GetDefaultPayload();

QRCodeSetupPayloadGenerator generator(inPayload);
string result;
std::string result;
CHIP_ERROR err = generator.payloadBase38Representation(result);
EXPECT_EQ(err, CHIP_NO_ERROR);

string result2;
std::string result2;
err = generator.payloadBase38RepresentationWithAutoTLVBuffer(result2);
EXPECT_EQ(err, CHIP_NO_ERROR);

Expand All @@ -102,7 +102,7 @@ TEST_F(TestQRCodeTLV, TestSimpleRead)
SetupPayload outPayload;

QRCodeSetupPayloadGenerator generator(inPayload);
string result;
std::string result;
CHIP_ERROR err = generator.payloadBase38Representation(result);
EXPECT_EQ(err, CHIP_NO_ERROR);

Expand Down Expand Up @@ -138,7 +138,7 @@ TEST_F(TestQRCodeTLV, TestSerialNumberAddRemove)
{
SetupPayload inPayload = GetDefaultPayload();

string sn;
std::string sn;
EXPECT_EQ(inPayload.getSerialNumber(sn), CHIP_ERROR_KEY_NOT_FOUND);
EXPECT_EQ(inPayload.removeSerialNumber(), CHIP_ERROR_KEY_NOT_FOUND);

Expand All @@ -148,7 +148,7 @@ TEST_F(TestQRCodeTLV, TestSerialNumberAddRemove)

EXPECT_EQ(inPayload.addSerialNumber(kSerialNumberDefaultUInt32Value), CHIP_NO_ERROR);
EXPECT_EQ(inPayload.getSerialNumber(sn), CHIP_NO_ERROR);
EXPECT_EQ(sn, to_string(kSerialNumberDefaultUInt32Value));
EXPECT_EQ(sn, std::to_string(kSerialNumberDefaultUInt32Value));

EXPECT_EQ(inPayload.removeSerialNumber(), CHIP_NO_ERROR);
EXPECT_EQ(inPayload.getSerialNumber(sn), CHIP_ERROR_KEY_NOT_FOUND);
Expand All @@ -163,15 +163,15 @@ TEST_F(TestQRCodeTLV, TestOptionalDataWriteSerial)
EXPECT_EQ(err, CHIP_NO_ERROR);

QRCodeSetupPayloadGenerator generator(inPayload);
string result;
std::string result;
err = generator.payloadBase38Representation(result);
EXPECT_NE(err, CHIP_NO_ERROR);

uint8_t optionalInfo[kDefaultBufferSizeInBytes];
err = generator.payloadBase38Representation(result, optionalInfo, sizeof(optionalInfo));
EXPECT_EQ(err, CHIP_NO_ERROR);

string result2;
std::string result2;
err = generator.payloadBase38RepresentationWithAutoTLVBuffer(result2);
EXPECT_EQ(err, CHIP_NO_ERROR);

Expand All @@ -183,12 +183,12 @@ TEST_F(TestQRCodeTLV, TestOptionalDataWrite)
SetupPayload inPayload = GetDefaultPayloadWithOptionalDefaults();

QRCodeSetupPayloadGenerator generator(inPayload);
string result;
std::string result;
uint8_t optionalInfo[kDefaultBufferSizeInBytes];
CHIP_ERROR err = generator.payloadBase38Representation(result, optionalInfo, sizeof(optionalInfo));
EXPECT_EQ(err, CHIP_NO_ERROR);

string result2;
std::string result2;
err = generator.payloadBase38RepresentationWithAutoTLVBuffer(result2);
EXPECT_EQ(err, CHIP_NO_ERROR);

Expand Down Expand Up @@ -234,7 +234,7 @@ TEST_F(TestQRCodeTLV, TestOptionalDataWriteNoBuffer)
SetupPayload inPayload = GetDefaultPayloadWithOptionalDefaults();

QRCodeSetupPayloadGenerator generator(inPayload);
string result;
std::string result;
CHIP_ERROR err = generator.payloadBase38Representation(result);
EXPECT_NE(err, CHIP_NO_ERROR);
}
Expand All @@ -244,7 +244,7 @@ TEST_F(TestQRCodeTLV, TestOptionalDataWriteSmallBuffer)
SetupPayload inPayload = GetDefaultPayloadWithOptionalDefaults();

QRCodeSetupPayloadGenerator generator(inPayload);
string result;
std::string result;
uint8_t optionalInfo[kSmallBufferSizeInBytes];
CHIP_ERROR err = generator.payloadBase38Representation(result, optionalInfo, sizeof(optionalInfo));
EXPECT_NE(err, CHIP_NO_ERROR);
Expand Down

0 comments on commit e9ac903

Please sign in to comment.