@@ -245,29 +245,52 @@ testR(S s, typename S::size_type pos, typename S::size_type n1, const typename S
245
245
246
246
template <typename Arithmetic>
247
247
bool
248
- testTS (Arithmetic value, const char * str_expected = " " , const wchar_t * wstr_expected = L" " , bool test_expected = false )
248
+ testTS (Arithmetic value, const char * str_expected = " " , bool test_expected = false )
249
249
{
250
250
const auto str = to_static_string (value);
251
- const auto wstr = to_static_wstring (value);
252
251
if (std::is_floating_point<Arithmetic>::value)
253
252
{
254
253
const auto std_res = std::to_string (value);
254
+ return str == std_res.data ();
255
+ }
256
+ else
257
+ {
258
+ if (std::is_signed<Arithmetic>::value)
259
+ {
260
+ return
261
+ Arithmetic (std::strtoll (str.begin (), nullptr , 10 )) == value &&
262
+ (! test_expected || str == str_expected);
263
+ }
264
+ else
265
+ {
266
+ return Arithmetic (std::strtoull (str.begin (), nullptr , 10 )) == value &&
267
+ (! test_expected || str == str_expected);
268
+ }
269
+ }
270
+ }
271
+
272
+ template <typename Arithmetic>
273
+ bool
274
+ testTWS (Arithmetic value, const wchar_t * wstr_expected = L" " , bool test_expected = false )
275
+ {
276
+ const auto wstr = to_static_wstring (value);
277
+ if (std::is_floating_point<Arithmetic>::value)
278
+ {
255
279
const auto wstd_res = std::to_wstring (value);
256
- return str == std_res. data () && wstr == wstd_res.data ();
280
+ return wstr == wstd_res.data ();
257
281
}
258
282
else
259
283
{
260
284
if (std::is_signed<Arithmetic>::value)
261
285
{
262
- return Arithmetic ( std::strtoll (str. begin (), nullptr , 10 )) == value &&
286
+ return
263
287
Arithmetic (std::wcstoll (wstr.begin (), nullptr , 10 )) == value &&
264
- (test_expected ? str == str_expected && wstr == wstr_expected : true );
288
+ (! test_expected || wstr == wstr_expected);
265
289
}
266
290
else
267
291
{
268
- return Arithmetic (std::strtoull (str.begin (), nullptr , 10 )) == value &&
269
- Arithmetic (std::wcstoull (wstr.begin (), nullptr , 10 )) == value &&
270
- (test_expected ? str == str_expected && wstr == wstr_expected : true );
292
+ return Arithmetic (std::wcstoull (wstr.begin (), nullptr , 10 )) == value &&
293
+ (! test_expected || wstr == wstr_expected);
271
294
}
272
295
}
273
296
}
@@ -3913,16 +3936,16 @@ testGeneral()
3913
3936
void
3914
3937
testToStaticString ()
3915
3938
{
3916
- BOOST_TEST (testTS (0 , " 0" , L" 0 " , true ));
3917
- BOOST_TEST (testTS (0u , " 0" , L" 0 " , true ));
3918
- BOOST_TEST (testTS (0xffff , " 65535" , L" 65535 " , true ));
3919
- BOOST_TEST (testTS (0x10000 , " 65536" , L" 65536 " , true ));
3920
- BOOST_TEST (testTS (0xffffffff , " 4294967295" , L" 4294967295 " , true ));
3921
- BOOST_TEST (testTS (-65535 , " -65535" , L" -65535 " , true ));
3922
- BOOST_TEST (testTS (-65536 , " -65536" , L" -65536 " , true ));
3923
- BOOST_TEST (testTS (-4294967295ll , " -4294967295" , L" -4294967295 " , true ));
3924
- BOOST_TEST (testTS (1 , " 1" , L" 1 " , true ));
3925
- BOOST_TEST (testTS (-1 , " -1" , L" -1 " , true ));
3939
+ BOOST_TEST (testTS (0 , " 0" , true ));
3940
+ BOOST_TEST (testTS (0u , " 0" , true ));
3941
+ BOOST_TEST (testTS (0xffff , " 65535" , true ));
3942
+ BOOST_TEST (testTS (0x10000 , " 65536" , true ));
3943
+ BOOST_TEST (testTS (0xffffffff , " 4294967295" , true ));
3944
+ BOOST_TEST (testTS (-65535 , " -65535" , true ));
3945
+ BOOST_TEST (testTS (-65536 , " -65536" , true ));
3946
+ BOOST_TEST (testTS (-4294967295ll , " -4294967295" , true ));
3947
+ BOOST_TEST (testTS (1 , " 1" , true ));
3948
+ BOOST_TEST (testTS (-1 , " -1" , true ));
3926
3949
BOOST_TEST (testTS (0.1 ));
3927
3950
BOOST_TEST (testTS (0.0000001 ));
3928
3951
BOOST_TEST (testTS (-0.0000001 ));
@@ -3956,6 +3979,35 @@ testToStaticString()
3956
3979
BOOST_TEST (str.find (' e' ) != static_string<0 >::npos || str.find (' .' ) !=
3957
3980
static_string<0 >::npos || str == " infinity" || str == " inf" );
3958
3981
}
3982
+
3983
+ #ifdef BOOST_STATIC_STRING_HAS_WCHAR
3984
+
3985
+ BOOST_TEST (testTWS (0 , L" 0" , true ));
3986
+ BOOST_TEST (testTWS (0u , L" 0" , true ));
3987
+ BOOST_TEST (testTWS (0xffff , L" 65535" , true ));
3988
+ BOOST_TEST (testTWS (0x10000 , L" 65536" , true ));
3989
+ BOOST_TEST (testTWS (0xffffffff , L" 4294967295" , true ));
3990
+ BOOST_TEST (testTWS (-65535 , L" -65535" , true ));
3991
+ BOOST_TEST (testTWS (-65536 , L" -65536" , true ));
3992
+ BOOST_TEST (testTWS (-4294967295ll , L" -4294967295" , true ));
3993
+ BOOST_TEST (testTWS (1 , L" 1" , true ));
3994
+ BOOST_TEST (testTWS (-1 , L" -1" , true ));
3995
+ BOOST_TEST (testTWS (0.1 ));
3996
+ BOOST_TEST (testTWS (0.0000001 ));
3997
+ BOOST_TEST (testTWS (-0.0000001 ));
3998
+ BOOST_TEST (testTWS (-0.1 ));
3999
+ BOOST_TEST (testTWS (1234567890.0001 ));
4000
+ BOOST_TEST (testTWS (1.123456789012345 ));
4001
+ BOOST_TEST (testTWS (-1234567890.1234 ));
4002
+ BOOST_TEST (testTWS (-1.123456789012345 ));
4003
+
4004
+ BOOST_TEST (testTWS (std::numeric_limits<long long >::max ()));
4005
+ BOOST_TEST (testTWS (std::numeric_limits<long long >::min ()));
4006
+ BOOST_TEST (testTWS (std::numeric_limits<unsigned long long >::max ()));
4007
+ BOOST_TEST (testTWS (std::numeric_limits<unsigned long long >::max ()));
4008
+ BOOST_TEST (testTWS (std::numeric_limits<long double >::min ()));
4009
+ BOOST_TEST (testTWS (std::numeric_limits<float >::min ()));
4010
+
3959
4011
{
3960
4012
auto str = to_static_wstring (std::numeric_limits<float >::max ());
3961
4013
BOOST_TEST (str.find (' e' ) != static_string<0 >::npos || str.find (' .' ) !=
@@ -3971,6 +4023,7 @@ testToStaticString()
3971
4023
BOOST_TEST (str.find (' e' ) != static_string<0 >::npos || str.find (' .' ) !=
3972
4024
static_string<0 >::npos || str == L" infinity" || str == L" inf" );
3973
4025
}
4026
+ #endif
3974
4027
}
3975
4028
3976
4029
// done
@@ -6007,7 +6060,7 @@ testFind()
6007
6060
void
6008
6061
testReplace ()
6009
6062
{
6010
- // replace(size_type pos1, size_type n1, const charT* s, size_type n2);
6063
+ // replace(size_type pos1, size_type n1, const charT* s, size_type n2);
6011
6064
{
6012
6065
static_string<20 > fs1 = " helloworld" ;
6013
6066
BOOST_TEST (fs1.replace (5 , 2 , fs1.data () + 1 , 8 ) == " helloelloworlrld" );
0 commit comments