1 // Copyright (c) Microsoft Corporation. 2 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 4 #ifndef TEST_HPP 5 #define TEST_HPP 6 7 #include <charconv> 8 #include <limits> 9 #include <stddef.h> 10 #include <system_error> 11 using namespace std; 12 13 inline constexpr float float_inf = numeric_limits<float>::infinity(); 14 inline constexpr float float_nan = numeric_limits<float>::quiet_NaN(); 15 inline constexpr float float_nan_payload = __builtin_nanf("1729"); 16 17 inline constexpr double double_inf = numeric_limits<double>::infinity(); 18 inline constexpr double double_nan = numeric_limits<double>::quiet_NaN(); 19 inline constexpr double double_nan_payload = __builtin_nan("1729"); 20 21 struct FloatFromCharsTestCase { 22 const char* input; 23 chars_format fmt; 24 std::size_t correct_idx; 25 errc correct_ec; 26 float correct_value; 27 }; 28 29 struct FloatToCharsTestCase { 30 float value; 31 chars_format fmt; 32 const char* correct; 33 }; 34 35 struct FloatPrecisionToCharsTestCase { 36 float value; 37 chars_format fmt; 38 int precision; 39 const char* correct; 40 }; 41 42 struct DoubleFromCharsTestCase { 43 const char* input; 44 chars_format fmt; 45 std::size_t correct_idx; 46 errc correct_ec; 47 double correct_value; 48 }; 49 50 struct DoubleToCharsTestCase { 51 double value; 52 chars_format fmt; 53 const char* correct; 54 }; 55 56 struct DoublePrecisionToCharsTestCase { 57 double value; 58 chars_format fmt; 59 int precision; 60 const char* correct; 61 }; 62 63 #endif // TEST_HPP 64