Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address compiler warnings. #701

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/faker-cxx/Helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Helper
template <typename It>
static auto arrayElement(It start, It end) -> decltype(*::std::declval<It>())
{
size_t size = end - start;
size_t size = static_cast<size_t>(end - start);

if (size == 0)
{
Expand Down
7 changes: 3 additions & 4 deletions src/modules/crypto/Crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>(
(static_cast<uint32_t>(m_data[j]) << 24) | (static_cast<uint32_t>(m_data[j + 1]) << 16) |
(static_cast<uint32_t>(m_data[j + 2]) << 8) | static_cast<uint32_t>(m_data[j + 3]));
m[i] = (static_cast<uint32_t>(m_data[j]) << 24) | (static_cast<uint32_t>(m_data[j + 1]) << 16) |
(static_cast<uint32_t>(m_data[j + 2]) << 8) | static_cast<uint32_t>(m_data[j + 3]);
}

for (uint8_t k = 16; k < 64; k++)
Expand Down Expand Up @@ -437,7 +436,7 @@ void SHA256::revert(std::array<uint8_t, 32>& hash)
{
for (uint8_t j = 0; j < 8; j++)
{
hash[i + (j * 4)] = (m_state[j] >> (24 - i * 8)) & 0x000000ff;
hash[static_cast<uint8_t>(i + (j * 4))] = (m_state[j] >> (24 - i * 8)) & 0x000000ff;
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/modules/datatype/Datatype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
8 changes: 4 additions & 4 deletions tests/modules/finance/FinanceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Finance::IbanCountry>& info)
{ return generatedTestName.at(info.param); });
[](const TestParamInfo<Finance::IbanCountry>& paramInfo)
{ return generatedTestName.at(paramInfo.param); });

TEST_F(FinanceTest, shouldGenerateAmountWithSymbol)
{
Expand Down Expand Up @@ -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<Finance::BicCountry>& info)
{ return generatedBicTestName.at(info.param); });
[](const TestParamInfo<Finance::BicCountry>& paramInfo)
{ return generatedBicTestName.at(paramInfo.param); });
3 changes: 2 additions & 1 deletion tests/modules/location/LocationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ TEST_P(LocationTest, shouldGenerateSecondaryAddress)
}

INSTANTIATE_TEST_SUITE_P(TestLocationByCountries, LocationTest, ValuesIn(addressCountries),
[](const TestParamInfo<AddressCountry>& info) { return generatedTestName.at(info.param); });
[](const TestParamInfo<AddressCountry>& paramInfo)
{ return generatedTestName.at(paramInfo.param); });

TEST_F(LocationTest, shouldGenerateUsaStreet)
{
Expand Down
10 changes: 5 additions & 5 deletions tests/modules/person/PersonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ TEST_P(PersonTest, shouldGenerateFemaleFullName)
}

INSTANTIATE_TEST_SUITE_P(TestPersonNamesByCountries, PersonTest, ValuesIn(countries),
[](const TestParamInfo<Country>& info) { return generatedTestName.at(info.param); });
[](const TestParamInfo<Country>& paramInfo) { return generatedTestName.at(paramInfo.param); });

// TODO: move to parameterized tests
TEST_F(PersonTest, shouldGeneratePrefix)
Expand Down Expand Up @@ -609,9 +609,9 @@ std::string toString(Language language)
}

INSTANTIATE_TEST_SUITE_P(TestPersonSexTranslation, PersonSexSuite, testing::ValuesIn(languageSexPairs),
[](const testing::TestParamInfo<PersonSexSuite::ParamType>& info)
[](const testing::TestParamInfo<PersonSexSuite::ParamType>& paramInfo)
{
auto param = info.param;
auto param = paramInfo.param;
return toString(param.first) + "_" + toString(param.second);
});

Expand Down Expand Up @@ -647,8 +647,8 @@ std::string toString(SsnCountry country)
}

INSTANTIATE_TEST_SUITE_P(TestPersonSsn, PersonSsnSuite, testing::ValuesIn(supportedSsnCountries),
[](const testing::TestParamInfo<PersonSsnSuite::ParamType>& info)
{ return "shouldGenerate" + toString(info.param) + "Ssn"; });
[](const testing::TestParamInfo<PersonSsnSuite::ParamType>& paramInfo)
{ return "shouldGenerate" + toString(paramInfo.param) + "Ssn"; });

class PersonPassportTest : public Test
{
Expand Down
Loading