@@ -297,59 +297,58 @@ TEST(latin1_to_utf16)
297297 }
298298}
299299
300- TEST (print_string_locale, " Ignore:Android" , " Locale unsupported on Android" )
300+ TEST (print_string)
301+ {
302+ VERIFY_ARE_EQUAL (_XPLATSTR (" 1.5" ), utility::details::print_string (1.5 ));
303+ }
304+
305+ TEST (print_string_fr_locale, " Ignore:Android" , " Locale unsupported on Android" )
301306{
302- std::locale changedLocale;
303307 try
304308 {
305309#ifdef _WIN32
306- changedLocale = std::locale (" fr-FR" );
310+ tests::common::utilities::locale_guard loc ( std::locale (" fr-FR" ) );
307311#else
308- changedLocale = std::locale (" fr_FR.UTF-8" );
312+ tests::common::utilities::locale_guard loc ( std::locale (" fr_FR.UTF-8" ) );
309313#endif
314+
315+ VERIFY_ARE_EQUAL (_XPLATSTR (" 1.5" ), utility::details::print_string (1.5 ));
310316 }
311317 catch (const std::exception &)
312318 {
313319 // Silently pass if locale isn't installed on machine.
314320 return ;
315321 }
322+ }
316323
317- tests::common::utilities::locale_guard loc (changedLocale);
318-
319- utility::ostringstream_t oss ;
320- oss << 1000 ;
321- VERIFY_ARE_EQUAL (oss. str () , utility::conversions::print_string ( 1000 ));
322- VERIFY_ARE_EQUAL ( _XPLATSTR ( " 1000 " ), utility::conversions::print_string ( 1000 , std::locale::classic ()));
324+ TEST (scan_string)
325+ {
326+ VERIFY_ARE_EQUAL ( 1.5 , utility::details::scan_string< double >( " 1.5 " )) ;
327+ # ifdef WIN32
328+ VERIFY_ARE_EQUAL (1.5 , utility::details::scan_string< double >( L" 1.5 " ));
329+ # endif
323330}
324331
325332TEST (scan_string_locale, " Ignore:Android" , " Locale unsupported on Android" )
326333{
327- std::locale changedLocale;
328334 try
329335 {
330336#ifdef _WIN32
331- changedLocale = std::locale (" fr-FR" );
337+ tests::common::utilities::locale_guard loc ( std::locale (" fr-FR" ) );
332338#else
333- changedLocale = std::locale (" fr_FR.UTF-8" );
339+ tests::common::utilities::locale_guard loc (std::locale (" fr_FR.UTF-8" ));
340+ #endif
341+
342+ VERIFY_ARE_EQUAL (1.5 , utility::details::scan_string<double >(" 1.5" ));
343+ #ifdef WIN32
344+ VERIFY_ARE_EQUAL (1.5 , utility::details::scan_string<double >(L" 1.5" ));
334345#endif
335346 }
336347 catch (const std::exception &)
337348 {
338349 // Silently pass if locale isn't installed on machine.
339350 return ;
340351 }
341-
342- VERIFY_ARE_EQUAL (_XPLATSTR (" 1000" ), utility::conversions::scan_string<utility::string_t >(utility::string_t (_XPLATSTR (" 1000" ))));
343- VERIFY_ARE_EQUAL (_XPLATSTR (" 1,000" ), utility::conversions::scan_string<utility::string_t >(utility::string_t (_XPLATSTR (" 1,000" ))));
344-
345- VERIFY_ARE_EQUAL (_XPLATSTR (" 1000" ), utility::conversions::scan_string<utility::string_t >(utility::string_t (_XPLATSTR (" 1000" )), changedLocale));
346- VERIFY_ARE_EQUAL (_XPLATSTR (" 1,000" ), utility::conversions::scan_string<utility::string_t >(utility::string_t (_XPLATSTR (" 1,000" )), changedLocale));
347-
348- {
349- tests::common::utilities::locale_guard loc (changedLocale);
350- VERIFY_ARE_EQUAL (_XPLATSTR (" 1000" ), utility::conversions::scan_string<utility::string_t >(utility::string_t (_XPLATSTR (" 1000" )), std::locale::classic ()));
351- VERIFY_ARE_EQUAL (_XPLATSTR (" 1,000" ), utility::conversions::scan_string<utility::string_t >(utility::string_t (_XPLATSTR (" 1,000" )), std::locale::classic ()));
352- }
353352}
354353
355354}
0 commit comments