From f32abbd70994860173df10a210b172410573105d Mon Sep 17 00:00:00 2001 From: Michal Cieslar Date: Wed, 11 Oct 2023 11:08:30 +0200 Subject: [PATCH] fix apple clang build --- src/modules/color/ColorTest.cpp | 5 +++-- src/modules/commerce/CommerceTest.cpp | 4 ++-- src/modules/finance/FinanceTest.cpp | 5 +++-- src/modules/location/LocationTest.cpp | 16 ++++++++-------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/modules/color/ColorTest.cpp b/src/modules/color/ColorTest.cpp index e4d11a5f8..7aa74d130 100644 --- a/src/modules/color/ColorTest.cpp +++ b/src/modules/color/ColorTest.cpp @@ -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(")")); diff --git a/src/modules/commerce/CommerceTest.cpp b/src/modules/commerce/CommerceTest.cpp index 456e30946..ed49b5248 100644 --- a/src/modules/commerce/CommerceTest.cpp +++ b/src/modules/commerce/CommerceTest.cpp @@ -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, "."); diff --git a/src/modules/finance/FinanceTest.cpp b/src/modules/finance/FinanceTest.cpp index 198543721..e4a30298f 100644 --- a/src/modules/finance/FinanceTest.cpp +++ b/src/modules/finance/FinanceTest.cpp @@ -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, "."); diff --git a/src/modules/location/LocationTest.cpp b/src/modules/location/LocationTest.cpp index 40f99e7ac..51dfd77cb 100644 --- a/src/modules/location/LocationTest.cpp +++ b/src/modules/location/LocationTest.cpp @@ -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, "."); @@ -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, "."); @@ -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, "."); @@ -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, ".");