From 3a6ff92f9954c0e787cc29acd5858375ca70d264 Mon Sep 17 00:00:00 2001 From: AnkitGourav Date: Thu, 20 Jun 2024 16:26:48 +0530 Subject: [PATCH] Address compiler warnings. Signed-off-by: AnkitGourav --- include/faker-cxx/Helper.h | 2 +- src/modules/crypto/Crypto.cpp | 7 +++---- src/modules/datatype/Datatype.cpp | 10 +++++----- tests/modules/finance/FinanceTest.cpp | 8 ++++---- tests/modules/location/LocationTest.cpp | 3 ++- tests/modules/person/PersonTest.cpp | 10 +++++----- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/faker-cxx/Helper.h b/include/faker-cxx/Helper.h index f9216ce7f..093910151 100644 --- a/include/faker-cxx/Helper.h +++ b/include/faker-cxx/Helper.h @@ -60,7 +60,7 @@ class Helper template static auto arrayElement(It start, It end) -> decltype(*::std::declval()) { - size_t size = end - start; + size_t size = static_cast(end - start); if (size == 0) { diff --git a/src/modules/crypto/Crypto.cpp b/src/modules/crypto/Crypto.cpp index ea4e4dc6c..104047ede 100644 --- a/src/modules/crypto/Crypto.cpp +++ b/src/modules/crypto/Crypto.cpp @@ -355,9 +355,8 @@ void SHA256::transform() for (uint8_t i = 0, j = 0; i < 16; i++, j += 4) { // Split data in 32 bit blocks for the 16 first words // m[i] = (m_data[j] << 24) | (m_data[j + 1] << 16) | (m_data[j + 2] << 8) | (m_data[j + 3]); - m[i] = static_cast( - (static_cast(m_data[j]) << 24) | (static_cast(m_data[j + 1]) << 16) | - (static_cast(m_data[j + 2]) << 8) | static_cast(m_data[j + 3])); + m[i] = (static_cast(m_data[j]) << 24) | (static_cast(m_data[j + 1]) << 16) | + (static_cast(m_data[j + 2]) << 8) | static_cast(m_data[j + 3]); } for (uint8_t k = 16; k < 64; k++) @@ -437,7 +436,7 @@ void SHA256::revert(std::array& hash) { for (uint8_t j = 0; j < 8; j++) { - hash[i + (j * 4)] = (m_state[j] >> (24 - i * 8)) & 0x000000ff; + hash[static_cast(i + (j * 4))] = (m_state[j] >> (24 - i * 8)) & 0x000000ff; } } } diff --git a/src/modules/datatype/Datatype.cpp b/src/modules/datatype/Datatype.cpp index d5c027d56..f800392fa 100644 --- a/src/modules/datatype/Datatype.cpp +++ b/src/modules/datatype/Datatype.cpp @@ -13,23 +13,23 @@ bool Datatype::boolean() bool Datatype::boolean(double probability) { - if (probability != NAN) + if (probability != nan("")) { double prob = probability; - if (prob <= 0.f) + if (prob <= 0.) { return false; } - if (prob >= 1.f) + if (prob >= 1.) { return true; } - return Number::decimal(0.f, 1.f) < prob; + return Number::decimal(0., 1.) < prob; } - return Number::decimal(0.f, 1.f) < 0.5f; + return Number::decimal(0., 1.) < 0.5; } } diff --git a/tests/modules/finance/FinanceTest.cpp b/tests/modules/finance/FinanceTest.cpp index 4a2ac2c2d..ea2a3cb16 100644 --- a/tests/modules/finance/FinanceTest.cpp +++ b/tests/modules/finance/FinanceTest.cpp @@ -202,8 +202,8 @@ TEST_P(FinanceTest, CheckIbanGenerator) INSTANTIATE_TEST_SUITE_P(TestIbanGenerator, FinanceTest, ValuesIn(std::views::keys(expectedRegex).begin(), std::views::keys(expectedRegex).end()), - [](const TestParamInfo& info) - { return generatedTestName.at(info.param); }); + [](const TestParamInfo& paramInfo) + { return generatedTestName.at(paramInfo.param); }); TEST_F(FinanceTest, shouldGenerateAmountWithSymbol) { @@ -432,5 +432,5 @@ INSTANTIATE_TEST_SUITE_P(TestBicGenerator, FinanceBicTest, Finance::BicCountry::Romania, Finance::BicCountry::France, Finance::BicCountry::Italy, Finance::BicCountry::Spain, Finance::BicCountry::Netherlands, Finance::BicCountry::India), - [](const TestParamInfo& info) - { return generatedBicTestName.at(info.param); }); + [](const TestParamInfo& paramInfo) + { return generatedBicTestName.at(paramInfo.param); }); diff --git a/tests/modules/location/LocationTest.cpp b/tests/modules/location/LocationTest.cpp index 06b763de5..91f12236c 100644 --- a/tests/modules/location/LocationTest.cpp +++ b/tests/modules/location/LocationTest.cpp @@ -272,7 +272,8 @@ TEST_P(LocationTest, shouldGenerateSecondaryAddress) } INSTANTIATE_TEST_SUITE_P(TestLocationByCountries, LocationTest, ValuesIn(addressCountries), - [](const TestParamInfo& info) { return generatedTestName.at(info.param); }); + [](const TestParamInfo& paramInfo) + { return generatedTestName.at(paramInfo.param); }); TEST_F(LocationTest, shouldGenerateUsaStreet) { diff --git a/tests/modules/person/PersonTest.cpp b/tests/modules/person/PersonTest.cpp index cbcecf3ce..6bbaf5047 100644 --- a/tests/modules/person/PersonTest.cpp +++ b/tests/modules/person/PersonTest.cpp @@ -393,7 +393,7 @@ TEST_P(PersonTest, shouldGenerateFemaleFullName) } INSTANTIATE_TEST_SUITE_P(TestPersonNamesByCountries, PersonTest, ValuesIn(countries), - [](const TestParamInfo& info) { return generatedTestName.at(info.param); }); + [](const TestParamInfo& paramInfo) { return generatedTestName.at(paramInfo.param); }); // TODO: move to parameterized tests TEST_F(PersonTest, shouldGeneratePrefix) @@ -609,9 +609,9 @@ std::string toString(Language language) } INSTANTIATE_TEST_SUITE_P(TestPersonSexTranslation, PersonSexSuite, testing::ValuesIn(languageSexPairs), - [](const testing::TestParamInfo& info) + [](const testing::TestParamInfo& paramInfo) { - auto param = info.param; + auto param = paramInfo.param; return toString(param.first) + "_" + toString(param.second); }); @@ -647,8 +647,8 @@ std::string toString(SsnCountry country) } INSTANTIATE_TEST_SUITE_P(TestPersonSsn, PersonSsnSuite, testing::ValuesIn(supportedSsnCountries), - [](const testing::TestParamInfo& info) - { return "shouldGenerate" + toString(info.param) + "Ssn"; }); + [](const testing::TestParamInfo& paramInfo) + { return "shouldGenerate" + toString(paramInfo.param) + "Ssn"; }); class PersonPassportTest : public Test {