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 9d5df91
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
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 9d5df91

Please sign in to comment.