44#define MAX_LOOPS 100000
53#if !defined (_RWSTD_OS_HP_UX) || defined (_ILP32)
106#ifndef _RWSTD_NO_WCHAR_T
116template <
class charT,
class Traits>
117struct MyIos: std::basic_ios<charT, Traits>
125template <
class charT,
class Traits>
126struct MyStreambuf: std::basic_streambuf<charT, Traits>
128 typedef std::basic_streambuf<charT, Traits>
Base;
135 this->setp (pbeg, pbeg +
n);
154#ifndef _RWSTD_NO_WCHAR_T
172 const std::locale
loc =
174 : std::locale (
data.locale_name_);
179 const std::time_put<char> &tp =
180 std::use_facet<std::time_put<char> >(
loc);
186 *tp.put (std::ostreambuf_iterator<char>(&nsb),
187 nio,
' ', &
data.time_,
data.format_) =
'\0';
199#ifndef _RWSTD_NO_WCHAR_T
201 const std::time_put<wchar_t> &wp =
202 std::use_facet<std::time_put<wchar_t> >(
loc);
207 *wp.put (std::ostreambuf_iterator<wchar_t>(&wsb),
208 wio,
L' ', &
data.time_,
data.format_) =
L'\0';
232#ifndef _RWSTD_NO_WCHAR_T
257 data.time_.tm_sec = ++
j % 61;
258 data.time_.tm_min = ++
j % 60;
259 data.time_.tm_hour = ++
j % 12;
260 data.time_.tm_wday = ++
j % 7;
261 data.time_.tm_mon = ++
j % 12;
262 data.time_.tm_mday = ++
j % 31;
263 data.time_.tm_yday = ++
j % 366;
264 data.time_.tm_year = ++
j;
266 const char cvtspecs[] =
"aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%";
270 data.format_ = cvtspecs [
nlocales % (
sizeof cvtspecs - 1)];
273 const std::locale
loc (
data.locale_name_);
275 const std::time_put<char> &np =
276 std::use_facet<std::time_put<char> >(
loc);
281 *np.put (std::ostreambuf_iterator<char>(&nsb),
282 nio,
' ', &
data.time_,
data.format_) =
'\0';
284 rw_fatal (!nio.fail (), __FILE__, __LINE__,
285 "time_put<char>::put(..., %c) "
286 "failed for locale(%#s)",
289#ifndef _RWSTD_NO_WCHAR_T
291 const std::time_put<wchar_t> &wp =
292 std::use_facet<std::time_put<wchar_t> >(
loc);
297 *wp.put (std::ostreambuf_iterator<wchar_t>(&wsb),
298 wio,
L' ', &
data.time_,
data.format_) =
L'\0';
300 rw_fatal (!wio.fail (), __FILE__, __LINE__,
301 "time_put<wchar_t>::put(..., %c) "
302 "failed for locale(%#s)",
315 "failed to create locale(%#s)",
name);
318 if (nlocales == maxinx || nlocales == std::size_t (
opt_nlocales))
323 rw_fatal (nlocales != 0, 0, __LINE__,
324 "failed to create one or more usable locales!");
327 "testing std::time_put<charT> with %d thread%{?}s%{;}, "
328 "%d iteration%{?}s%{;} each, in %zu locales { %{ .*A@} }",
331 nlocales,
int (nlocales),
"%#s", locales);
333 rw_info (0, 0, 0,
"exercising std::time_put<char>");
344 "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
347#ifndef _RWSTD_NO_WCHAR_T
349 rw_info (0, 0, 0,
"exercising std::time_put<wchar_t>");
360 "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
367 "exercising both std::time_put<char> and std::time_put<wchar_t>");
378 "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
388int main (
int argc,
char *argv[])
390#ifdef _RWSTD_REENTRANT
400 return rw_test (argc, argv, __FILE__,
401 "lib.locale.time.put",
struct MyTimeData my_time_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)
std::basic_streambuf< charT, Traits > Base
void pubsetp(charT *beg, charT *cur, charT *end)
void pubsetp(charT *pbeg, std::streamsize n)
const char * locale_name_