42#define MAX_CATALOGS 32
44#define MAX_LOOPS 100000
57#if !defined (_RWSTD_OS_HP_UX) || defined (_ILP32)
105#define MAX_MESSAGES 5
112 return (set - 1) * 5 + id;
124static const char*
const
126 {
"First set, first message",
127 "First set, second message",
128 "First set, third message",
129 "First set, fourth message",
130 "First set, fifth message"
132 {
"Second set, first message",
133 "Second set, second message",
134 "Second set, third message",
135 "Second set, fourth message",
136 "Second set, fifth message"
138 {
"Third set, first message",
139 "Third set, second message",
140 "Third set, third message",
141 "Third set, fourth message",
142 "Third set, fifth message"
144 {
"Fourth set, first message",
145 "Fourth set, second message",
146 "Fourth set, third message",
147 "Fourth set, fourth message",
148 "Fourth set, fifth message"
150 {
"Fifth set, first message",
151 "Fifth set, second message",
152 "Fifth set, third message",
153 "Fifth set, fourth message",
154 "Fifth set, fifth message"
168 const std::string ndflt (
"\1\2\3\4");
171 std::messages_base::catalog cat;
175 const unsigned n_ncatalogs =
sizeof (ncatalogs) /
sizeof (*ncatalogs);
179 for (
unsigned c = 0;
c < n_ncatalogs; ++
c)
180 ncatalogs [
c].cat = -1;
182#ifndef _RWSTD_NO_WCHAR_T
184 const std::wstring wdflt (
L"\1\2\3\4");
187 std::messages_base::catalog cat;
191 const unsigned n_wcatalogs =
sizeof (wcatalogs) /
sizeof (*wcatalogs);
193 for (
unsigned c = 0;
c < n_wcatalogs; ++
c)
194 wcatalogs [
c].cat = -1;
209 const std::locale
loc =
211 : std::locale (
data.locale_name_);
219 const std::messages<char> &nm =
220 std::use_facet<std::messages<char> >(
loc);
222 const unsigned cat_idx =
i % n_ncatalogs;
223 if (! (ncatalogs [cat_idx].cat < 0)) {
224 (nm.close)(ncatalogs [cat_idx].cat);
229 const std::messages_base::catalog cat =
232 ncatalogs [cat_idx].cat = cat;
233 ncatalogs [cat_idx].loc =
loc;
238 const std::messages<char>::string_type
res =
239 nm.get (cat, set,
msg_id (set, msgid), ndflt);
244#ifndef _RWSTD_NO_WCHAR_T
249 const std::messages<wchar_t> &wm =
250 std::use_facet<std::messages<wchar_t> >(
loc);
252 const unsigned cat_idx =
i % n_wcatalogs;
253 if (! (wcatalogs [cat_idx].cat < 0)) {
254 (wm.close)(wcatalogs [cat_idx].cat);
259 const std::messages_base::catalog cat =
264 wcatalogs [cat_idx].cat = cat;
265 wcatalogs [cat_idx].loc =
loc;
270 const std::messages<wchar_t>::string_type
res =
271 wm.get (cat, set,
msg_id (set, msgid), wdflt);
284 for (
unsigned c = 0;
c < n_ncatalogs; ++
c) {
285 if (! (ncatalogs [
c].cat < 0)) {
287 const std::messages<char> &nm =
288 std::use_facet<std::messages<char> >(ncatalogs[
c].loc);
290 (nm.close)(ncatalogs [
c].cat);
294#ifndef _RWSTD_NO_WCHAR_T
296 for (
unsigned c = 0;
c < n_wcatalogs; ++
c) {
297 if (! (wcatalogs [
c].cat < 0)) {
299 const std::messages<wchar_t> &wm =
300 std::use_facet<std::messages<wchar_t> >(wcatalogs[
c].loc);
302 (wm.close)(wcatalogs [
c].cat);
324 catalog.append (messages [
i][
j],
325 std::strlen (messages [
i][
j]) + 1);
328 catalog.append (1,
'\0');
339 std::sprintf (msg_name,
"rwstdmessages_%d.msg",
i);
341 std::sprintf (msg_name,
"rwstdmessages_%d.rc",
i);
346 "failed to create message catalog from %s",
350 std::sprintf (msg_name,
"./rwstdmessages_%d.cat",
i);
352 std::sprintf (msg_name,
"rwstdmessages_%d.dll",
i);
376 const std::locale
loc (
data.locale_name_);
379 const std::messages<char>& nm =
380 std::use_facet<std::messages<char> >(
loc);
385#ifndef _RWSTD_NO_WCHAR_T
388 const std::messages<wchar_t>& wm =
389 std::use_facet<std::messages<wchar_t> >(
loc);
404 "unable to use locale(%#s)",
name);
407 if (nlocales == maxinx || nlocales == std::size_t (
opt_nlocales))
412 "testing std::messages<charT> with %d thread%{?}s%{;}, "
413 "%d iteration%{?}s%{;} each",
422 rw_info (0, 0, 0,
"exercising std::messages<char>");
429 "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
434#ifndef _RWSTD_NO_WCHAR_T
439 rw_info (0, 0, 0,
"exercising std::messages<wchar_t>");
446 "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
454 rw_info (0, 0, 0,
"exercising std::messages<char> and "
455 "std::messages<wchar_t>");
462 "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
476int main (
int argc,
char *argv[])
478#ifdef _RWSTD_REENTRANT
488 return rw_test (argc, argv, __FILE__,
489 "lib.locale.messages",
int msg_id(int set, int id)
struct MyMessageData my_message_data[MAX_THREADS]
char my_catalog_names[64][MAX_CATALOGS]
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
#define _RWSTD_UNUSED(arg)
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 const char *const & rw_opt_locales
_TEST_EXPORT char * rw_locales(int=_UNUSED_CAT, const char *=0, bool=true)
_TEST_EXPORT int rw_create_catalog(const char *, const char *)
_TEST_EXPORT int rw_system(const char *,...)
_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()
const char * locale_name_