60 if (
rw_snprintf (cm_fname,
sizeof cm_fname,
"%s%c%s",
64 static const char charmap[] = {
65 "<code_set_name> test_charmap \n"
73 "<U0002> /x32/x32 22 \n"
74 "<U0003> /x33/x33/x33 333 \n"
75 "<U0004> /x34/x34/x34/x34 4444 \n"
76 "<U0005> /x35/x35/x35/x35/x35 55555 \n"
77 "<U0006> /x36/x36/x36/x36/x36/x36 666666 \n"
78 "<U0007> /x37/x37/x37/x37/x37/x37/x37 7777777 \n"
79 "<U0008> /x38/x38/x38/x38/x38/x38/x38/x38 88888888 \n"
80 "<U0009> /x39/x39/x39/x39/x39/x39/x39/x39/x39 999999999 \n"
90 if (std::size_t (-1) ==
rw_fwrite (cm_fname, charmap))
93 char src_fname [1024];
94 if (
rw_snprintf (src_fname,
sizeof src_fname,
"%s%c%s",
98 if (std::size_t (-1) ==
rw_fwrite (src_fname,
"LC_CTYPE\nEND LC_CTYPE\n"))
107 const char*
const locname =
109 src_fname, cm_fname,
"mb_cur_max-9");
123get_mb_char (
wchar_t *wchar,
char *mbchar, std::size_t
bytes)
141 for (wc =
wchar_t (1); wc !=
wchar_t (0xffff); ++wc) {
143 if (
int (
bytes) == std::wctomb (mbchar, wc)
144 && int (
bytes) == std::mblen (mbchar,
bytes)) {
146 mbchar [
bytes] =
'\0';
154#if 2 < _RWSTD_WCHAR_SIZE
158 if (
wchar_t (0xffff) == wc) {
163 for (
int i = 0;
i != 0x100000; ++
i) {
167 typedef unsigned char UChar;
172 for (
int j = 0;
j < int (
sizeof wc); ++
j) {
177 if (
int (
bytes) == std::wctomb (mbchar, wc)
178 &&
int (
bytes) == std::mblen (mbchar,
bytes)) {
180 mbchar [
bytes] =
'\0';
192 return !exact ||
bytes == std::strlen (mbchar) ? mbchar : 0;
215 get_mb_char (&mb_chars [0].wchar,
221 "in locale \"%s\" with MB_CUR_MAX = %u\n",
227 std::size_t mb_cur_max = std::strlen (mbc);
234 for (std::size_t
i = mb_cur_max;
i; --
i) {
236 const std::size_t
inx =
i - 1;
239 mbc = get_mb_char (&mb_chars [
inx].wchar, mb_chars [
inx].mbchar,
i);
242 if (
i < mb_cur_max) {
244 " in locale \"%s\" with MB_CUR_MAX = %u\n",
273 static const char *mb_locale_name;
275 char saved_locale_name [1024];
276 std::strcpy (saved_locale_name, std::setlocale (
LC_CTYPE, 0));
288 const std::size_t cur_max = get_mb_chars (mb_chars);
290 if (*mb_cur_max < cur_max) {
291 *mb_cur_max = cur_max;
292 mb_locale_name =
name;
302 if (*mb_cur_max < 2) {
304 "characters in locale \"%s\" with MB_CUR_MAX = %u "
305 "(computed)", mb_locale_name, *mb_cur_max);
313 std::setlocale (
LC_CTYPE, mb_locale_name);
314 get_mb_chars (mb_chars);
317 std::setlocale (
LC_CTYPE, saved_locale_name);
319 return mb_locale_name;
326 return std::codecvt_base::error ==
res ?
"error"
327 : std::codecvt_base::ok ==
res ?
"ok"
328 : std::codecvt_base::partial ==
res ?
"partial"
333template <
class internT>
336 const std::mbstate_t *pstate,
337 const std::codecvt<internT, char, std::mbstate_t> &
cvt,
344 std::codecvt_base::result
result)
346 static const std::mbstate_t initial_state = std::mbstate_t ();
348 std::mbstate_t state = pstate ? *pstate : initial_state;
352 std::memset (
buf, -1,
sizeof buf);
355 const internT*
const from = src;
356 const internT*
const from_end = from + src_len;
357 const internT* from_next = 0;
360 char*
const to =
buf;
361 char*
const to_end = to + res_len;
365 const std::codecvt_base::result cvtres =
367 from, from_end, from_next,
368 to, to_end, to_next);
371 static char fcall [4096];
372 std::memset (fcall, 0,
sizeof fcall);
375 "codecvt<%s, char, mbstate_t>::out(state, "
376 "from = %{*.*Ac}, from + %td, from + %td, "
377 "to = %{#*s}, to + %d, to + %d)",
378 tname,
int (
sizeof *from),
int (src_len), from,
379 from_end - from, from_next - from,
380 int (to_next - to), to, to_end - to, to_next - to);
382 RW_ASSERT (std::strlen (fcall) <
sizeof fcall);
386 "line %d: %s == %s, got %s",
394 "line %d: %s: from_next == from + %d, got from + %d",
396 src_off, from_next - from);
401 "line %d: %s: to_next == to + %d, got to + %d",
403 res_off, to_next - to);
407 "line %d: %s: expected %{#*s}, got %{#*s}",
409 int (res_off),
res,
int (to_next - to), to);
414 "line %d: %s: expected %{#lc}, got %{#lc} "
415 "at end of destination buffer (offset %zu)",
417 -1, to [res_off], res_off);
420 rw_assert (!pstate || !std::memcmp (pstate, &state,
sizeof state),
422 "line %d: %s: unexpected conversion state",
428typedef std::codecvt<char, char, std::mbstate_t>
Codecvt;
437 "std::codecvt<char, char, mbstate_t>::out("
439 "const intern_type*, const intern_type*, "
440 "const intern_type*, "
441 "extern_type*, extern_type*, exterm_type*&)");
443 const std::locale classic = std::locale::classic ();
445 const Codecvt &
cvt = pcvt ? *pcvt : std::use_facet<Codecvt>(classic);
448#define TEST(from, from_end_off, from_next_off, \
449 res, res_end_off, res_next_off, result) \
450 test_out (__LINE__, "char", 0, cvt, \
451 from, from_end_off, from_next_off, \
452 res, res_end_off, res_next_off, \
453 std::codecvt_base::result)
464 TEST (
"", 0, 0,
"", 0, 0, noconv);
465 TEST (
"a", 1, 0,
"", 0, 0, noconv);
466 TEST (
"b", 1, 0,
"", 1, 0, noconv);
467 TEST (
"ab", 2, 0,
"", 0, 0, noconv);
468 TEST (
"bc", 2, 0,
"", 1, 0, noconv);
469 TEST (
"cd", 2, 0,
"", 2, 0, noconv);
470 TEST (
"abc", 3, 0,
"", 0, 0, noconv);
471 TEST (
"\0", 1, 0,
"", 0, 0, noconv);
477test_codecvt_byname ()
480 "std::codecvt_byname<char, char, mbstate_t>::out("
481 "state_type&, const intern_type*, const intern_type*, "
482 "const intern_type*, "
483 "extern_type*, extern_type*, exterm_type*&)");
492#ifndef _RWSTD_NO_WCHAR_T
494typedef std::codecvt<wchar_t, char, std::mbstate_t>
WCodecvt;
502 "std::codecvt<wchar_t, char, mbstate_t>::out("
504 "const intern_type*, const intern_type*, "
505 "const intern_type*, "
506 "extern_type*, extern_type*, exterm_type*&)");
508 const std::locale classic = std::locale::classic ();
510 const WCodecvt &
cvt = std::use_facet<WCodecvt>(classic);
513#define TEST(from, from_end_off, from_next_off, \
514 res, res_end_off, res_next_off, result) \
515 test_out (__LINE__, "wchar_t", 0, cvt, \
516 from, from_end_off, from_next_off, \
517 res, res_end_off, res_next_off, \
518 std::codecvt_base::result)
529 TEST (
L"", 0, 0,
"", 0, 0, ok);
530 TEST (
L"a", 1, 1,
"a", 1, 1, ok);
531 TEST (
L"ab", 2, 2,
"ab", 2, 2, ok);
532 TEST (
L"abc", 3, 3,
"abc", 3, 3, ok);
533 TEST (
L"\0", 1, 1,
"\0", 1, 1, ok);
534 TEST (
L"\x80", 1, 1,
"\x80", 1, 1, ok);
535 TEST (
L"\xff", 1, 1,
"\xff", 1, 1, ok);
536 TEST (
L"a\0", 2, 2,
"a\0", 2, 2, ok);
537 TEST (
L"a\0b", 3, 3,
"a\0b", 3, 3, ok);
538 TEST (
L"\0\0", 2, 2,
"\0\0", 2, 2, ok);
540 TEST (
L"123", 3, 0,
"", 0, 0, partial);
541 TEST (
L"234", 3, 1,
"2", 1, 1, partial);
542 TEST (
L"345", 3, 2,
"34", 2, 2, partial);
543 TEST (
L"456", 3, 3,
"456", 3, 3, ok);
544 TEST (
L"567", 3, 3,
"567", 4, 3, ok);
545 TEST (
L"6789", 3, 3,
"678", 4, 3, ok);
552test_wcodecvt_byname_algorithmic ()
554 rw_info (0, 0, __LINE__,
"locale (\"UTF-8@UCS\") [algorithmic encoding]");
564#define STRICT(from, from_end_off, from_next_off, \
565 res, res_end_off, res_next_off, result) \
566 test_out (__LINE__, "wchar_t", 0, cvt_strict, \
567 from, from_end_off, from_next_off, \
568 res, res_end_off, res_next_off, \
569 std::codecvt_base::result)
572#define RELAXD(from, from_end_off, from_next_off, \
573 res, res_end_off, res_next_off, result) \
574 test_out (__LINE__, "wchar_t", 0, cvt_relaxd, \
575 from, from_end_off, from_next_off, \
576 res, res_end_off, res_next_off, \
577 std::codecvt_base::result)
580#define TEST(from, from_end_off, from_next_off, \
581 res, res_end_off, res_next_off, result) \
582 STRICT (from, from_end_off, from_next_off, \
583 res, res_end_off, res_next_off, result); \
584 RELAXD (from, from_end_off, from_next_off, \
585 res, res_end_off, res_next_off, result)
596 TEST (
L"", 0, 0,
"", 0, 0, ok);
597 TEST (
L"a", 1, 1,
"a", 1, 1, ok);
598 TEST (
L"ab", 2, 2,
"ab", 2, 2, ok);
599 TEST (
L"abc", 3, 3,
"abc", 3, 3, ok);
600 TEST (
L"\0", 1, 1,
"\0", 1, 1, ok);
601 TEST (
L"a\0", 2, 2,
"a\0", 2, 2, ok);
602 TEST (
L"a\0b", 3, 3,
"a\0b", 3, 3, ok);
604 TEST (
L"123", 3, 0,
"", 0, 0, partial);
605 TEST (
L"234", 3, 1,
"2", 1, 1, partial);
606 TEST (
L"345", 3, 2,
"34", 2, 2, partial);
607 TEST (
L"456", 3, 3,
"456", 3, 3, ok);
608 TEST (
L"567", 3, 3,
"567", 4, 3, ok);
611 TEST (
L"\x100", 1, 0,
"\xc4\x80", 0, 0, partial);
612 TEST (
L"\x101", 1, 0,
"\xc4\x81", 1, 0, partial);
613 TEST (
L"\x102", 1, 1,
"\xc4\x82", 2, 2, ok);
615 TEST (
L"\x103x", 2, 0,
"\xc4\x83", 0, 0, partial);
616 TEST (
L"\x104y", 2, 1,
"\xc4\x84", 2, 2, partial);
617 TEST (
L"\x105z", 2, 2,
"\xc4\x85z", 3, 3, ok);
618 TEST (
L"\x106zz", 2, 2,
"\xc4\x86z", 4, 3, ok);
620 TEST (
L"\x0901", 1, 0,
"\xe0\xa4\x81", 0, 0, partial);
621 TEST (
L"\x0902", 1, 0,
"\xe0\xa4\x82", 1, 0, partial);
622 TEST (
L"\x0903", 1, 0,
"\xe0\xa4\x83", 2, 0, partial);
623 TEST (
L"\x0904", 1, 1,
"\xe0\xa4\x84", 3, 3, ok);
625 TEST (
L"\x0905\x0916", 2, 1,
"\xe0\xa4\x85\xe0\xa4\x96", 4, 3, partial);
626 TEST (
L"\x0906\x0917", 2, 1,
"\xe0\xa4\x86\xe0\xa4\x97", 5, 3, partial);
627 TEST (
L"\x0907\x0918", 2, 2,
"\xe0\xa4\x87\xe0\xa4\x98", 6, 6, ok);
633 STRICT (
L"\xd800", 1, 0,
"", 6, 0, error);
634 STRICT (
L"\xd801", 1, 0,
"", 6, 0, error);
635 STRICT (
L"A\xd802", 2, 1,
"A", 6, 1, error);
636 STRICT (
L"AB\xd803", 3, 2,
"AB", 6, 2, error);
637 STRICT (
L"ABC\xd804", 4, 3,
"ABC", 6, 3, error);
638 STRICT (
L"\xdffe", 1, 0,
"", 6, 0, error);
639 STRICT (
L"\xdfff", 1, 0,
"", 6, 0, error);
641 TEST (
L"\xe000", 1, 1,
"\xee\x80\x80", 6, 3, ok);
642 TEST (
L"\xd7ff", 1, 1,
"\xed\x9f\xbf", 6, 3, ok);
644 STRICT (
L"\xd800", 1, 0,
"", 6, 0, error);
645 STRICT (
L"\xd801", 1, 0,
"", 6, 0, error);
646 STRICT (
L"\xdffe", 1, 0,
"", 6, 0, error);
647 STRICT (
L"\xdfff", 1, 0,
"", 6, 0, error);
649 TEST (
L"\xe000", 1, 1,
"\xee\x80\x80", 6, 3, ok);
652 RELAXD (
L"\xd800", 1, 1,
"\xed\xa0\x80", 6, 3, ok);
653 RELAXD (
L"\xd801", 1, 1,
"\xed\xa0\x81", 6, 3, ok);
654 RELAXD (
L"\xdffe", 1, 1,
"\xed\xbf\xbe", 6, 3, ok);
655 RELAXD (
L"\xdfff", 1, 1,
"\xed\xbf\xbf", 6, 3, ok);
662test_wcodecvt_byname_table_based ()
670 rw_error (0, 0, __LINE__,
"failed to create a locale database");
677 loc = std::locale (locname);
680 rw_error (0, 0, __LINE__,
"locale(\"%s\") unexpectedly threw", locname);
684 const WCodecvt &cvt_table = std::use_facet<WCodecvt>(
loc);
686 rw_info (0, 0, __LINE__,
"locale (\"%s\") [table-based encoding]", locname);
689#define TEST(from, from_end_off, from_next_off, \
690 res, res_end_off, res_next_off, result) \
691 test_out (__LINE__, "wchar_t", 0, cvt_table, \
692 from, from_end_off, from_next_off, \
693 res, res_end_off, res_next_off, \
694 std::codecvt_base::result)
696 TEST (
L"", 0, 0,
"", 0, 0, ok);
697 TEST (
L"\x10", 1, 1,
"A", 1, 1, ok);
698 TEST (
L"\x11\x12", 2, 2,
"BC", 2, 2, ok);
699 TEST (
L"\x12\x13\x14", 3, 3,
"CDE", 3, 3, ok);
701 TEST (
L"\1\2\3\4\5\6", 1, 1,
"1", 21, 1, ok);
702 TEST (
L"\1\2\3\4\5\6", 2, 1,
"1", 1, 1, partial);
703 TEST (
L"\1\2\3\4\5\6", 2, 1,
"1", 2, 1, partial);
704 TEST (
L"\1\2\3\4\5\6", 2, 2,
"122", 3, 3, ok);
705 TEST (
L"\1\2\3\4\5\6", 2, 2,
"122", 21, 3, ok);
706 TEST (
L"\1\2\3\4\5\6", 3, 2,
"122", 3, 3, partial);
707 TEST (
L"\1\2\3\4\5\6", 3, 2,
"122", 4, 3, partial);
708 TEST (
L"\1\2\3\4\5\6", 3, 2,
"122", 5, 3, partial);
709 TEST (
L"\1\2\3\4\5\6", 3, 3,
"122333", 6, 6, ok);
710 TEST (
L"\1\2\3\4\5\6", 4, 3,
"122333", 7, 6, partial);
711 TEST (
L"\1\2\3\4\5\6", 3, 3,
"122333", 21, 6, ok);
712 TEST (
L"\1\2\3\4\5\6", 4, 4,
"1223334444", 21, 10, ok);
713 TEST (
L"\1\2\3\4\5\6", 5, 5,
"122333444455555", 21, 15, ok);
714 TEST (
L"\6\5\4\3\2\1", 6, 3,
"666666555554444", 15, 15, partial);
715 TEST (
L"\6\5\4\3\2\1", 6, 3,
"666666555554444", 16, 15, partial);
718 TEST (
L"*\3\4\5\6\7", 6, 0,
"", 27, 0, error);
719 TEST (
L"\2*\4\5\6\7", 6, 0,
"", 1, 0, partial);
720 TEST (
L"\2*\4\5\6\7", 6, 1,
"22", 2, 2, partial);
721 TEST (
L"\2*\4\5\6\7", 6, 1,
"22", 27, 2, error);
722 TEST (
L"\2*\4\5\6\7", 6, 1,
"22", 27, 2, error);
723 TEST (
L"\2\3*\5\6\7", 6, 2,
"22333", 27, 5, error);
724 TEST (
L"\2\3\4*\6\7", 6, 3,
"223334444", 27, 9, error);
730make_strings (
const char *pat, std::size_t patsize,
731 wchar_t *wstr,
char *mbstr,
739 typedef unsigned char UChar;
743 for (
const char *
s = pat;
s != pat + patsize; ++
s, ++wstr) {
751 std::size_t char_inx = *
s -
'0';
753 *wstr = mb_chars [char_inx].wchar;
755 std::strcpy (mbstr, mb_chars [char_inx].mbchar);
756 mbstr += std::strlen (mbstr);
772test_wcodecvt_byname_libc_based ()
784 std::size_t mb_cur_max = 0;
788 const char*
const locname = find_mb_locale (&mb_cur_max, mb_chars);
791 rw_warn (0, 0, __LINE__,
"unable to find a multibyte locale");
798 loc = std::locale (locname);
801 rw_error (0, 0, __LINE__,
"locale(\"%s\") unexpectedly threw", locname);
805 const WCodecvt &cvt_libc = std::use_facet<WCodecvt>(
loc);
807 rw_info (0, 0, __LINE__,
"locale (\"%s\") [libc-based encoding, "
808 "single-byte characters]", locname);
814#define TEST(from, from_end_off, from_next_off, \
815 res, res_end_off, res_next_off, result) \
816 test_out (__LINE__, "wchar_t", 0, cvt_libc, \
817 from, from_end_off, from_next_off, \
818 res, res_end_off, res_next_off, \
819 std::codecvt_base::result)
830 TEST (
L"", 0, 0,
"", 0, 0, ok);
831 TEST (
L"a", 1, 1,
"a", 1, 1, ok);
832 TEST (
L"b", 1, 1,
"b", 2, 1, ok);
833 TEST (
L"c", 1, 1,
"c", 3, 1, ok);
834 TEST (
L"d", 1, 1,
"d", 4, 1, ok);
835 TEST (
L"e", 1, 1,
"e", 5, 1, ok);
836 TEST (
L"f", 1, 1,
"f", 6, 1, ok);
837 TEST (
L"ab", 2, 2,
"ab", 6, 2, ok);
838 TEST (
L"abc", 3, 3,
"abc", 6, 3, ok);
839 TEST (
L"abcd", 4, 4,
"abcd", 6, 4, ok);
840 TEST (
L"abcde", 5, 5,
"abcde", 6, 5, ok);
841 TEST (
L"abcdef", 6, 6,
"abcdef", 6, 6, ok);
843 TEST (
L"\n", 1, 1,
"\n", 1, 1, ok);
844 TEST (
L"\n\377", 1, 1,
"\n", 1, 1, ok);
847 TEST (
L"\0abcdef", 7, 7,
"\0abcdef", 7, 7, ok);
848 TEST (
L"a\0bcdef", 7, 7,
"a\0bcdef", 7, 7, ok);
849 TEST (
L"ab\0cdef", 7, 7,
"ab\0cdef", 7, 7, ok);
850 TEST (
L"abc\0def", 7, 7,
"abc\0def", 7, 7, ok);
851 TEST (
L"abcd\0ef", 7, 7,
"abcd\0ef", 7, 7, ok);
852 TEST (
L"abcde\0f", 7, 7,
"abcde\0f", 7, 7, ok);
853 TEST (
L"abcdef\0", 7, 7,
"abcdef\0", 7, 7, ok);
855 TEST (
L"ab\0cd\0ef", 8, 8,
"ab\0cd\0ef", 8, 8, ok);
860 if (mb_cur_max < 2) {
861 rw_warn (0, 0, __LINE__,
"no multibyte characters found");
869 for (std::size_t
i = 0;
i < mb_cur_max; ++
i) {
870 const std::size_t mb_len = std::strlen (mb_chars [
i].mbchar);
872 if (
i + 1 != mb_len) {
874 "unexpected multibyte character length: "
875 "%u, expected %u", mb_len,
i + 1);
880 "%{+}%s{ %{#lc}, %{#s} }",
883 mb_chars [
i].mbchar);
887 "locale (\"%s\") [libc-based encoding, "
888 "MB_CUR_MAX = %u, multi-byte characters: %s]",
889 locname, mb_cur_max, (
const char*)sequences);
891 std::free (sequences);
893#ifdef _RWSTD_OS_SUNOS
895 if (0 == std::strcmp (
"5.7", _RWSTD_OS_RELEASE)) {
897 rw_warn (0, 0, __LINE__,
"skipping tests due to a SunOS 5.7 libc bug");
907#define TEST(pat, from_end_off, from_next_off, \
908 res_end_off, res_next_off, result) \
909 make_strings (pat, sizeof pat - 1, \
910 wstr, mbstr, mb_chars); \
911 test_out (__LINE__, "wchar_t", 0, cvt_libc, \
912 wstr, from_end_off, from_next_off, \
913 mbstr, res_end_off, res_next_off, \
914 std::codecvt_base::result)
929 TEST (
"%0", 0, 0, 0, 0, ok);
930 TEST (
"%0", 1, 0, 0, 0, partial);
931 TEST (
"%0", 1, 1, 1, 1, ok);
932 TEST (
"%1", 1, 0, 0, 0, partial);
933 TEST (
"%1", 1, 0, 1, 0, partial);
934 TEST (
"%1", 1, 1, 2, 2, ok);
936 TEST (
"a%1", 2, 1, 2, 1, partial);
937 TEST (
"b%1", 2, 2, 3, 3, ok);
939 TEST (
"%1%1", 2, 0, 1, 0, partial);
940 TEST (
"%1%1", 2, 1, 2, 2, partial);
941 TEST (
"%1%1", 2, 1, 3, 2, partial);
942 TEST (
"%1%1", 2, 2, 4, 4, ok);
944 TEST (
"%1X%1Y%1Z", 6, 0, 1, 0, partial);
945 TEST (
"%1X%1Y%1Z", 6, 1, 2, 2, partial);
946 TEST (
"%1X%1Y%1Z", 6, 2, 3, 3, partial);
947 TEST (
"%1X%1Y%1Z", 6, 2, 4, 3, partial);
948 TEST (
"%1X%1Y%1Z", 6, 3, 5, 5, partial);
949 TEST (
"%1X%1Y%1Z", 6, 4, 6, 6, partial);
950 TEST (
"%1X%1Y%1Z", 6, 4, 7, 6, partial);
951 TEST (
"%1X%1Y%1Z", 6, 5, 8, 8, partial);
952 TEST (
"%1X%1Y%1Z", 6, 6, 9, 9, ok);
955 TEST (
"\0", 1, 1, 1, 1, ok);
956 TEST (
"\0X", 2, 2, 2, 2, ok);
957 TEST (
"\0X\0", 3, 3, 3, 3, ok);
958 TEST (
"\0X\0Y", 4, 4, 4, 4, ok);
959 TEST (
"\0X\0Y\0", 5, 5, 5, 5, ok);
960 TEST (
"\0X\0Y\0Z", 6, 6, 6, 6, ok);
961 TEST (
"\0XYZ\0", 5, 5, 5, 5, ok);
963 TEST (
"%1\0", 2, 2, 3, 3, ok);
964 TEST (
"\0%1", 2, 2, 3, 3, ok);
966 TEST (
"%1\0%1", 3, 3, 5, 5, ok);
967 TEST (
"\0%1\0", 3, 3, 4, 4, ok);
969 TEST (
"%1\0%1\0%1\0", 6, 2, 3, 3, partial);
970 TEST (
"%1\0%1\0%1\0", 6, 3, 5, 5, partial);
971 TEST (
"%1\0%1\0%1\0", 6, 4, 6, 6, partial);
972 TEST (
"%1\0%1\0%1\0", 6, 5, 8, 8, partial);
973 TEST (
"%1\0%1\0%1\0", 6, 6, 9, 9, ok);
976 TEST (
"\0\0%1\0\0%1\0\0", 8, 8, 10, 10, ok);
977 TEST (
"\0\0\0\0\0\0\0XY", 9, 9, 9, 9, ok);
985 TEST (
"%2", 1, 0, 0, 0, partial);
986 TEST (
"%2", 1, 0, 1, 0, partial);
987 TEST (
"%2", 1, 0, 2, 0, partial);
988 TEST (
"%2", 1, 1, 3, 3, ok);
990 TEST (
"%2%1", 2, 0, 0, 0, partial);
991 TEST (
"%2%1", 2, 0, 1, 0, partial);
992 TEST (
"%2%1", 2, 0, 2, 0, partial);
993 TEST (
"%2%1", 2, 1, 3, 3, partial);
994 TEST (
"%2%1", 2, 1, 4, 3, partial);
995 TEST (
"%2%1", 2, 2, 5, 5, ok);
997 TEST (
"%2%2", 2, 0, 0, 0, partial);
998 TEST (
"%2%2", 2, 0, 1, 0, partial);
999 TEST (
"%2%2", 2, 0, 2, 0, partial);
1000 TEST (
"%2%2", 2, 1, 3, 3, partial);
1001 TEST (
"%2%2", 2, 1, 4, 3, partial);
1002 TEST (
"%2%2", 2, 1, 5, 3, partial);
1003 TEST (
"%2%2", 2, 2, 6, 6, ok);
1005 TEST (
"%2%1%2", 3, 0, 0, 0, partial);
1006 TEST (
"%2%1%2", 3, 0, 1, 0, partial);
1007 TEST (
"%2%1%2", 3, 0, 2, 0, partial);
1008 TEST (
"%2%1%2", 3, 1, 3, 3, partial);
1009 TEST (
"%2%1%2", 3, 1, 4, 3, partial);
1010 TEST (
"%2%1%2", 3, 2, 5, 5, partial);
1011 TEST (
"%2%1%2", 3, 2, 6, 5, partial);
1012 TEST (
"%2%1%2", 3, 2, 7, 5, partial);
1013 TEST (
"%2%1%2", 3, 3, 8, 8, ok);
1015 TEST (
"%2%1%2%0%1%2$", 6, 6, 14, 14, ok);
1018 TEST (
"\0%2$", 2, 2, 4, 4, ok);
1019 TEST (
"%2\0$", 2, 2, 4, 4, ok);
1020 TEST (
"\0\0%2$", 3, 3, 5, 5, ok);
1021 TEST (
"%2\0\0$", 3, 3, 5, 5, ok);
1022 TEST (
"\0\0%2\0%2$", 5, 5, 9, 9, ok);
1023 TEST (
"\0%2\0\0%2$", 5, 5, 9, 9, ok);
1024 TEST (
"\0%2\0%2\0$", 5, 5, 9, 9, ok);
1025 TEST (
"%2\0\0%2\0$", 5, 5, 9, 9, ok);
1026 TEST (
"%2\0%2\0\0$", 5, 5, 9, 9, ok);
1034 TEST (
"%3", 1, 0, 0, 0, partial);
1035 TEST (
"%3", 1, 0, 1, 0, partial);
1036 TEST (
"%3", 1, 0, 2, 0, partial);
1037 TEST (
"%3", 1, 0, 3, 0, partial);
1038 TEST (
"%3", 1, 1, 4, 4, ok);
1040 TEST (
"%3%3", 2, 0, 3, 0, partial);
1041 TEST (
"%3%3", 2, 1, 4, 4, partial);
1042 TEST (
"%3%3", 2, 1, 5, 4, partial);
1043 TEST (
"%3%3", 2, 1, 6, 4, partial);
1044 TEST (
"%3%3", 2, 1, 7, 4, partial);
1045 TEST (
"%3%3", 2, 2, 8, 8, ok);
1047 TEST (
"%3G%3", 3, 2, 8, 5, partial);
1048 TEST (
"%3G%3", 3, 3, 9, 9, ok);
1050 TEST (
"%3%1%3", 3, 2, 9, 6, partial);
1051 TEST (
"%3%1%3", 3, 3, 10, 10, ok);
1053 TEST (
"%3%2%1%0%1%2%3", 7, 7, 19, 19, ok);
1056 TEST (
"%3\0%2\0%1\0%0\0%1\0%2\0%3$", 13, 13, 25, 25, ok);
1058 TEST (
"%3\0\0%2%1\0%0\0%1\0%2%3\0$", 13, 13, 25, 25, ok);
1060 TEST (
"\0%3%2\0%1\0\0%0%1\0%2%3\0$", 13, 13, 25, 25, ok);
1062 TEST (
"\0%3%2\0%1%0%1\0%2%3\0\0\0$", 13, 13, 25, 25, ok);
1064 TEST (
"\0\0\0\0\0\0%3%2%1%0%1%2%3$", 13, 13, 25, 25, ok);
1070test_wcodecvt_byname ()
1073 "std::codecvt_byname<wchar_t, char, mbstate_t>::out("
1075 "const intern_type*, const intern_type*, "
1076 "const intern_type*, "
1077 "extern_type*, extern_type*, exterm_type*&)");
1079 test_wcodecvt_byname_algorithmic ();
1080 test_wcodecvt_byname_table_based ();
1081 test_wcodecvt_byname_libc_based ();
1097 test_codecvt_byname ();
1099#ifndef _RWSTD_NO_WCHAR_T
1103 test_wcodecvt_byname ();
1107 rw_warn (0, 0, __LINE__,
"_RWSTD_NO_WCHAR_T #defined, cannot test");
1118 return rw_test (argc, argv, __FILE__,
1119 "lib.locale.codecvt.virtuals",
std::codecvt< char, char, std::mbstate_t > Codecvt
std::codecvt< wchar_t, char, std::mbstate_t > WCodecvt
std::codecvt_byname< wchar_t, char, std::mbstate_t > WCodecvtByname
const char * create_locale()
std::codecvt_byname< char, char, std::mbstate_t > CodecvtByname
void test_codecvt(const Codecvt *pcvt=0)
std::codecvt< char, char, std::mbstate_t > Codecvt
std::codecvt< wchar_t, char, std::mbstate_t > WCodecvt
std::codecvt_byname< wchar_t, char, std::mbstate_t > WCodecvtByname
const char * codecvt_result(std::codecvt_base::result res)
void test_out(int line, const char *tname, const std::mbstate_t *pstate, const std::codecvt< internT, char, std::mbstate_t > &cvt, const internT *src, std::size_t src_len, std::size_t src_off, const char *res, std::size_t res_len, std::size_t res_off, std::codecvt_base::result result)
#define STRICT(from, from_end_off, from_next_off, res, res_end_off, res_next_off, result)
WideCode mb_char_array_t[MB_LEN_MAX]
std::codecvt_byname< char, char, std::mbstate_t > CodecvtByname
#define RELAXD(from, from_end_off, from_next_off, res, res_end_off, res_next_off, result)
#define TEST(from, from_end_off, from_next_off, res, res_end_off, res_next_off, result)
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
_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_error(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_warn(int, const char *, int, const char *,...)
_TEST_EXPORT _RWSTD_SIZE_T rw_fwrite(const char *, const void *, _RWSTD_SIZE_T=~0, const char *="w")
_TEST_EXPORT const char * rw_set_locale_root()
_TEST_EXPORT char * rw_locales(int=_UNUSED_CAT, const char *=0, bool=true)
_TEST_EXPORT const char * rw_localedef(const char *, const char *, const char *, const char *)
_TEST_EXPORT rw_file *const rw_stderr
_TEST_EXPORT int rw_snprintf(char *, _RWSTD_SIZE_T, const char *,...)
_TEST_EXPORT int rw_sprintf(char *, const char *,...)
_TEST_EXPORT int rw_fprintf(rw_file *, const char *,...)
_TEST_EXPORT int rw_asnprintf(char **pbuf, _RWSTD_SIZE_T *pbufsize, const char *fmt,...)
_TEST_EXPORT int rw_strncmp(const char *, const char *, _RWSTD_SIZE_T=_RWSTD_SIZE_MAX, int=CMP_NULTERM)
char mbchar[MB_LEN_MAX+1]