Skip to content

Commit b3acae2

Browse files
committed
fix parse_zero and parse_negative_zero output
1 parent 74e00e1 commit b3acae2

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

tests/basictest.cpp

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ TEST_CASE("rounds_to_nearest") {
159159
#endif
160160
}
161161

162-
TEST_CASE("parse_zero") {
162+
TEST_CASE("double.parse_zero") {
163163
//
164164
// If this function fails, we may be left in a non-standard rounding state.
165165
//
@@ -172,41 +172,45 @@ TEST_CASE("parse_zero") {
172172
fesetround(FE_UPWARD);
173173
auto r1 = fast_float::from_chars(zero, zero + 1, f);
174174
CHECK(r1.ec == std::errc());
175-
std::cout << "FE_UPWARD parsed zero as " << iHexAndDec(f) << std::endl;
175+
std::cout << "FE_UPWARD parsed zero as " << fHexAndDec(f) << std::endl;
176176
CHECK(f == 0);
177177
::memcpy(&float64_parsed, &f, sizeof(f));
178-
std::cout << "double as uint64_t is " << float64_parsed << std::endl;
178+
std::cout << "double as uint64_t is " << iHexAndDec(float64_parsed)
179+
<< std::endl;
179180
CHECK(float64_parsed == 0);
180181

181182
fesetround(FE_TOWARDZERO);
182183
auto r2 = fast_float::from_chars(zero, zero + 1, f);
183184
CHECK(r2.ec == std::errc());
184-
std::cout << "FE_TOWARDZERO parsed zero as " << iHexAndDec(f) << std::endl;
185+
std::cout << "FE_TOWARDZERO parsed zero as " << fHexAndDec(f) << std::endl;
185186
CHECK(f == 0);
186187
::memcpy(&float64_parsed, &f, sizeof(f));
187-
std::cout << "double as uint64_t is " << float64_parsed << std::endl;
188+
std::cout << "double as uint64_t is " << iHexAndDec(float64_parsed)
189+
<< std::endl;
188190
CHECK(float64_parsed == 0);
189191

190192
fesetround(FE_DOWNWARD);
191193
auto r3 = fast_float::from_chars(zero, zero + 1, f);
192194
CHECK(r3.ec == std::errc());
193-
std::cout << "FE_DOWNWARD parsed zero as " << iHexAndDec(f) << std::endl;
195+
std::cout << "FE_DOWNWARD parsed zero as " << fHexAndDec(f) << std::endl;
194196
CHECK(f == 0);
195197
::memcpy(&float64_parsed, &f, sizeof(f));
196-
std::cout << "double as uint64_t is " << float64_parsed << std::endl;
198+
std::cout << "double as uint64_t is " << iHexAndDec(float64_parsed)
199+
<< std::endl;
197200
CHECK(float64_parsed == 0);
198201

199202
fesetround(FE_TONEAREST);
200203
auto r4 = fast_float::from_chars(zero, zero + 1, f);
201204
CHECK(r4.ec == std::errc());
202-
std::cout << "FE_TONEAREST parsed zero as " << iHexAndDec(f) << std::endl;
205+
std::cout << "FE_TONEAREST parsed zero as " << fHexAndDec(f) << std::endl;
203206
CHECK(f == 0);
204207
::memcpy(&float64_parsed, &f, sizeof(f));
205-
std::cout << "double as uint64_t is " << float64_parsed << std::endl;
208+
std::cout << "double as uint64_t is " << iHexAndDec(float64_parsed)
209+
<< std::endl;
206210
CHECK(float64_parsed == 0);
207211
}
208212

209-
TEST_CASE("parse_negative_zero") {
213+
TEST_CASE("double.parse_negative_zero") {
210214
//
211215
// If this function fails, we may be left in a non-standard rounding state.
212216
//
@@ -219,41 +223,45 @@ TEST_CASE("parse_negative_zero") {
219223
fesetround(FE_UPWARD);
220224
auto r1 = fast_float::from_chars(negative_zero, negative_zero + 2, f);
221225
CHECK(r1.ec == std::errc());
222-
std::cout << "FE_UPWARD parsed negative zero as " << iHexAndDec(f)
226+
std::cout << "FE_UPWARD parsed negative zero as " << fHexAndDec(f)
223227
<< std::endl;
224228
CHECK(f == 0);
225229
::memcpy(&float64_parsed, &f, sizeof(f));
226-
std::cout << "double as uint64_t is " << float64_parsed << std::endl;
230+
std::cout << "double as uint64_t is " << iHexAndDec(float64_parsed)
231+
<< std::endl;
227232
CHECK(float64_parsed == 0x8000'0000'0000'0000);
228233

229234
fesetround(FE_TOWARDZERO);
230235
auto r2 = fast_float::from_chars(negative_zero, negative_zero + 2, f);
231236
CHECK(r2.ec == std::errc());
232-
std::cout << "FE_TOWARDZERO parsed negative zero as " << iHexAndDec(f)
237+
std::cout << "FE_TOWARDZERO parsed negative zero as " << fHexAndDec(f)
233238
<< std::endl;
234239
CHECK(f == 0);
235240
::memcpy(&float64_parsed, &f, sizeof(f));
236-
std::cout << "double as uint64_t is " << float64_parsed << std::endl;
241+
std::cout << "double as uint64_t is " << iHexAndDec(float64_parsed)
242+
<< std::endl;
237243
CHECK(float64_parsed == 0x8000'0000'0000'0000);
238244

239245
fesetround(FE_DOWNWARD);
240246
auto r3 = fast_float::from_chars(negative_zero, negative_zero + 2, f);
241247
CHECK(r3.ec == std::errc());
242-
std::cout << "FE_DOWNWARD parsed negative zero as " << iHexAndDec(f)
248+
std::cout << "FE_DOWNWARD parsed negative zero as " << fHexAndDec(f)
243249
<< std::endl;
244250
CHECK(f == 0);
245251
::memcpy(&float64_parsed, &f, sizeof(f));
246-
std::cout << "double as uint64_t is " << float64_parsed << std::endl;
252+
std::cout << "double as uint64_t is " << iHexAndDec(float64_parsed)
253+
<< std::endl;
247254
CHECK(float64_parsed == 0x8000'0000'0000'0000);
248255

249256
fesetround(FE_TONEAREST);
250257
auto r4 = fast_float::from_chars(negative_zero, negative_zero + 2, f);
251258
CHECK(r4.ec == std::errc());
252-
std::cout << "FE_TONEAREST parsed negative zero as " << iHexAndDec(f)
259+
std::cout << "FE_TONEAREST parsed negative zero as " << fHexAndDec(f)
253260
<< std::endl;
254261
CHECK(f == 0);
255262
::memcpy(&float64_parsed, &f, sizeof(f));
256-
std::cout << "double as uint64_t is " << float64_parsed << std::endl;
263+
std::cout << "double as uint64_t is " << iHexAndDec(float64_parsed)
264+
<< std::endl;
257265
CHECK(float64_parsed == 0x8000'0000'0000'0000);
258266
}
259267

0 commit comments

Comments
 (0)