41#define MAX_LOOPS 100000
50#if !defined (_RWSTD_OS_HP_UX) || defined (_ILP32)
90#ifndef _RWSTD_NO_LONG_LONG
99#ifndef _RWSTD_NO_LONG_DOUBLE
125#ifndef _RWSTD_NO_WCHAR_T
135template <
class charT,
class Traits>
136struct MyIos: std::basic_ios<charT, Traits>
143template <
class charT,
class Traits>
144struct MyStreambuf: std::basic_streambuf<charT, Traits>
146 typedef std::basic_streambuf<charT, Traits>
Base;
153 this->setp (pbeg, pbeg +
n);
157template <
class charT,
class Traits>
160 const std::num_put<charT> &np,
161 const std::ostreambuf_iterator<charT, Traits> &iter,
162 std::basic_ios<charT, Traits> &io,
166 switch (
data.type_) {
168 *np.put (iter, io,
fill,
169 data.value_ < 1.f) = term;
172 *np.put (iter, io,
fill,
173 (
long)
data.value_) = term;
176 *np.put (iter, io,
fill,
177 (
unsigned long)
data.value_) = term;
180#ifndef _RWSTD_NO_LONG_LONG
183 *np.put (iter, io,
fill,
187 *np.put (iter, io,
fill,
194 *np.put (iter, io,
fill,
195 (
double)
data.value_) = term;
199#ifndef _RWSTD_NO_LONG_DOUBLE
202 *np.put (iter, io,
fill,
203 (
long double)
data.value_) = term;
209 *np.put (iter, io,
fill,
210 (
const void*)&
data.value_) = term;
235#ifndef _RWSTD_NO_WCHAR_T
252 const std::locale
loc =
254 : std::locale (
data.locale_name_);
259 const std::num_put<char> &np =
260 std::use_facet<std::num_put<char> >(
loc);
265 put_data (
data, np, std::ostreambuf_iterator<char>(&nsb),
277#ifndef _RWSTD_NO_WCHAR_T
279 const std::num_put<wchar_t> &wp =
280 std::use_facet<std::num_put<wchar_t> >(
loc);
285 put_data (
data, wp, std::ostreambuf_iterator<wchar_t>(&wsb),
311#ifndef _RWSTD_NO_WCHAR_T
335 const std::locale
loc (
data.locale_name_);
341 const std::num_put<char> &np =
342 std::use_facet<std::num_put<char> >(
loc);
347 put_data (
data, np, std::ostreambuf_iterator<char>(&nsb),
350 rw_fatal (!nio.fail (), __FILE__, __LINE__,
351 "num_put<char>::put(...) failed for locale(%#s)",
354#ifndef _RWSTD_NO_WCHAR_T
356 const std::num_put<wchar_t> &wp =
357 std::use_facet<std::num_put<wchar_t> >(
loc);
362 put_data (
data, wp, std::ostreambuf_iterator<wchar_t>(&wsb),
365 rw_fatal (!wio.fail (), __FILE__, __LINE__,
366 "num_put<wchar_t>::put(...) failed for locale(%#s)",
378 "failed to create locale(%#s)",
name);
381 if (nlocales == maxinx || nlocales == std::size_t (
opt_nlocales))
386 rw_fatal (nlocales != 0, 0, __LINE__,
387 "failed to create one or more usable locales!");
390 "testing std::num_put<charT> with %d thread%{?}s%{;}, "
391 "%d iteration%{?}s%{;} each, in %zu locales { %{ .*A@} }",
394 nlocales,
int (nlocales),
"%#s", locales);
396 rw_info (0, 0, 0,
"exercising std::num_put<char>");
407 "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
410#ifndef _RWSTD_NO_WCHAR_T
412 rw_info (0, 0, 0,
"exercising std::num_put<wchar_t>");
423 "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
430 "exercising both std::num_put<char> and std::num_put<wchar_t>");
441 "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
451int main (
int argc,
char *argv[])
453#ifdef _RWSTD_REENTRANT
463 return rw_test (argc, argv, __FILE__,
464 "lib.locale.num.put",
void put_data(const MyNumData &data, const std::num_put< charT > &np, const std::ostreambuf_iterator< charT, Traits > &iter, std::basic_ios< charT, Traits > &io, charT fill, charT term)
struct MyNumData my_num_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_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)