1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // wstring to_wstring(int val);
12 // wstring to_wstring(unsigned val);
13 // wstring to_wstring(long val);
14 // wstring to_wstring(unsigned long val);
15 // wstring to_wstring(long long val);
16 // wstring to_wstring(unsigned long long val);
17 // wstring to_wstring(float val);
18 // wstring to_wstring(double val);
19 // wstring to_wstring(long double val);
25 #include "parse_integer.h"
26 #include "test_macros.h"
33 std::wstring s
= std::to_wstring(T(0));
34 assert(s
.size() == 1);
35 assert(s
[s
.size()] == 0);
39 std::wstring s
= std::to_wstring(T(12345));
40 assert(s
.size() == 5);
41 assert(s
[s
.size()] == 0);
42 assert(s
== L
"12345");
45 std::wstring s
= std::to_wstring(T(-12345));
46 assert(s
.size() == 6);
47 assert(s
[s
.size()] == 0);
48 assert(s
== L
"-12345");
51 std::wstring s
= std::to_wstring(std::numeric_limits
<T
>::max());
52 assert(s
.size() == std::numeric_limits
<T
>::digits10
+ 1);
53 T t
= parse_integer
<T
>(s
);
54 assert(t
== std::numeric_limits
<T
>::max());
57 std::wstring s
= std::to_wstring(std::numeric_limits
<T
>::min());
58 T t
= parse_integer
<T
>(s
);
59 assert(t
== std::numeric_limits
<T
>::min());
68 std::wstring s
= std::to_wstring(T(0));
69 assert(s
.size() == 1);
70 assert(s
[s
.size()] == 0);
74 std::wstring s
= std::to_wstring(T(12345));
75 assert(s
.size() == 5);
76 assert(s
[s
.size()] == 0);
77 assert(s
== L
"12345");
80 std::wstring s
= std::to_wstring(std::numeric_limits
<T
>::max());
81 assert(s
.size() == std::numeric_limits
<T
>::digits10
+ 1);
82 T t
= parse_integer
<T
>(s
);
83 assert(t
== std::numeric_limits
<T
>::max());
92 std::wstring s
= std::to_wstring(T(0));
93 assert(s
.size() == 8);
94 assert(s
[s
.size()] == 0);
95 assert(s
== L
"0.000000");
98 std::wstring s
= std::to_wstring(T(12345));
99 assert(s
.size() == 12);
100 assert(s
[s
.size()] == 0);
101 assert(s
== L
"12345.000000");
104 std::wstring s
= std::to_wstring(T(-12345));
105 assert(s
.size() == 13);
106 assert(s
[s
.size()] == 0);
107 assert(s
== L
"-12345.000000");
111 int main(int, char**)
115 test_signed
<long long>();
116 test_unsigned
<unsigned>();
117 test_unsigned
<unsigned long>();
118 test_unsigned
<unsigned long long>();
120 test_float
<double>();
121 test_float
<long double>();