Skip to content

Commit

Permalink
fix apple clang build (#202)
Browse files Browse the repository at this point in the history
Co-authored-by: Michal Cieslar <[email protected]>
  • Loading branch information
cieslarmichal and Michal Cieslar authored Oct 11, 2023
1 parent 734edcb commit 11cc926
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/modules/color/ColorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,13 @@ TEST_F(ColorTest, shouldGenerateHslWithAlpha)
const auto hslValues = faker::StringHelper::split(generatedHslaColor.substr(5, generatedHslaColor.size() - 1), " ");

int hue, staturation, lightness;
double alpha;

std::from_chars(hslValues[0].data(), hslValues[0].data() + hslValues[0].size(), hue);
std::from_chars(hslValues[1].data(), hslValues[1].data() + hslValues[1].size(), staturation);
std::from_chars(hslValues[2].data(), hslValues[2].data() + hslValues[2].size(), lightness);
std::from_chars(hslValues[3].data(), hslValues[3].data() + hslValues[3].size(), alpha);

auto offset = hslValues[3].size();
const auto alpha = std::stod(hslValues[3].data(), &offset);

ASSERT_TRUE(generatedHslaColor.starts_with("hsla("));
ASSERT_TRUE(generatedHslaColor.ends_with(")"));
Expand Down
4 changes: 2 additions & 2 deletions src/modules/commerce/CommerceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ TEST_F(CommerceTest, shouldGeneratePrice)
{
const auto generatedPrice = Commerce::price(100, 10000);

auto priceAsFloat{0.0f};
std::from_chars(generatedPrice.data(), generatedPrice.data() + generatedPrice.size(), priceAsFloat);
auto offset = generatedPrice.size();
const auto priceAsFloat = std::stof(generatedPrice.data(), &offset);

const auto generatedPriceElements = StringHelper::split(generatedPrice, ".");

Expand Down
5 changes: 3 additions & 2 deletions src/modules/finance/FinanceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,10 @@ TEST_F(FinanceTest, shouldGenerateAccountType)

TEST_F(FinanceTest, shouldGenerateAmount)
{
auto amountAsFloat{0.0f};
const auto generatedAmount = Finance::amount();
std::from_chars(generatedAmount.data(), generatedAmount.data() + generatedAmount.size(), amountAsFloat);

auto offset = generatedAmount.size();
const auto amountAsFloat = std::stof(generatedAmount.data(), &offset);

const auto generatedAmountParts = StringHelper::split(generatedAmount, ".");

Expand Down
16 changes: 8 additions & 8 deletions src/modules/location/LocationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ TEST_F(LocationTest, shouldGenerateLatitude)
{
const auto latitude = Location::latitude();

auto latitudeAsFloat{0.0f};
std::from_chars(latitude.data(), latitude.data() + latitude.size(), latitudeAsFloat);
auto offset = latitude.size();
const auto latitudeAsFloat = std::stof(latitude.data(), &offset);

const auto generatedLatitudeParts = StringHelper::split(latitude, ".");

Expand All @@ -326,8 +326,8 @@ TEST_F(LocationTest, shouldGenerateLatitudeWithSpecifiedPrecision)
{
const auto latitude = Location::latitude(Precision::ThreeDp);

auto latitudeAsFloat{0.0f};
std::from_chars(latitude.data(), latitude.data() + latitude.size(), latitudeAsFloat);
auto offset = latitude.size();
const auto latitudeAsFloat = std::stof(latitude.data(), &offset);

const auto generatedLatitudeParts = StringHelper::split(latitude, ".");

Expand All @@ -341,8 +341,8 @@ TEST_F(LocationTest, shouldGenerateLongitude)
{
const auto longitude = Location::longitude();

auto longitudeAsFloat{0.0f};
std::from_chars(longitude.data(), longitude.data() + longitude.size(), longitudeAsFloat);
auto offset = longitude.size();
const auto longitudeAsFloat = std::stof(longitude.data(), &offset);

const auto generatedLongitudeParts = StringHelper::split(longitude, ".");

Expand All @@ -356,8 +356,8 @@ TEST_F(LocationTest, shouldGenerateLongitudeWithSpecifiedPrecision)
{
const auto longitude = Location::longitude(Precision::SixDp);

auto longitudeAsFloat{0.0f};
std::from_chars(longitude.data(), longitude.data() + longitude.size(), longitudeAsFloat);
auto offset = longitude.size();
const auto longitudeAsFloat = std::stof(longitude.data(), &offset);

const auto generatedLongitudeParts = StringHelper::split(longitude, ".");

Expand Down

0 comments on commit 11cc926

Please sign in to comment.