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>
11using namespace std;
12
13inline constexpr float float_inf = numeric_limits<float>::infinity();
14inline constexpr float float_nan = numeric_limits<float>::quiet_NaN();
15inline constexpr float float_nan_payload = __builtin_nanf("1729");
16
17inline constexpr double double_inf = numeric_limits<double>::infinity();
18inline constexpr double double_nan = numeric_limits<double>::quiet_NaN();
19inline constexpr double double_nan_payload = __builtin_nan("1729");
20
21struct 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
29struct FloatToCharsTestCase {
30 float value;
31 chars_format fmt;
32 const char* correct;
33};
34
35struct FloatPrecisionToCharsTestCase {
36 float value;
37 chars_format fmt;
38 int precision;
39 const char* correct;
40};
41
42struct 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
50struct DoubleToCharsTestCase {
51 double value;
52 chars_format fmt;
53 const char* correct;
54};
55
56struct DoublePrecisionToCharsTestCase {
57 double value;
58 chars_format fmt;
59 int precision;
60 const char* correct;
61};
62
63#endif // TEST_HPP
64

source code of libcxx/test/std/utilities/charconv/charconv.msvc/test.hpp