Skip to content

Commit 59c873d

Browse files
committed
cleanup.
1 parent 62bc4b4 commit 59c873d

File tree

1 file changed

+21
-37
lines changed

1 file changed

+21
-37
lines changed

tests/basictest.cpp

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@
2121
#endif // #ifndef FASTFLOAT_CONSTEXPR_TESTS
2222
#endif // FASTFLOAT_IS_CONSTEXPR
2323

24-
// MSVC's constexpr evaluation and some constexpr-friendly std library pieces
25-
// (like i/o and certain std::numeric_limits members) aren't suitable for the
26-
// compile-time tests in this file on MSVC; disable the constexpr tests when
27-
// compiling with MSVC (but allow them for clang/clang-cl).
28-
#if defined(_MSC_VER) && !defined(__clang__)
29-
#ifdef FASTFLOAT_CONSTEXPR_TESTS
30-
#undef FASTFLOAT_CONSTEXPR_TESTS
31-
#endif
32-
#endif
33-
3424
#if FASTFLOAT_HAS_BIT_CAST
3525
#include <bit>
3626
#endif
@@ -79,7 +69,7 @@ template <typename T> std::string fHexAndDec(T v) {
7969
return ss.str();
8070
}
8171

82-
constexpr std::string_view round_name(int const d) noexcept {
72+
char const *round_name(int d) {
8373
switch (d) {
8474
case FE_UPWARD:
8575
return "FE_UPWARD";
@@ -117,9 +107,9 @@ TEST_CASE("system_info") {
117107
#endif
118108
#ifdef FASTFLOAT_IS_BIG_ENDIAN
119109
#if FASTFLOAT_IS_BIG_ENDIAN
120-
std::cout << "big endian" << std::endl;
110+
printf("big endian\n");
121111
#else
122-
std::cout << "little endian" << std::endl;
112+
printf("little endian\n");
123113
#endif
124114
#endif
125115
#ifdef FASTFLOAT_32BIT
@@ -628,7 +618,7 @@ TEST_CASE("issue8") {
628618
"752384674818467669405132000568127145263560827785771342757789609173637178"
629619
"721468440901224953430146549585371050792279689258923542019956112129021960"
630620
"864034418159813629774771309960518707211349999998372978";
631-
for (int i = 0; i != 16; ++i) {
621+
for (int i = 0; i < 16; i++) {
632622
// Parse all but the last i chars. We should still get 3.141ish.
633623
double d = 0.0;
634624
auto answer = fast_float::from_chars(s, s + strlen(s) - i, d);
@@ -929,9 +919,9 @@ uint16_t get_mantissa(std::bfloat16_t f) {
929919
}
930920
#endif
931921

932-
std::string append_zeros(std::string_view str, size_t const number_of_zeros) {
922+
std::string append_zeros(std::string str, size_t number_of_zeros) {
933923
std::string answer(str);
934-
for (size_t i = 0; i++ != number_of_zeros;) {
924+
for (size_t i = 0; i < number_of_zeros; i++) {
935925
answer += "0";
936926
}
937927
return answer;
@@ -957,7 +947,7 @@ constexpr void check_basic_test_result(stringtype str, result_type result,
957947
#define FASTFLOAT_CHECK_EQ(...) \
958948
if constexpr (diag == Diag::runtime) { \
959949
char narrow[global_string_capacity]{}; \
960-
for (size_t i = 0; i++ != str.size();) { \
950+
for (size_t i = 0; i < str.size(); i++) { \
961951
narrow[i] = char(str[i]); \
962952
} \
963953
INFO("str(char" << 8 * sizeof(typename stringtype::value_type) \
@@ -1016,7 +1006,7 @@ constexpr void basic_test(std::string_view str, T expected,
10161006

10171007
// We give plenty of memory: 2048 characters.
10181008
char16_t u16[global_string_capacity]{};
1019-
for (size_t i = 0; i++ != str.size();) {
1009+
for (size_t i = 0; i < str.size(); i++) {
10201010
u16[i] = char16_t(str[i]);
10211011
}
10221012

@@ -1025,7 +1015,7 @@ constexpr void basic_test(std::string_view str, T expected,
10251015
actual, expected, expected_ec);
10261016

10271017
char32_t u32[global_string_capacity]{};
1028-
for (size_t i = 0; i++ != str.size();) {
1018+
for (size_t i = 0; i < str.size(); i++) {
10291019
u32[i] = char32_t(str[i]);
10301020
}
10311021

@@ -2136,9 +2126,8 @@ TEST_CASE("bfloat16.general") {
21362126
#endif
21372127

21382128
template <typename Int, typename T, typename U>
2139-
void verify_integer_times_pow10_result(Int const mantissa,
2140-
int_fast16_t const decimal_exponent,
2141-
T const actual, U const expected) {
2129+
void verify_integer_times_pow10_result(Int mantissa, int decimal_exponent,
2130+
T actual, U expected) {
21422131
static_assert(std::is_same<T, U>::value,
21432132
"expected and actual types must match");
21442133

@@ -2155,8 +2144,8 @@ void verify_integer_times_pow10_result(Int const mantissa,
21552144
}
21562145

21572146
template <typename T, typename Int>
2158-
T calculate_integer_times_pow10_expected_result(
2159-
Int const mantissa, int_fast16_t const decimal_exponent) {
2147+
T calculate_integer_times_pow10_expected_result(Int mantissa,
2148+
int decimal_exponent) {
21602149
std::string constructed_string =
21612150
std::to_string(mantissa) + "e" + std::to_string(decimal_exponent);
21622151
T expected_result;
@@ -2169,9 +2158,8 @@ T calculate_integer_times_pow10_expected_result(
21692158
}
21702159

21712160
template <typename Int>
2172-
void verify_integer_times_pow10_dflt(Int const mantissa,
2173-
int_fast16_t const decimal_exponent,
2174-
double const expected) {
2161+
void verify_integer_times_pow10_dflt(Int mantissa, int decimal_exponent,
2162+
double expected) {
21752163
static_assert(std::is_integral<Int>::value);
21762164

21772165
// the "default" overload
@@ -2183,8 +2171,7 @@ void verify_integer_times_pow10_dflt(Int const mantissa,
21832171
}
21842172

21852173
template <typename Int>
2186-
void verify_integer_times_pow10_dflt(Int const mantissa,
2187-
int_fast16_t const decimal_exponent) {
2174+
void verify_integer_times_pow10_dflt(Int mantissa, int decimal_exponent) {
21882175
static_assert(std::is_integral<Int>::value);
21892176

21902177
const auto expected_result =
@@ -2195,9 +2182,8 @@ void verify_integer_times_pow10_dflt(Int const mantissa,
21952182
}
21962183

21972184
template <typename T, typename Int>
2198-
void verify_integer_times_pow10(Int const mantissa,
2199-
int_fast16_t const decimal_exponent,
2200-
T const expected) {
2185+
void verify_integer_times_pow10(Int mantissa, int decimal_exponent,
2186+
T expected) {
22012187
static_assert(std::is_floating_point<T>::value);
22022188
static_assert(std::is_integral<Int>::value);
22032189

@@ -2210,8 +2196,7 @@ void verify_integer_times_pow10(Int const mantissa,
22102196
}
22112197

22122198
template <typename T, typename Int>
2213-
void verify_integer_times_pow10(Int const mantissa,
2214-
int_fast16_t const decimal_exponent) {
2199+
void verify_integer_times_pow10(Int mantissa, int decimal_exponent) {
22152200
static_assert(std::is_floating_point<T>::value);
22162201
static_assert(std::is_integral<Int>::value);
22172202

@@ -2223,8 +2208,7 @@ void verify_integer_times_pow10(Int const mantissa,
22232208

22242209
namespace all_supported_types {
22252210
template <typename Int>
2226-
void verify_integer_times_pow10(Int const mantissa,
2227-
int_fast16_t const decimal_exponent) {
2211+
void verify_integer_times_pow10(Int mantissa, int decimal_exponent) {
22282212
static_assert(std::is_integral<Int>::value);
22292213

22302214
// verify the "default" overload
@@ -2329,7 +2313,7 @@ TEST_CASE("integer_times_pow10") {
23292313

23302314
for (int mode : {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO, FE_TONEAREST}) {
23312315
fesetround(mode);
2332-
INFO("fesetround(): " << round_name(mode));
2316+
INFO("fesetround(): " << std::string{round_name(mode)});
23332317

23342318
struct Guard {
23352319
~Guard() { fesetround(FE_TONEAREST); }

0 commit comments

Comments
 (0)