43#define MAX_LOOPS 100000
53#if !defined (_RWSTD_OS_HP_UX) || defined (_ILP32)
85static const char n_money_vals[][20] = {
86 "1",
"12",
"123",
"1234",
"12345",
"123456",
"1234567",
"12345678",
87 "-9",
"-98",
"-987",
"-9876",
"-98765",
"-987654",
"-9876543",
88 "1.9",
"-12.89",
"123.789",
"-1234.6789",
"-12345.56789"
91#ifndef _RWSTD_NO_WCHAR_T
93static const wchar_t w_money_vals[][20] = {
94 L"1",
L"12",
L"123",
L"1234",
L"12345",
L"123456",
L"1234567",
95 L"-9",
L"-98",
L"-987",
L"-9876",
L"-98765",
L"-987654",
L"-9876543",
96 L"1.9",
L"-12.89",
L"123.789",
L"-1234.6789",
L"-12345.56789"
133#ifndef _RWSTD_NO_WCHAR_T
143template <
class charT,
class Traits>
144struct MyIos: std::basic_ios<charT, Traits>
152template <
class charT,
class Traits>
153struct MyStreambuf: std::basic_streambuf<charT, Traits>
155 typedef std::basic_streambuf<charT, Traits>
Base;
162 this->setp (pbeg, pbeg +
n);
181#ifndef _RWSTD_NO_WCHAR_T
198 const std::locale
loc =
200 : std::locale (
data.locale_name_);
205 const std::money_put<char> &np =
206 std::use_facet<std::money_put<char> >(
loc);
211 switch (
data.type_) {
213 *np.put (std::ostreambuf_iterator<char>(&nsb),
214 data.intl_, nio,
' ',
data.money_value_) =
'\0';
217 *np.put (std::ostreambuf_iterator<char>(&nsb),
218 data.intl_, nio,
' ',
219 n_money_vals [
data.money_index_]) =
'\0';
237#ifndef _RWSTD_NO_WCHAR_T
239 const std::money_put<wchar_t> &wp =
240 std::use_facet<std::money_put<wchar_t> >(
loc);
245 switch (
data.type_) {
247 *wp.put (std::ostreambuf_iterator<wchar_t>(&wsb),
248 data.intl_, wio,
' ',
data.money_value_) =
L'\0';
251 *wp.put (std::ostreambuf_iterator<wchar_t>(&wsb),
252 data.intl_, wio,
' ',
253 w_money_vals [
data.money_index_]) =
L'\0';
283#ifndef _RWSTD_NO_WCHAR_T
307 const std::locale
loc (
data.locale_name_);
321 data.money_value_ *= -1.;
325 data.money_value_ +=
data.money_value_ / 3.14;
327 const std::money_put<char> &np =
328 std::use_facet<std::money_put<char> >(
loc);
333 switch (
data.type_) {
335 *np.put (std::ostreambuf_iterator<char>(&nsb),
336 data.intl_, nio,
' ',
data.money_value_) =
'\0';
339 *np.put (std::ostreambuf_iterator<char>(&nsb),
340 data.intl_, nio,
' ',
341 n_money_vals [
data.money_index_]) =
'\0';
349 rw_assert (!nio.fail (), __FILE__, __LINE__,
350 "money_put<char>::put(...) "
351 "failed for locale(%#s)",
354#ifndef _RWSTD_NO_WCHAR_T
356 const std::money_put<wchar_t> &wp =
357 std::use_facet<std::money_put<wchar_t> >(
loc);
362 switch (
data.type_) {
364 *wp.put (std::ostreambuf_iterator<wchar_t>(&wsb),
365 data.intl_, wio,
L' ',
data.money_value_) =
'\0';
368 *wp.put (std::ostreambuf_iterator<wchar_t>(&wsb),
369 data.intl_, wio,
L' ',
370 w_money_vals [
data.money_index_]) =
L'\0';
378 rw_assert (!nio.fail (), __FILE__, __LINE__,
379 "money_put<wchar_t>::put(...) "
380 "failed for locale(%#s)",
393 "failed to create locale(%#s)",
name);
396 if (nlocales == maxinx || nlocales == std::size_t (
opt_nlocales))
401 rw_fatal (nlocales != 0, 0, __LINE__,
402 "failed to create one or more usable locales!");
405 "testing std::money_put<charT> with %d thread%{?}s%{;}, "
406 "%d iteration%{?}s%{;} each, in %zu locales { %{ .*A@} }",
409 nlocales,
int (nlocales),
"%#s", locales);
411 rw_info (0, 0, 0,
"exercising std::money_put<char>");
422 "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
425#ifndef _RWSTD_NO_WCHAR_T
427 rw_info (0, 0, 0,
"exercising std::money_put<wchar_t>");
438 "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
445 "exercising both std::money_put<char> "
446 "and std::money_put<wchar_t>");
457 "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
467int main (
int argc,
char *argv[])
469#ifdef _RWSTD_REENTRANT
479 return rw_test (argc, argv, __FILE__,
480 "lib.locale.money.put",
struct MyMoneyData my_money_data[MAX_THREADS]
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
const struct @19 locales[]
_TEST_EXPORT int rw_test(int argc, char *argv[], const char *filename, const char *clause, const char *comment, int(*testfun)(int, char **), const char *optspec,...)
_TEST_EXPORT int rw_info(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_fatal(int expr, const char *filename, int line, const char *fmtspec,...)
_TEST_EXPORT int rw_assert(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_error(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_warn(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_opt_setlocales(int, char *[])
_TEST_EXPORT const char *const & rw_opt_locales
_TEST_EXPORT char * rw_locales(int=_UNUSED_CAT, const char *=0, bool=true)
_TEST_EXPORT int rw_thread_pool(rw_thread_t *, _RWSTD_SIZE_T, rw_thread_attr_t *, rw_thread_proc *, void **, _RWSTD_SIZE_T=0)
_TEST_EXPORT int rw_get_cpus()
_TEST_EXPORT int rw_thread_pool_timeout_expired()
_TEST_EXPORT int rw_strncmp(const char *, const char *, _RWSTD_SIZE_T=_RWSTD_SIZE_MAX, int=CMP_NULTERM)
const char * locale_name_
std::basic_streambuf< charT, Traits > Base
void pubsetp(charT *beg, charT *cur, charT *end)
void pubsetp(charT *pbeg, std::streamsize n)