Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
22.locale.messages.stdcxx-542.cpp
Go to the documentation of this file.
1
29#include <cstdio>
30#include <cassert>
31#include <locale>
32
33#include <rw_locale.h>
34#include <rw_driver.h>
35
36#ifdef _MSC_VER
37#include <crtdbg.h>
38#endif
39
40#ifdef _WIN32
41# define CATALOG "test"
42# define MSG_EXT ".rc"
43# define CAT_EXT ".dll"
44#else
45# define CATALOG "./test"
46# define MSG_EXT ".msg"
47# define CAT_EXT ".cat"
48#endif
49
50
51static int run_test (int, char**)
52{
53 const char * catalog =
54 "First set, first message\0\0"
55 "Second set, first message\0\0";
56
58
59 typedef std::messages<char> messagesT;
60
61 const std::locale loc;
62
63 const messagesT& msgs =
64 std::use_facet<messagesT>(loc);
65
66 messagesT::catalog cats [4];
67
68 std::size_t i;
69
70 // test STDCXX-508
71 for (i = 0; i < sizeof (cats) / sizeof (*cats); ++i) {
72 cats [i] = msgs.open (CATALOG CAT_EXT, loc);
73 assert (-1 != cats [i]);
74 }
75
76 // test STDCXX-542
77 while (i-- > 0)
78 msgs.close (cats [i]);
79
80 std::remove (CATALOG CAT_EXT);
81
82 return 0;
83}
84
85
86int main (int argc, char* argv[])
87{
88#ifdef _MSC_VER
89 // disable GUI window from abort()
90 _CrtSetReportMode (_CRT_ERROR, _CRTDBG_MODE_DEBUG);
91#endif
92
93 return rw_test (argc, argv, __FILE__,
94 "lib.locale.messages",
95 "STDCXX-508;STDCXX-542",
97 "",
98 (void*)0);
99}
#define i
Definition 17.names.cpp:126
#define loc
Definition 17.names.cpp:492
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
#define main
#define assert(expr)
Definition _cassert.h:40
_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_create_catalog(const char *, const char *)
Definition locale.cpp:920