static void* thread_func (void*) { char ncs [MyMoneyData::BufferSize]; MyIos<char, std::char_traits<char> > nio; MyStreambuf<char, std::char_traits<char> > nsb; nio.rdbuf (&nsb); #ifndef _RWSTD_NO_WCHAR_T wchar_t wcs [MyMoneyData::BufferSize]; MyIos<wchar_t, std::char_traits<wchar_t> > wio; MyStreambuf<wchar_t, std::char_traits<wchar_t> > wsb; wio.rdbuf (&wsb); #endif // _RWSTD_NO_WCHAR_T for (int i = 0; i != opt_nloops; ++i) { if (rw_thread_pool_timeout_expired ()) break; // save the name of the locale const MyMoneyData& data = my_money_data [i % nlocales]; // construct a named locale, get a reference to the money_put // facet from it and use it to format a random money value const std::locale loc = opt_shared_locale ? data.locale_ : std::locale (data.locale_name_); if (test_char) { // exercise the narrow char specialization of the facet const std::money_put<char> &np = std::use_facet<std::money_put<char> >(loc); nio.imbue (loc); nsb.pubsetp (ncs, RW_COUNT_OF (ncs)); switch (data.type_) { case MyMoneyData::put_ldbl: *np.put (std::ostreambuf_iterator<char>(&nsb), data.intl_, nio, ' ', data.money_value_) = '\0'; break; case MyMoneyData::put_string: *np.put (std::ostreambuf_iterator<char>(&nsb), data.intl_, nio, ' ', n_money_vals [data.money_index_]) = '\0'; break; case MyMoneyData::put_max: // avoid enumeration value `put_max' not handled in switch // this case should never happen break; } RW_ASSERT (!nio.fail ()); RW_ASSERT (!rw_strncmp (ncs, data.ncs_)); } // both specializations may be tested at the same time if (test_wchar) { // exercise the wide char specialization of the facet #ifndef _RWSTD_NO_WCHAR_T const std::money_put<wchar_t> &wp = std::use_facet<std::money_put<wchar_t> >(loc); wio.imbue (loc); wsb.pubsetp (wcs, RW_COUNT_OF (wcs)); switch (data.type_) { case MyMoneyData::put_ldbl: *wp.put (std::ostreambuf_iterator<wchar_t>(&wsb), data.intl_, wio, ' ', data.money_value_) = L'\0'; break; case MyMoneyData::put_string: *wp.put (std::ostreambuf_iterator<wchar_t>(&wsb), data.intl_, wio, ' ', w_money_vals [data.money_index_]) = L'\0'; break; case MyMoneyData::put_max: // avoid enumeration value `put_max' not handled in switch // this case should never happen break; } RW_ASSERT (!wio.fail ()); RW_ASSERT (!rw_strncmp (wcs, data.wcs_)); #endif // _RWSTD_NO_WCHAR_T } } return 0; }
static void thread_loop_body (std::size_t i) { const std::size_t inx = std::size_t (i) % (nlocales ? nlocales : 1); const MoneypunctData* const data = punct_data + inx; // construct a named locale const std::locale loc (data->locale_name_); if (test_char) { // exercise the narrow char, local specialization of the facet typedef std::moneypunct<char, false> Punct; const Punct &mp = std::use_facet<Punct>(loc); const char dp = mp.decimal_point (); const char ts = mp.thousands_sep (); const std::string grp = mp.grouping (); const std::string cur = mp.curr_symbol (); const std::string pos = mp.positive_sign (); const std::string neg = mp.negative_sign (); const int fd = mp.frac_digits (); const Punct::pattern pfm = mp.pos_format (); const Punct::pattern nfm = mp.neg_format (); RW_ASSERT (dp == data->decimal_point_); RW_ASSERT (ts == data->thousands_sep_); RW_ASSERT (fd == data->frac_digits_); RW_ASSERT (!rw_strncmp (grp.c_str (), data->grouping_)); RW_ASSERT (!rw_strncmp (cur.c_str (), data->curr_symbol_)); RW_ASSERT (!rw_strncmp (pos.c_str (), data->positive_sign_)); RW_ASSERT (!rw_strncmp (neg.c_str (), data->negative_sign_)); RW_ASSERT (!std::memcmp (&pfm, data->pos_format_, 4)); RW_ASSERT (!std::memcmp (&nfm, data->neg_format_, 4)); } if (test_char) { // exercise the narrow char, international specialization typedef std::moneypunct<char, true> Punct; const Punct &mp = std::use_facet<Punct>(loc); const char dp = mp.decimal_point (); const char ts = mp.thousands_sep (); const std::string grp = mp.grouping (); const std::string cur = mp.curr_symbol (); const std::string pos = mp.positive_sign (); const std::string neg = mp.negative_sign (); const int fd = mp.frac_digits (); const Punct::pattern pfm = mp.pos_format (); const Punct::pattern nfm = mp.neg_format (); RW_ASSERT (dp == data->decimal_point_); RW_ASSERT (ts == data->thousands_sep_); RW_ASSERT (fd == data->frac_digits_); RW_ASSERT (!rw_strncmp (grp.c_str (), data->grouping_)); RW_ASSERT (!rw_strncmp (cur.c_str (), data->int_curr_symbol_)); RW_ASSERT (!rw_strncmp (pos.c_str (), data->positive_sign_)); RW_ASSERT (!rw_strncmp (neg.c_str (), data->negative_sign_)); RW_ASSERT (!std::memcmp (&pfm, data->int_pos_format_, 4)); RW_ASSERT (!std::memcmp (&nfm, data->int_neg_format_, 4)); } // both specializations may be tested at the same time #ifndef _RWSTD_NO_WCHAR_T if (test_wchar) { // exercise the wide char, local specialization of the facet typedef std::moneypunct<wchar_t, false> Punct; const Punct &mp = std::use_facet<Punct>(loc); const wchar_t dp = mp.decimal_point (); const wchar_t ts = mp.thousands_sep (); const std::string grp = mp.grouping (); const std::wstring cur = mp.curr_symbol (); const std::wstring pos = mp.positive_sign (); const std::wstring neg = mp.negative_sign (); const int fd = mp.frac_digits (); const Punct::pattern pfm = mp.pos_format (); const Punct::pattern nfm = mp.neg_format (); RW_ASSERT (dp == data->wdecimal_point_); RW_ASSERT (ts == data->wthousands_sep_); RW_ASSERT (fd == data->frac_digits_); RW_ASSERT (!rw_strncmp (grp.c_str (), data->grouping_)); RW_ASSERT (!rw_strncmp (cur.c_str (), data->wcurr_symbol_)); RW_ASSERT (!rw_strncmp (pos.c_str (), data->wpositive_sign_)); RW_ASSERT (!rw_strncmp (neg.c_str (), data->wnegative_sign_)); RW_ASSERT (!std::memcmp (&pfm, data->pos_format_, 4)); RW_ASSERT (!std::memcmp (&nfm, data->neg_format_, 4)); } if (test_wchar) { // exercise the wide char, international specialization typedef std::moneypunct<wchar_t, true> Punct; const Punct &mp = std::use_facet<Punct>(loc); const wchar_t dp = mp.decimal_point (); const wchar_t ts = mp.thousands_sep (); const std::string grp = mp.grouping (); const std::wstring cur = mp.curr_symbol (); const std::wstring pos = mp.positive_sign (); const std::wstring neg = mp.negative_sign (); const int fd = mp.frac_digits (); const Punct::pattern pfm = mp.pos_format (); const Punct::pattern nfm = mp.neg_format (); RW_ASSERT (dp == data->wdecimal_point_); RW_ASSERT (ts == data->wthousands_sep_); RW_ASSERT (fd == data->frac_digits_); RW_ASSERT (!rw_strncmp (grp.c_str (), data->grouping_)); RW_ASSERT (!rw_strncmp (cur.c_str (), data->wint_curr_symbol_)); RW_ASSERT (!rw_strncmp (pos.c_str (), data->wpositive_sign_)); RW_ASSERT (!rw_strncmp (neg.c_str (), data->wnegative_sign_)); RW_ASSERT (!std::memcmp (&pfm, data->int_pos_format_, 4)); RW_ASSERT (!std::memcmp (&nfm, data->int_neg_format_, 4)); } #endif // _RWSTD_NO_WCHAR_T }
static void* thread_func (void*) { char ncs [MyNumData::BufferSize]; MyIos<char, std::char_traits<char> > nio; MyStreambuf<char, std::char_traits<char> > nsb; nio.rdbuf (&nsb); #ifndef _RWSTD_NO_WCHAR_T wchar_t wcs [MyNumData::BufferSize]; MyIos<wchar_t, std::char_traits<wchar_t> > wio; MyStreambuf<wchar_t, std::char_traits<wchar_t> > wsb; wio.rdbuf (&wsb); #endif // _RWSTD_NO_WCHAR_T for (int i = 0; i != opt_nloops; ++i) { // fill in the value and results for this locale const MyNumData& data = my_num_data [i % nlocales]; // construct a named locale and imbue it in the ios object // so that the locale is used not only by the num_put facet const std::locale loc = opt_shared_locale ? data.locale_ : std::locale (data.locale_name_); if (test_char) { // exercise the narrow char specialization of the facet const std::num_put<char> &np = std::use_facet<std::num_put<char> >(loc); nio.imbue (loc); nsb.pubsetp (ncs, RW_COUNT_OF (ncs)); put_data (data, np, std::ostreambuf_iterator<char>(&nsb), nio, ' ', '\0'); RW_ASSERT (!nio.fail ()); RW_ASSERT (!rw_strncmp (ncs, data.ncs_)); } // both specializations may be tested at the same time if (test_wchar) { // exercise the wide char specialization of the facet #ifndef _RWSTD_NO_WCHAR_T const std::num_put<wchar_t> &wp = std::use_facet<std::num_put<wchar_t> >(loc); wio.imbue (loc); wsb.pubsetp (wcs, RW_COUNT_OF (wcs)); put_data (data, wp, std::ostreambuf_iterator<wchar_t>(&wsb), wio, L' ', L'\0'); RW_ASSERT (!wio.fail ()); RW_ASSERT (!rw_strncmp (wcs, data.wcs_)); #endif // _RWSTD_NO_WCHAR_T } } return 0; }
static void* thread_func (void*) { for (int i = 0; i != opt_nloops; ++i) { if (rw_thread_pool_timeout_expired ()) break; const std::size_t inx = std::size_t (i) % nlocales; const NumPunctData& data = punct_data[inx]; // construct a named locale const std::locale loc = opt_shared_locale ? data.locale_ : std::locale (data.locale_name_); if (test_char) { // exercise the narrow char specialization of the facet const std::numpunct<char> &np = std::use_facet<std::numpunct<char> >(loc); const char dp = np.decimal_point (); const char ts = np.thousands_sep (); const std::string grp = np.grouping (); const std::string tn = np.truename (); const std::string fn = np.falsename (); RW_ASSERT (dp == data.decimal_point_); RW_ASSERT (ts == data.thousands_sep_); RW_ASSERT (0 == rw_strncmp (grp.c_str (), data.grouping_.c_str ())); RW_ASSERT (0 == rw_strncmp (tn.c_str (), data.truename_.c_str ())); RW_ASSERT (0 == rw_strncmp (fn.c_str (), data.falsename_.c_str ())); } // both specializations may be tested at the same time if (test_wchar) { // exercise the wide char specialization of the facet #ifndef _RWSTD_NO_WCHAR_T const std::numpunct<wchar_t> &wp = std::use_facet<std::numpunct<wchar_t> >(loc); const wchar_t dp = wp.decimal_point (); const wchar_t ts = wp.thousands_sep (); const std::string grp = wp.grouping (); const std::wstring tn = wp.truename (); const std::wstring fn = wp.falsename (); RW_ASSERT (dp == data.wdecimal_point_); RW_ASSERT (ts == data.wthousands_sep_); RW_ASSERT (0 == rw_strncmp (grp.c_str (), data.grouping_.c_str ())); RW_ASSERT (0 == rw_strncmp (tn.c_str (), data.wtruename_.c_str ())); RW_ASSERT (0 == rw_strncmp (fn.c_str (), data.wfalsename_.c_str ())); #endif // _RWSTD_NO_WCHAR_T } } return 0; }