This commit is contained in:
Daniel Lemire 2024-08-22 15:41:04 -04:00
parent 311e4c20d4
commit 9cebeb1c2c
2 changed files with 7 additions and 6 deletions

View File

@ -199,7 +199,7 @@ from_chars(UC const *first, UC const *last, T &value,
template <typename T, typename UC> template <typename T, typename UC>
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC> FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
from_chars_advanced(parsed_number_string_t<UC> &pns, T &value) noexcept { from_chars_advanced(parsed_number_string_t<UC> &pns, T &value) noexcept {
printf("from_chars_advanced\n"); printf("from_chars_advanced\n");
static_assert(is_supported_float_type<T>(), static_assert(is_supported_float_type<T>(),
"only some floating-point types are supported"); "only some floating-point types are supported");
static_assert(is_supported_char_type<UC>(), static_assert(is_supported_char_type<UC>(),

View File

@ -79,11 +79,14 @@ const char *round_name(int d) {
TEST_CASE("issue261") { TEST_CASE("issue261") {
std::string_view str = "5.47382e-48"; std::string_view str = "5.47382e-48";
float value = 100.0f; float value = 100.0f;
auto res = fast_float::from_chars(str.data(), str.data() + str.size(), value, fast_float::general); auto res = fast_float::from_chars(str.data(), str.data() + str.size(), value,
CHECK_MESSAGE(res.ec == std::errc::result_out_of_range, "value is out of range (interpretation of the standard)"); fast_float::general);
CHECK_MESSAGE(res.ec == std::errc::result_out_of_range,
"value is out of range (interpretation of the standard)");
std::cout << "value = " << fHexAndDec(value) << std::endl; std::cout << "value = " << fHexAndDec(value) << std::endl;
CHECK_MESSAGE(value == 100.0f, "value should be unchanged"); CHECK_MESSAGE(value == 100.0f, "value should be unchanged");
CHECK_MESSAGE(res.ptr == str.data() + str.size(), "should point to end of matching pattern"); CHECK_MESSAGE(res.ptr == str.data() + str.size(),
"should point to end of matching pattern");
} }
TEST_CASE("system_info") { TEST_CASE("system_info") {
std::cout << "system info:" << std::endl; std::cout << "system info:" << std::endl;
@ -409,8 +412,6 @@ TEST_CASE("full_multiplication") {
test_full_multiplication(bit << 63, bit << 63, 0u, bit << 62); test_full_multiplication(bit << 63, bit << 63, 0u, bit << 62);
} }
TEST_CASE("issue8") { TEST_CASE("issue8") {
const char *s = const char *s =
"3." "3."