From 9d5df91fad43b6dc0508b9c00c3494b2e05aa8da Mon Sep 17 00:00:00 2001 From: Rohit Jadhav Date: Tue, 24 Sep 2024 16:01:19 +0530 Subject: [PATCH] Fix compilation --- src/setup_payload/tests/TestQRCode.cpp | 54 +++++++++++------------ src/setup_payload/tests/TestQRCodeTLV.cpp | 24 +++++----- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/setup_payload/tests/TestQRCode.cpp b/src/setup_payload/tests/TestQRCode.cpp index 25cb4cea8089f7..ce5048489113e6 100644 --- a/src/setup_payload/tests/TestQRCode.cpp +++ b/src/setup_payload/tests/TestQRCode.cpp @@ -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)); } @@ -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); @@ -240,10 +240,10 @@ TEST(TestQRCode, TestBase38) base38Encode(ByteSpan((uint8_t *) "Hello World!", sizeof("Hello World!") - 1), encodedSpan); EXPECT_STREQ(encodedBuf, "KKHF3W2S013OPM3EJX11"); - vector decoded = vector(); + std::vector decoded = std::vector(); EXPECT_EQ(base38Decode("KKHF3W2S013OPM3EJX11", decoded), CHIP_NO_ERROR); - string hello_world; + std::string hello_world; for (uint8_t b : decoded) { hello_world += static_cast(b); @@ -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; @@ -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); @@ -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); @@ -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); @@ -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); @@ -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 diff --git a/src/setup_payload/tests/TestQRCodeTLV.cpp b/src/setup_payload/tests/TestQRCodeTLV.cpp index 27e7027101ae18..3cada5cb505264 100644 --- a/src/setup_payload/tests/TestQRCodeTLV.cpp +++ b/src/setup_payload/tests/TestQRCodeTLV.cpp @@ -37,7 +37,7 @@ class TestQRCodeTLV : public ::testing::Test TEST_F(TestQRCodeTLV, TestOptionalDataAddRemove) { SetupPayload payload = GetDefaultPayload(); - vector optionalData; + std::vector optionalData; CHIP_ERROR err; optionalData = payload.getAllOptionalVendorData(); @@ -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); @@ -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); @@ -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); @@ -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); @@ -163,7 +163,7 @@ 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); @@ -171,7 +171,7 @@ TEST_F(TestQRCodeTLV, TestOptionalDataWriteSerial) 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); @@ -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); @@ -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); } @@ -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);