mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 01:06:48 +08:00
lint
This commit is contained in:
parent
1ab438cf7a
commit
929e98182e
@ -23,10 +23,11 @@ namespace detail {
|
|||||||
template <typename T, typename UC>
|
template <typename T, typename UC>
|
||||||
from_chars_result_t<UC>
|
from_chars_result_t<UC>
|
||||||
FASTFLOAT_CONSTEXPR14 parse_infnan(UC const *first, UC const *last,
|
FASTFLOAT_CONSTEXPR14 parse_infnan(UC const *first, UC const *last,
|
||||||
T &value, const chars_format fmt) noexcept {
|
T &value,
|
||||||
|
const chars_format fmt) noexcept {
|
||||||
from_chars_result_t<UC> answer{};
|
from_chars_result_t<UC> answer{};
|
||||||
answer.ptr = first;
|
answer.ptr = first;
|
||||||
answer.ec = std::errc(); // be optimistic
|
answer.ec = std::errc(); // be optimistic
|
||||||
FASTFLOAT_ASSUME(first < last); // so dereference without checks
|
FASTFLOAT_ASSUME(first < last); // so dereference without checks
|
||||||
|
|
||||||
bool const minusSign = (*first == UC('-'));
|
bool const minusSign = (*first == UC('-'));
|
||||||
@ -254,9 +255,9 @@ from_chars_advanced(parsed_number_string_t<UC> const &pns, T &value) noexcept {
|
|||||||
if (pns.mantissa == 0) {
|
if (pns.mantissa == 0) {
|
||||||
value =
|
value =
|
||||||
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||||
pns.negative ? T(-0.) :
|
pns.negative ? T(-0.) :
|
||||||
#endif
|
#endif
|
||||||
T(0.);
|
T(0.);
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -286,9 +287,9 @@ from_chars_advanced(parsed_number_string_t<UC> const &pns, T &value) noexcept {
|
|||||||
}
|
}
|
||||||
to_float(
|
to_float(
|
||||||
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||||
pns.negative,
|
pns.negative,
|
||||||
#endif
|
#endif
|
||||||
am, value);
|
am, value);
|
||||||
// Test for over/underflow.
|
// Test for over/underflow.
|
||||||
if ((pns.mantissa != 0 && am.mantissa == 0 && am.power2 == 0) ||
|
if ((pns.mantissa != 0 && am.mantissa == 0 && am.power2 == 0) ||
|
||||||
am.power2 == binary_format<T>::infinite_power()) {
|
am.power2 == binary_format<T>::infinite_power()) {
|
||||||
@ -329,7 +330,7 @@ from_chars_float_advanced(UC const *first, UC const *last, T &value,
|
|||||||
? parse_number_string<true, UC>(first, last, options)
|
? parse_number_string<true, UC>(first, last, options)
|
||||||
:
|
:
|
||||||
#endif
|
#endif
|
||||||
parse_number_string<false, UC>(first, last, options);
|
parse_number_string<false, UC>(first, last, options);
|
||||||
if (!pns.valid) {
|
if (!pns.valid) {
|
||||||
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||||
if (uint64_t(options.format & chars_format::no_infnan)) {
|
if (uint64_t(options.format & chars_format::no_infnan)) {
|
||||||
|
|||||||
@ -656,8 +656,7 @@ TEST_CASE("decimal_point_parsing") {
|
|||||||
|
|
||||||
answer = fast_float::from_chars_advanced(
|
answer = fast_float::from_chars_advanced(
|
||||||
input.data(), input.data() + input.size(), result,
|
input.data(), input.data() + input.size(), result,
|
||||||
fast_float::parse_options(fast_float::chars_format::general, ',', 10)
|
fast_float::parse_options(fast_float::chars_format::general, ',', 10));
|
||||||
);
|
|
||||||
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
|
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
|
||||||
CHECK_MESSAGE(answer.ptr == input.data() + input.size(),
|
CHECK_MESSAGE(answer.ptr == input.data() + input.size(),
|
||||||
"Parsing should have stopped at end");
|
"Parsing should have stopped at end");
|
||||||
@ -667,8 +666,7 @@ TEST_CASE("decimal_point_parsing") {
|
|||||||
std::string const input = "1.25";
|
std::string const input = "1.25";
|
||||||
auto answer = fast_float::from_chars_advanced(
|
auto answer = fast_float::from_chars_advanced(
|
||||||
input.data(), input.data() + input.size(), result,
|
input.data(), input.data() + input.size(), result,
|
||||||
fast_float::parse_options(fast_float::chars_format::general, ',', 10)
|
fast_float::parse_options(fast_float::chars_format::general, ',', 10));
|
||||||
);
|
|
||||||
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
|
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
|
||||||
CHECK_MESSAGE(answer.ptr == input.data() + 1,
|
CHECK_MESSAGE(answer.ptr == input.data() + 1,
|
||||||
"Parsing should have stopped at dot");
|
"Parsing should have stopped at dot");
|
||||||
@ -676,8 +674,7 @@ TEST_CASE("decimal_point_parsing") {
|
|||||||
|
|
||||||
answer = fast_float::from_chars_advanced(
|
answer = fast_float::from_chars_advanced(
|
||||||
input.data(), input.data() + input.size(), result,
|
input.data(), input.data() + input.size(), result,
|
||||||
fast_float::parse_options{}
|
fast_float::parse_options{});
|
||||||
);
|
|
||||||
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
|
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
|
||||||
CHECK_MESSAGE(answer.ptr == input.data() + input.size(),
|
CHECK_MESSAGE(answer.ptr == input.data() + input.size(),
|
||||||
"Parsing should have stopped at end");
|
"Parsing should have stopped at end");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user