43 "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
44 "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f"
51extern const std::size_t
57extern const std::size_t
61graph[] =
"!\"#$%&\\()*+,-./0123456789:;<=>?@[]^_`{|}~";
63extern const std::size_t
67lower[] =
"abcdefghijklmnopqrstuvwxyz";
69extern const std::size_t
73punct[] =
"!#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~";
75extern const std::size_t
80 "!\"#$%&\\()*+,-./0123456789:;<=>?@[]^_`{|}~"
81 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
82 "abcdefghijklmnopqrstuvwxyz"
85extern const std::size_t
91extern const std::size_t
95upper[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
97extern const std::size_t
101xdigits[] =
"0123456789ABCDEFabcdef";
103extern const std::size_t
108template <
class charT>
112 rw_info (0, 0, __LINE__,
"UserCtype<%s>::id", cname);
114 std::locale::id*
const pid_b = &std::ctype<charT>::id;
118 "&ctype<%s>::id == &UserCtype<%1$s>::id "
119 "(%#p == %2$#p, got %#p)",
120 cname, pid_b, pid_d);
125template <
class charT>
128 std::ctype_base::mask
m,
129 const char *chars, std::size_t n_chars)
133 std::size_t n_calls = ctp.n_calls_ [ctp.mf_is];
134 std::size_t n_throws = ctp.n_throws_ [ctp.mf_is];
136 std::size_t expect_calls = 0;
137 std::size_t expect_throws = 0;
139 for (std::size_t
i = 0;
i != n_chars; ++
i) {
144#ifndef _RWSTD_NO_EXCEPTIONS
148 ctp.throw_at_calls_ [ctp.mf_is] =
149 ctp.n_calls_ [ctp.mf_is] + 2;
151 for (
int j = 0;
j != 2; ++
j) {
153 if (1 <
sizeof (
charT)) {
178 "UserCtype<%s>::is(%{LC}, %{#c}) "
179 "%{?}unexpectedly threw%{:}failed to throw%{;}",
180 cname,
m, ch,
j == threw);
191 "UserCtype<%s>::is(%{LC}, %{#c}) == true",
192 cname,
m, chars [
i]);
195 n_calls = ctp.n_calls_ [ctp.mf_is] - n_calls;
197 rw_assert (expect_calls == n_calls, 0, __LINE__,
198 "expected %zu calls to UserCtype<%s>::is(%{LC}, char_type), "
199 "got %zu", expect_calls, cname,
m, n_calls);
201 n_throws = ctp.n_throws_ [ctp.mf_is] - n_throws;
203 rw_assert (expect_throws == n_throws, 0, __LINE__,
204 "expected %zu exceptions thrown by UserCtype<%s>::is(%{LC}, "
205 "char_type), got %zu", expect_throws, cname,
m, n_throws);
208template <
class charT>
212 rw_info (0, 0, __LINE__,
"UserCtype<%s>::is"
213 "(mask, char_type) const", cname);
236 static const unsigned chars[] = {
237 '0',
'1',
'2',
'3',
'a',
'b',
'c',
238 0x100, 0x7fff, 0x8000, 0xffff,
239#if 2 < _RWSTD_INT_SIZE
240 0x10000, 0x7fffffff, 0x80000000, 0xffffffff,
242 0x1ff, 0x700, 0x8fff, 0xf000,
247 static const unsigned masks[] = {
248 std::ctype_base::alpha,
249 std::ctype_base::cntrl,
250 std::ctype_base::digit,
251 std::ctype_base::lower,
252 std::ctype_base::print,
253 std::ctype_base::punct,
254 std::ctype_base::space,
255 std::ctype_base::upper,
256 std::ctype_base::xdigit,
257 std::ctype_base::alpha | std::ctype_base::cntrl,
258 std::ctype_base::cntrl | std::ctype_base::digit,
259 std::ctype_base::digit | std::ctype_base::lower,
260 std::ctype_base::lower | std::ctype_base::print,
261 std::ctype_base::print | std::ctype_base::punct,
262 std::ctype_base::punct | std::ctype_base::space,
266 static const unsigned mask_all =
267 std::ctype_base::alpha
268 | std::ctype_base::cntrl
269 | std::ctype_base::digit
270 | std::ctype_base::lower
271 | std::ctype_base::print
272 | std::ctype_base::punct
273 | std::ctype_base::space
274 | std::ctype_base::upper
275 | std::ctype_base::xdigit;
279 for (std::size_t
i = 0; 0 <= chars [
i]; ++
i) {
282 if ( _RWSTD_UCHAR_MAX < std::size_t (chars [
i])
291 const std::ctype_base::mask m_is =
292 std::ctype_base::mask (masks [
i]);
296 "UserCtype<%s>::is(%{LC}, %{#lc}) == true",
297 cname, m_is, chars [
i]);
299 const std::ctype_base::mask m_not =
300 std::ctype_base::mask (~m_is & mask_all);
302 rw_assert (!cust.is (m_not, ch), 0, __LINE__,
303 "UserCtype<%s>::is(%{LC}, %{#lc}) == false",
304 cname, m_not, chars [
i]);
310template <
class charT>
314 rw_info (0, 0, __LINE__,
"UserCtype<%s>::scan_is"
315 "(mask, const char_type*, const char_type*) const", cname);
317 rw_warn (0, 0, __LINE__,
"UserCtype<%s>::scan_is"
318 "(mask, const char_type*, const char_type*) const"
319 " not exercised", cname);
324template <
class charT>
328 rw_info (0, 0, __LINE__,
"UserCtype<%s>::scan_not"
329 "(mask, const char_type*, const char_type*) const", cname);
331 rw_warn (0, 0, __LINE__,
"UserCtype<%s>::scan_not"
332 "(mask, const char_type*, const char_type*) const "
333 "not exercised", cname);
338template <
class charT>
342 rw_info (0, 0, __LINE__,
"UserCtype<%s>::toupper"
343 "(char_type) const", cname);
345 rw_warn (0, 0, __LINE__,
"UserCtype<%s>::toupper"
346 "(char_type) const not exercised", cname);
348 rw_info (0, 0, __LINE__,
"UserCtype<%s>::toupper"
349 "(char_type*, const char_type) const", cname);
351 rw_warn (0, 0, __LINE__,
"UserCtype<%s>::toupper"
352 "(char_type*, const char_type) const not exercised", cname);
357template <
class charT>
361 rw_info (0, 0, __LINE__,
"UserCtype<%s>::tolower"
362 "(char_type) const", cname);
364 rw_warn (0, 0, __LINE__,
"UserCtype<%s>::tolower"
365 "(char_type) const not exercised", cname);
367 rw_info (0, 0, __LINE__,
"UserCtype<%s>::tolower"
368 "(char_type*, const char_type) const", cname);
370 rw_warn (0, 0, __LINE__,
"UserCtype<%s>::tolower"
371 "(char_type*, const char_type) const not exercised", cname);
376template <
class charT>
380 rw_info (0, 0, __LINE__,
"UserCtype<%s>::widen"
381 "(char) const", cname);
383 rw_warn (0, 0, __LINE__,
"UserCtype<%s>::widen"
384 "(char) const not exercised", cname);
386 rw_info (0, 0, __LINE__,
"UserCtype<%s>::widen"
387 "(const char*, const char*, char_type*) const", cname);
389 rw_warn (0, 0, __LINE__,
"UserCtype<%s>::widen"
390 "(const char*, const char*, char_type*) const not exercised",
396template <
class charT>
400 rw_info (0, 0, __LINE__,
"UserCtype<%s>::narrow"
401 "(char_type, char) const", cname);
403 rw_warn (0, 0, __LINE__,
"UserCtype<%s>::narrow"
404 "(char_type, char) const not exercised", cname);
406 rw_info (0, 0, __LINE__,
"UserCtype<%s>::narrow"
407 "(const char_type*, const char_type*, char, char*) const",
410 rw_warn (0, 0, __LINE__,
"UserCtype<%s>::narrow"
411 "(const char_type*, const char_type*, char, char*) const"
431template <
class charT>
436 if (0 <= opt_ ## func) \
437 test_ ## func ((charT*)0, cname); \
439 rw_note (0, 0, __LINE__, \
440 "UserCtype<%s>::%s() tests disabled", \
461 test ((
char*)0,
"char");
463#ifndef _RWSTD_NO_WCHAR_T
464 test ((
wchar_t*)0,
"wchar_t");
474int main (
int argc,
char *argv[])
476 return rw_test (argc, argv, __FILE__,
const std::size_t n_cntrl
const std::size_t n_graph
const std::size_t n_spaces
const std::size_t n_digits
void test_tolower(charT *, const char *cname)
const std::size_t n_xdigits
void test_is(charT *, const char *cname, std::ctype_base::mask m, const char *chars, std::size_t n_chars)
const std::size_t n_punct
void test_narrow(charT *, const char *cname)
void test_toupper(charT *, const char *cname)
void test_widen(charT *, const char *cname)
void test_scan_is(charT *, const char *cname)
const std::size_t n_print
const std::size_t n_lower
void test_scan_not(charT *, const char *cname)
void test_id(charT *, const char *cname)
const std::size_t n_upper
const char * widen(char *dst, const char *src)
const char * narrow(char *dst, const char *src)
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
UserChar make_char(char c, UserChar *)
_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_assert(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_warn(int, const char *, int, const char *,...)