54#if 255U == _RWSTD_UCHAR_MAX
58 static const std::size_t
N = 256;
63 static const std::size_t
N = std::ctype<char>::table_size;
68 struct ClassicTable: std::ctype<char> {
69 static const std::ctype_base::mask* get () {
70 return classic_table ();
75 const std::ctype_base::mask*
const classic = ClassicTable::get ();
77 static int chars [
N + 1];
78 static int masks [
N + 1];
84 for (std::size_t
i = 0;
i !=
N; ++
i) {
86 masks [
i] = classic [
i] &
~std::ctype_base::space;
89 typedef unsigned char UChar;
92 for (
const char *ws =
data.whitespace; *ws; ++ws)
93 masks [
UChar (*ws)] |= std::ctype_base::space;
97 const std::ctype<CharT>*
const ctp =
100 struct NumPunct: std::numpunct<CharT> {
104 typedef std::numpunct<CharType>
Base;
105 typedef std::char_traits<CharType>
Traits;
106 typedef std::allocator<CharType>
Allocator;
107 typedef std::basic_string<CharType, Traits, Allocator>
String;
115 NumPunct (
int dp,
int ts,
const char *grp,
117 :
Base (), dp_ (dp), ts_ (ts), grp_ (grp ? grp :
""),
118 fn_ (fn), tn_ (tn) { }
120 CharType do_decimal_point ()
const {
121 return -1 == dp_ ? Base::do_decimal_point ()
125 CharType do_thousands_sep ()
const {
126 return -1 == ts_ ? Base::do_thousands_sep ()
130 std::string do_grouping ()
const {
131 return 0 == grp_ ? Base::do_grouping ()
132 : std::string (grp_);
135 String do_truename ()
const {
136 return 0 == tn_ ? Base::do_truename () :
String (tn_);
139 String do_falsename ()
const {
140 return 0 == fn_ ? Base::do_falsename () :
String (fn_);
144 static CharT names [2][64];
146 names [
false][0] =
CharT ();
147 names [
true][0] =
CharT ();
149 if (
data.falsename) {
150 for (std::size_t
i = 0;
data.falsename [
i]; ++
i) {
151 names [
false][
i] =
data.falsename [
i];
152 names [
false][
i + 1] =
CharT ();
157 for (std::size_t
i = 0;
data.truename [
i]; ++
i) {
158 names [
true][
i] =
data.truename [
i];
159 names [
true][
i + 1] =
CharT ();
165 const std::numpunct<CharT>*
const np =
166 new NumPunct (
data.decimal_point,
169 data.falsename ? names [
false] : 0,
170 data.truename ? names [
true] : 0);
174 const std::locale
tmp (std::locale::classic (), np);
178 return std::locale (
tmp, ctp);
183template <
class CharT,
class Traits>
191 typedef std::istreambuf_iterator<CharT, Traits>
Iterator;
192 typedef std::num_get<CharT, Iterator>
NumGet;
197 if (std::has_facet<NumGet>(
tmp))
208template <
class CharT,
class Traits,
class ArithmeticType>
220 std::size_t cbuf_size,
230 int expect_exception,
239 ArithmeticType init_value,
241 ArithmeticType expect_value)
246 typedef std::basic_istream<CharT, Traits> Istream;
249 const char *fail_desc = 0;
258 fail_when = -fail_when;
261 else if (0 < fail_when) {
266 fail_desc =
"returned EOF";
271 Streambuf sb (cbuf, cbuf_size, fail_how, fail_when);
283 is.flags (std::ios::fmtflags (
flags));
286 if (-1 == exceptions) {
288 exceptions = is.exceptions ();
294 is.exceptions (std::ios::iostate (exceptions));
297 if (-1 == init_state) {
299 init_state = is.rdstate ();
304#ifndef _RWSTD_NO_EXCEPTIONS
306 is.setstate (std::ios::iostate (init_state));
312 is.setstate (std::ios::iostate (init_state));
318 const std::locale
loc =
328 ArithmeticType
value = init_value;
333 "%{$CLASS}(%{*Ac}).operator>>(%s& = %{@}): "
334 "initial flags() = %{If}, rdstate() = %{Is}, "
335 "exceptions() = %{Is}, whitespace = %{#s}, numpunct = { "
336 ".dp=%{#c}, .ts=%{#c}, .grp=%{#s}, .fn=%{#s}, .tn=%{#s} }",
337 int (
sizeof *cbuf), cbuf, aname, valfmt, init_value,
344#ifndef _RWSTD_NO_EXCEPTIONS
354 catch (std::ios_base::failure &ex) {
357 "line %d. %{$FUNCALL}: unexpectedly threw "
358 "ios_base::failure(%{#s})", __LINE__, ex.what ());
363 "line %d. %{$FUNCALL}: unexpectely threw an exception "
364 "of unknown type", __LINE__);
373 "line %d. %{$FUNCALL}: "
374 "%{?}failed to throw"
375 "%{:}unexpectedly propagated"
377 __LINE__, expect_exception);
394 const int extracted = int (
sb.pubgptr () -
sb.pubeback ());
397 "%d. %{$FUNCALL}: expected to extract %d characters, "
398 "got %d%{?} (underflow() %s at extraction %u)%{;}",
399 __LINE__, expect_extract,
400 extracted, 0 != fail_desc, fail_desc, fail_when);
407 "%d. %{$FUNCALL}: gcount() == 0, got %d "
408 "%{?} (underflow() %s at extraction %u)%{;}",
409 __LINE__, is.gcount (),
410 0 != fail_desc, fail_desc, fail_when);
416 "line %d. %{$FUNCALL}: rdstate() == %{Is}, got %{Is}"
417 "%{?} (underflow() %s at extraction %u)%{;}",
418 __LINE__, expect_state, is.rdstate(),
419 0 != fail_desc, fail_desc, fail_when);
425 "line %d. %{$FUNCALL}: expected value %{@}, got %{@}",
426 __LINE__, valfmt, expect_value, valfmt,
value);
433const int __f = 0 | 0 | std::ios::failbit;
434const int _e_ = 0 | std::ios::eofbit | 0;
435const int _ef = 0 | std::ios::eofbit | std::ios::failbit;
436const int b__ = std::ios::badbit | 0 | 0;
437const int b_f = std::ios::badbit | 0 | std::ios::failbit;
438const int be_ = std::ios::badbit | std::ios::eofbit | 0;
439const int bef = std::ios::badbit | std::ios::eofbit | std::ios::failbit;
441const int DEC = std::ios::dec;
442const int OCT = std::ios::oct;
443const int HEX = std::ios::hex;
446template <
class CharT,
class Traits,
class ArithmeticType>
454 typedef ArithmeticType
T;
460 static const volatile T zero =
T ();
461 static const volatile T negative_one =
T (-1);
463 const bool is_signed = negative_one <
zero;
464 const bool is_floating =
zero > negative_one / 2;
469#define TEST(str, fl, is, ex, ee, es, ne, fw, iv, ev) \
470 if (is_signed || 0 <= ev) \
471 test_extractor ((CharT*)0, (Traits*)0, (T*)0, cname, tname, aname, \
472 __LINE__, fmt, str, sizeof str - 1, locale_data, \
473 fl, is, ex, ee, es, ne, fw, (T)(iv), (T)ev)
489 TEST (
"", -1, -1, -1, 0,
_ef, 0, 0, 1, 1);
490 TEST (
" ", -1, -1, -1, 0,
__f, 0, 0, 2, 2);
491 TEST (
" ", -1, -1, -1, 0,
_ef, 0, 1, 3, 3);
492 TEST (
" ", -1, -1, -1, 0,
b__, 0, -1, 4, 4);
500 TEST (
" ", -1,
be_, -1, 0,
bef, 0, -1, 10, 10);
501 TEST (
" ", -1,
bef, -1, 0,
bef, 0, -1, 11, 11);
516 TEST (
" ", -1, -1, -1, 0,
_ef, 1, 0, 9, 9);
517 TEST (
" ", -1, -1, -1, 0,
_ef, 0, 1, 9, 9);
518 TEST (
" ", -1, -1, -1, 0,
b__, 0, -1, 9, 9);
519 TEST (
" ", -1, -1, -1, 0,
_ef, 1, 2, 9, 9);
520 TEST (
" ", -1, -1, -1, 0,
b__, 1, -2, 9, 9);
521 TEST (
"_", -1, -1, -1, 0,
__f, 0, 0, 9, 9);
523 TEST (
" ", 0, -1, -1, 0,
__f, 0, 0, 9, 9);
526 TEST (
" ", -1, -1, -1, 0,
__f, 0, 0, 9, 9);
527 TEST (
"_", -1, -1, -1, 0,
_ef, 1, 0, 9, 9);
530 TEST (
"0", -1, -1, -1, 0,
_e_, 1, 0, 9, 0);
531 TEST (
"1", -1, -1, -1, 0,
_e_, 1, 0, 9, 1);
532 TEST (
"+0", -1, -1, -1, 0,
_e_, 2, 0, 9, 0);
533 TEST (
"-0", -1, -1, -1, 0,
_e_, 2, 0, 9, 0);
534 TEST (
"+1", -1, -1, -1, 0,
_e_, 2, 0, 9, 1);
535 TEST (
"-1", -1, -1, -1, 0,
_e_, 2, 0, 1, -1);
536 TEST (
"+2 ", -1, -1, -1, 0,
___, 2, 0, 9, 2);
537 TEST (
"-2 ", -1, -1, -1, 0,
___, 2, 0, 9, -2);
540 TEST (
"3.", -1, -1, -1, 0,
_e_, 2, 0, 9, 3);
541 TEST (
"+3.", -1, -1, -1, 0,
_e_, 3, 0, 9, 3);
542 TEST (
"-3.", -1, -1, -1, 0,
_e_, 3, 0, 9, -3);
545 TEST (
"3.", -1, -1, -1, 0,
___, 1, 0, 9, 3);
546 TEST (
"+3.", -1, -1, -1, 0,
___, 2, 0, 9, 3);
547 TEST (
"-3.", -1, -1, -1, 0,
___, 2, 0, 9, -3);
552 TEST (
"#+3", -1, -1, -1, 0,
_e_, 3, 0, 9, 3);
553 TEST (
"#-4", -1, -1, -1, 0,
_e_, 3, 0, 9, -4);
554 TEST (
"#+5", -1, -1, -1, 0,
_e_, 3, 0, 9, 5);
555 TEST (
"#-6", -1, -1, -1, 0,
_e_, 3, 0, 9, -6);
556 TEST (
"#+7#", -1, -1, -1, 0,
___, 3, 0, 9, 7);
557 TEST (
"#-8#", -1, -1, -1, 0,
___, 3, 0, 9, -8);
558 TEST (
" -9", -1, -1, -1, 0,
__f, 0, 0, -9, -9);
562 TEST (
"X10", -1, -1, -1, 0,
_e_, 3, 0, 9, 10);
563 TEST (
"XY11", -1, -1, -1, 0,
_e_, 4, 0, 9, 11);
564 TEST (
"XYZ12", -1, -1, -1, 0,
_e_, 5, 0, 9, 12);
568 TEST (
"9", -1, -1, -1, 0,
_ef, 1, 0, 8, 8);
569 TEST (
"99", -1, -1, -1, 0,
_ef, 2, 0, 8, 8);
570 TEST (
"999", -1, -1, -1, 0,
_ef, 3, 0, 8, 8);
571 TEST (
"9991", -1, -1, -1, 0,
_e_, 4, 0, 8, 1);
578 TEST (
"0;0", -1, -1, -1, 0,
_e_, 3, 0, 9, 0);
579 TEST (
"+0;0", -1, -1, -1, 0,
_e_, 4, 0, 9, 0);
580 TEST (
"-0;0", -1, -1, -1, 0,
_e_, 4, 0, 9, 0);
581 TEST (
"+0;1", -1, -1, -1, 0,
_e_, 4, 0, 9, 1);
582 TEST (
"-0;1", -1, -1, -1, 0,
_e_, 4, 0, 9, -1);
583 TEST (
"0;1", -1, -1, -1, 0,
_e_, 3, 0, 9, 1);
584 TEST (
"1;0", -1, -1, -1, 0,
_e_, 3, 0, 9, 10);
585 TEST (
"1;2", -1, -1, -1, 0,
_e_, 3, 0, 9, 12);
586 TEST (
"_1;2", -1, -1, -1, 0,
_e_, 4, 0, 9, 12);
587 TEST (
"_1;2_", -1, -1, -1, 0,
___, 4, 0, 9, 12);
588 TEST (
"_1_;2", -1, -1, -1, 0,
___, 2, 0, 9, 1);
589 TEST (
"12345", -1, -1, -1, 0,
_e_, 5, 0, 9, 12345);
590 TEST (
"1;2;3;4;5", -1, -1, -1, 0,
_e_, 9, 0, 9, 12345);
591 TEST (
"12;3;4;5", -1, -1, -1, 0,
_ef, 8, 0, 9, 12345);
597 TEST (
" 0", -1, -1, -1, 0,
_e_, 2, 0, 9, 0);
598 TEST (
" 0", -1, -1, -1, 0,
_e_, 3, 0, 9, 0);
599 TEST (
" 0", -1, -1, -1, 0,
_e_, 4, 0, 9, 0);
600 TEST (
" 0 00", -1, -1, -1, 0,
_e_, 5, 0, 9, 0);
601 TEST (
"+0 00", -1, -1, -1, 0,
_e_, 5, 0, 9, 0);
602 TEST (
"-0 00", -1, -1, -1, 0,
_e_, 5, 0, 9, 0);
603 TEST (
" +0 00", -1, -1, -1, 0,
_e_, 6, 0, 9, 0);
604 TEST (
" -0 00", -1, -1, -1, 0,
_e_, 6, 0, 9, 0);
605 TEST (
" +0 00", -1, -1, -1, 0,
_e_, 7, 0, 9, 0);
606 TEST (
" -0 00", -1, -1, -1, 0,
_e_, 7, 0, 9, 0);
607 TEST (
" +00 00", -1, -1, -1, 0,
_e_, 7, 0, 9, 0);
608 TEST (
" -00 00", -1, -1, -1, 0,
_e_, 7, 0, 9, 0);
609 TEST (
" 00 01", -1, -1, -1, 0,
_e_, 7, 0, 9, 1);
610 TEST (
" +00 01", -1, -1, -1, 0,
_e_, 7, 0, 9, 1);
611 TEST (
" -00 01", -1, -1, -1, 0,
_e_, 7, 0, 1, -1);
612 TEST (
"0 01 02", -1, -1, -1, 0,
_e_, 7, 0, 9, 102);
613 TEST (
"1 02 03", -1, -1, -1, 0,
_e_, 7, 0, 9, 10203);
614 TEST (
"2 03 04", -1, -1, -1, 0,
_e_, 7, 0, 9, 20304);
615 TEST (
"304 05", -1, -1, -1, 0,
_ef, 6, 0, 9, 30405);
616 TEST (
"4 0 5 0", -1, -1, -1, 0,
_ef, 7, 0, 9, 4050);
625 TEST (
";", -1, -1, -1, 0,
__f, 0, 0, 9, 9);
626 TEST (
";;", -1, -1, -1, 0,
__f, 0, 0, 9, 9);
627 TEST (
"_;", -1, -1, -1, 0,
__f, 1, 0, 9, 9);
628 TEST (
"+;", -1, -1, -1, 0,
__f, 1, 0, 9, 9);
629 TEST (
"-;", -1, -1, -1, 0,
__f, 1, 0, 9, 9);
630 TEST (
"0;", -1, -1, -1, 0,
_ef, 2, 0, 9, 9);
631 TEST (
"+0;", -1, -1, -1, 0,
_ef, 3, 0, 9, 9);
632 TEST (
"-0;", -1, -1, -1, 0,
_ef, 3, 0, 9, 9);
633 TEST (
"+1;", -1, -1, -1, 0,
_ef, 3, 0, 9, 9);
634 TEST (
"-1;", -1, -1, -1, 0,
_ef, 3, 0, 9, 9);
635 TEST (
"1;", -1, -1, -1, 0,
_ef, 2, 0, 9, 9);
636 TEST (
"0;_", -1, -1, -1, 0,
__f, 2, 0, 9, 9);
637 TEST (
"1;_", -1, -1, -1, 0,
__f, 2, 0, 9, 9);
638 TEST (
"_0;", -1, -1, -1, 0,
_ef, 3, 0, 9, 9);
639 TEST (
"_1;", -1, -1, -1, 0,
_ef, 3, 0, 9, 9);
640 TEST (
"0;;", -1, -1, -1, 0,
__f, 2, 0, 9, 9);
641 TEST (
"1;;", -1, -1, -1, 0,
__f, 2, 0, 9, 9);
642 TEST (
";0", -1, -1, -1, 0,
__f, 0, 0, 9, 9);
643 TEST (
";1", -1, -1, -1, 0,
__f, 0, 0, 9, 9);
644 TEST (
"_;0", -1, -1, -1, 0,
__f, 1, 0, 9, 9);
645 TEST (
"_;1", -1, -1, -1, 0,
__f, 1, 0, 9, 9);
651 TEST (
" ", -1, -1, -1, 0,
_ef, 1, 0, 9, 9);
652 TEST (
" +", -1, -1, -1, 0,
_ef, 2, 0, 9, 9);
653 TEST (
" -", -1, -1, -1, 0,
_ef, 2, 0, 9, 9);
654 TEST (
" + ", -1, -1, -1, 0,
__f, 2, 0, 9, 9);
655 TEST (
" - ", -1, -1, -1, 0,
__f, 2, 0, 9, 9);
656 TEST (
" 0 ", -1, -1, -1, 0,
_ef, 3, 0, 9, 9);
657 TEST (
" +0 ", -1, -1, -1, 0,
_ef, 4, 0, 9, 9);
658 TEST (
" -0 ", -1, -1, -1, 0,
_ef, 4, 0, 9, 9);
659 TEST (
" 123 ", -1, -1, -1, 0,
_ef, 5, 0, 9, 9);
660 TEST (
" +123 ", -1, -1, -1, 0,
_ef, 6, 0, 9, 9);
661 TEST (
" -123 ", -1, -1, -1, 0,
_ef, 6, 0, 9, 9);
666void info (
const char *cname,
const char *tname,
const char *type)
671 "%{?}istream%{:}%{?}wistream"
672 "%{:}basic_istream<%s, %s>%{;}%{;}",
673 'c' == *cname &&
's' == *tname,
674 'w' == *cname &&
's' == *tname,
677 rw_info (0, 0, __LINE__,
"std::%{$CLASS}::operator>>(%s&)", type);
683#define TEST(T, fmt, str, fl, is, ex, ee, es, ne, fw, iv, ev) \
684 test_extractor ((CharT*)0, (Traits*)0, (T*)0, cname, tname, #T, \
685 __LINE__, fmt, str, sizeof str - 1, locale_data, \
686 fl, is, ex, ee, es, ne, fw, (T)(iv), (T)ev)
690template <
class CharT,
class Traits>
696 info (cname, tname,
"bool");
698#define TEST_BOOL(ss, fl, is, ex, ee, es, ne, fw, iv, ev) \
699 TEST (bool, "%b", ss, fl, is, ex, ee, es, ne, fw, iv, ev)
701 const int ba = std::ios::boolalpha;
702 const int ba_ws = ba | std::ios::skipws;
704 LocaleData locale_data = { 0, -1, -1, 0, 0, 0 };
713 TEST_BOOL (
"+0", -1, -1, -1, 0,
_e_, 2, 0,
true,
false);
714 TEST_BOOL (
"-0", -1, -1, -1, 0,
_e_, 2, 0,
true,
false);
715 TEST_BOOL (
"+1", -1, -1, -1, 0,
_e_, 2, 0,
false,
true);
716 TEST_BOOL (
"00", -1, -1, -1, 0,
_e_, 2, 0,
true,
false);
717 TEST_BOOL (
"01", -1, -1, -1, 0,
_e_, 2, 0,
false,
true);
718 TEST_BOOL (
"_000", -1, -1, -1, 0,
_e_, 4, 0,
true,
false);
719 TEST_BOOL (
"_001", -1, -1, -1, 0,
_e_, 4, 0,
false,
true);
722 TEST_BOOL (
"YES", -1, -1, -1, 0,
__f, 0, 0,
false,
false);
723 TEST_BOOL (
"_NO", -1, -1, -1, 0,
__f, 1, 0,
true,
true);
724 TEST_BOOL (
"_YES", -1, -1, -1, 0,
__f, 1, 0,
false,
false);
726 TEST_BOOL (
"NO", ba, -1, -1, 0,
___, 2, 0,
false,
false);
727 TEST_BOOL (
"YES", ba, -1, -1, 0,
___, 3, 0,
true,
true);
728 TEST_BOOL (
"_NO", ba_ws, -1, -1, 0,
___, 3, 0,
false,
false);
729 TEST_BOOL (
"_YES", ba_ws, -1, -1, 0,
___, 4, 0,
true,
true);
730 TEST_BOOL (
"_NO_", ba_ws, -1, -1, 0,
___, 3, 0,
false,
false);
731 TEST_BOOL (
"_YES_", ba_ws, -1, -1, 0,
___, 4, 0,
true,
true);
736 TEST_BOOL (
"bool:0", ba, -1, -1, 0,
___, 6, 0,
false,
false);
737 TEST_BOOL (
"bool:1", ba, -1, -1, 0,
___, 6, 0,
true,
true);
738 TEST_BOOL (
"bool:2", ba, -1, -1, 0,
__f, 5, 0,
true,
true);
743template <
class CharT,
class Traits>
749 info (cname, tname,
"short");
752 cname, tname,
"short",
"%hi");
754#define TEST_SHRT(ss, fl, is, ex, ee, es, ne, fw, iv, ev) \
755 TEST (short, "%hi", ss, fl, is, ex, ee, es, ne, fw, iv, ev)
757 LocaleData locale_data = { 0, -1, -1, 0, 0, 0 };
760#if 2 == _RWSTD_SHRT_SIZE
761 const short smax = +32767;
762 const short smin = -smax - 1;
764 TEST_SHRT (
"-32768", -1, -1, -1, 0,
_e_, 6, 0, -1, smin);
765 TEST_SHRT (
"-32769", -1, -1, -1, 0,
_ef, 6, 0, -1, smin);
766 TEST_SHRT (
"-99999", -1, -1, -1, 0,
_ef, 6, 0, -1, smin);
768 TEST_SHRT (
"+32767", -1, -1, -1, 0,
_e_, 6, 0, -1, smax);
769 TEST_SHRT (
"+32768", -1, -1, -1, 0,
_ef, 6, 0, -1, smax);
770 TEST_SHRT (
"+99999", -1, -1, -1, 0,
_ef, 6, 0, -1, smax);
771 TEST_SHRT (
"999999", -1, -1, -1, 0,
_ef, 6, 0, -1, smax);
773#elif 4 == _RWSTD_SHRT_SIZE
774 const short smax = +2147483647;
775 const short smin = -smax - 1;
777 TEST_SHRT (
"-2147483648", -1, -1, -1, 0,
_e_, 11, 0, -1, smin);
778 TEST_SHRT (
"-2147483649", -1, -1, -1, 0,
_ef, 11, 0, -1, smin);
779 TEST_SHRT (
"-9999999999", -1, -1, -1, 0,
_ef, 11, 0, -1, smin);
781 TEST_SHRT (
"+2147483647", -1, -1, -1, 0,
_e_, 11, 0, -1, smax);
782 TEST_SHRT (
"+2147483648", -1, -1, -1, 0,
_ef, 11, 0, -1, smax);
783 TEST_SHRT (
"+9999999999", -1, -1, -1, 0,
_ef, 11, 0, -1, smax);
784 TEST_SHRT (
"99999999999", -1, -1, -1, 0,
_ef, 11, 0, -1, smax);
791template <
class CharT,
class Traits>
797 info (cname, tname,
"unsigned short");
800 cname, tname,
"unsigned short",
"%hu");
802#define TEST_USHRT(ss, fl, is, ex, ee, es, ne, fw, iv, ev) \
803 TEST (unsigned short, "%hu", ss, fl, is, ex, ee, es, ne, fw, iv, ev)
805 LocaleData locale_data = { 0, -1, -1, 0, 0, 0 };
808#if 2 == _RWSTD_USHRT_SIZE
809 const unsigned short usmax = 65535U;
811 TEST_SHRT (
"65535", -1, -1, -1, 0,
_e_, 5, 0, 1, usmax);
812 TEST_SHRT (
"65536", -1, -1, -1, 0,
_ef, 5, 0, 1, usmax);
813 TEST_SHRT (
"99999", -1, -1, -1, 0,
_ef, 5, 0, 1, usmax);
814#elif 4 == _RWSTD_USHRT_SIZE
815 const unsigned short usmax = 4294967295U;
817 TEST_SHRT (
"4294967295", -1, -1, -1, 0,
_e_, 10, 0, -1, usmax);
818 TEST_SHRT (
"4294967296", -1, -1, -1, 0,
_ef, 10, 0, -1, usmax);
819 TEST_SHRT (
"9999999999", -1, -1, -1, 0,
_ef, 10, 0, -1, usmax);
826template <
class CharT,
class Traits>
832 info (cname, tname,
"int");
835 cname, tname,
"int",
"%i");
837#define TEST_INT(ss, fl, is, ex, ee, es, ne, fw, iv, ev) \
838 TEST (int, "%i", ss, fl, is, ex, ee, es, ne, fw, iv, ev)
840 LocaleData locale_data = { 0, -1, -1, 0, 0, 0 };
843#if 2 == _RWSTD_INT_SIZE
844 const int imax = +32767;
845 const int imin = -imax - 1;
847 TEST_INT (
"-32768", -1, -1, -1, 0,
_e_, 6, 0, 1, imin);
848 TEST_INT (
"-32769", -1, -1, -1, 0,
_ef, 6, 0, 1, imin);
849 TEST_INT (
"-99999", -1, -1, -1, 0,
_ef, 6, 0, 1, imin);
851 TEST_INT (
"+32767", -1, -1, -1, 0,
_e_, 6, 0, 1, imax);
852 TEST_INT (
"+32768", -1, -1, -1, 0,
_ef, 6, 0, 1, imax);
853 TEST_INT (
"+99999", -1, -1, -1, 0,
_ef, 6, 0, 1, imax);
854#elif 4 == _RWSTD_INT_SIZE
855 const int imax = +2147483647;
856 const int imin = -imax - 1;
858 TEST_INT (
"-2147483648", -1, -1, -1, 0,
_e_, 11, 0, -1, imin);
859 TEST_INT (
"-2147483649", -1, -1, -1, 0,
_ef, 11, 0, -1, imin);
860 TEST_INT (
"-9999999999", -1, -1, -1, 0,
_ef, 11, 0, -1, imin);
862 TEST_INT (
"+2147483647", -1, -1, -1, 0,
_e_, 11, 0, -1, imax);
863 TEST_INT (
"+2147483648", -1, -1, -1, 0,
_ef, 11, 0, -1, imax);
864 TEST_INT (
"99999999999", -1, -1, -1, 0,
_ef, 11, 0, -1, imax);
865#elif 8 == _RWSTD_INT_SIZE
866 const int imax = +9223372036854775807;
867 const int imin = -imax - 1;
869 TEST_INT (
"-9223372036854775808", -1, -1, -1, 0,
_e_, 20, 0, -1, imin);
870 TEST_INT (
"-9223372036854775809", -1, -1, -1, 0,
_ef, 20, 0, -1, imin);
871 TEST_INT (
"-9999999999999999999", -1, -1, -1, 0,
_ef, 20, 0, -1, imin);
873 TEST_INT (
"+9223372036854775807", -1, -1, -1, 0,
_e_, 20, 0, -1, imax);
874 TEST_INT (
"+9223372036854775808", -1, -1, -1, 0,
_ef, 20, 0, -1, imax);
875 TEST_INT (
"99999999999999999999", -1, -1, -1, 0,
_ef, 20, 0, -1, imax);
882template <
class CharT,
class Traits>
888 info (cname, tname,
"unsigned int");
891 cname, tname,
"unsigned int",
"%u");
893#define TEST_UINT(ss, fl, is, ex, ee, es, ne, fw, iv, ev) \
894 TEST (int, "%u", ss, fl, is, ex, ee, es, ne, fw, iv, ev)
896 LocaleData locale_data = { 0, -1, -1, 0, 0, 0 };
899#if 2 == _RWSTD_UINT_SIZE
900 const unsigned uimax = 65535U;
902 TEST_INT (
"65535", -1, -1, -1, 0,
_e_, 5, 0, 1, uimax);
903 TEST_INT (
"65536", -1, -1, -1, 0,
_ef, 5, 0, 1, uimax);
904 TEST_INT (
"99999", -1, -1, -1, 0,
_ef, 5, 0, 1, uimax);
905#elif 4 == _RWSTD_UINT_SIZE
906 const unsigned uimax = 4294967295U;
908 TEST_INT (
"4294967295", -1, -1, -1, 0,
_e_, 10, 0, -1, uimax);
909 TEST_INT (
"4294967296", -1, -1, -1, 0,
_ef, 10, 0, -1, uimax);
910 TEST_INT (
"9999999999", -1, -1, -1, 0,
_ef, 10, 0, -1, uimax);
911#elif 8 == _RWSTD_UINT_SIZE
912 const unsigned uimax = 9223372036854775807U;
914 TEST_INT (
"9223372036854775807", -1, -1, -1, 0,
_e_, 10, 0, -1, uimax);
915 TEST_INT (
"9223372036854775808", -1, -1, -1, 0,
_ef, 10, 0, -1, uimax);
916 TEST_INT (
"9999999999999999999", -1, -1, -1, 0,
_ef, 10, 0, -1, uimax);
923template <
class CharT,
class Traits>
929 info (cname, tname,
"long");
932 cname, tname,
"long",
"%li");
934#define TEST_LONG(ss, fl, is, ex, ee, es, ne, fw, iv, ev) \
935 TEST (long, "%li", ss, fl, is, ex, ee, es, ne, fw, iv, ev)
937 LocaleData locale_data = { 0, -1, -1, 0, 0, 0 };
940#if 2 == _RWSTD_LONG_SIZE
941 const long lmax = +32767L;
942 const long lmin = -lmax - 1;
944 TEST_LONG (
"-32768", -1, -1, -1, 0,
_e_, 6, 0, 1, lmin);
945 TEST_LONG (
"-32769", -1, -1, -1, 0,
_ef, 6, 0, 1, lmin);
946 TEST_LONG (
"-99999", -1, -1, -1, 0,
_ef, 6, 0, 1, lmin);
948 TEST_LONG (
"+32767", -1, -1, -1, 0,
_e_, 6, 0, 1, lmax);
949 TEST_LONG (
"+32768", -1, -1, -1, 0,
_ef, 6, 0, 1, lmax);
950 TEST_LONG (
"+99999", -1, -1, -1, 0,
_ef, 6, 0, 1, lmax);
951#elif 4 == _RWSTD_LONG_SIZE
952 const long lmax = +2147483647L;
953 const long lmin = -lmax - 1;
955 TEST_LONG (
"-2147483648", -1, -1, -1, 0,
_e_, 11, 0, -1, lmin);
956 TEST_LONG (
"-2147483649", -1, -1, -1, 0,
_ef, 11, 0, -1, lmin);
957 TEST_LONG (
"-9999999999", -1, -1, -1, 0,
_ef, 11, 0, -1, lmin);
959 TEST_LONG (
"+2147483647", -1, -1, -1, 0,
_e_, 11, 0, -1, lmax);
960 TEST_LONG (
"+2147483648", -1, -1, -1, 0,
_ef, 11, 0, -1, lmax);
961 TEST_LONG (
"99999999999", -1, -1, -1, 0,
_ef, 11, 0, -1, lmax);
962#elif 8 == _RWSTD_LONG_SIZE
963 const long lmax = +9223372036854775807L;
964 const long lmin = -lmax - 1;
966 TEST_LONG (
"-9223372036854775808", -1, -1, -1, 0,
_e_, 20, 0, -1, lmin);
967 TEST_LONG (
"-9223372036854775809", -1, -1, -1, 0,
_ef, 20, 0, -1, lmin);
968 TEST_LONG (
"-9999999999999999999", -1, -1, -1, 0,
_ef, 20, 0, -1, lmin);
970 TEST_LONG (
"+9223372036854775807", -1, -1, -1, 0,
_e_, 20, 0, -1, lmax);
971 TEST_LONG (
"+9223372036854775808", -1, -1, -1, 0,
_ef, 20, 0, -1, lmax);
972 TEST_LONG (
"99999999999999999999", -1, -1, -1, 0,
_ef, 20, 0, -1, lmax);
979template <
class CharT,
class Traits>
985 info (cname, tname,
"unsigned long");
988 cname, tname,
"unsigned long",
"%lu");
990#define TEST_ULONG(ss, fl, is, ex, ee, es, ne, fw, iv, ev) \
991 TEST (unsigned long, "%lu", ss, fl, is, ex, ee, es, ne, fw, iv, ev)
993 LocaleData locale_data = { 0, -1, -1, 0, 0, 0 };
996#if 2 == _RWSTD_ULONG_SIZE
997 const unsigned ulmax = 65535UL;
1002#elif 4 == _RWSTD_ULONG_SIZE
1003 const unsigned ulmax = 4294967295UL;
1005 TEST_ULONG (
"4294967295", -1, -1, -1, 0,
_e_, 10, 0, -1, ulmax);
1006 TEST_ULONG (
"4294967296", -1, -1, -1, 0,
_ef, 10, 0, -1, ulmax);
1007 TEST_ULONG (
"9999999999", -1, -1, -1, 0,
_ef, 10, 0, -1, ulmax);
1008#elif 8 == _RWSTD_ULONG_SIZE
1009 const unsigned ulmax = 9223372036854775807UL;
1011 TEST_ULONG (
"9223372036854775807", -1, -1, -1, 0,
_e_, 10, 0, -1, ulmax);
1012 TEST_ULONG (
"9223372036854775808", -1, -1, -1, 0,
_ef, 10, 0, -1, ulmax);
1013 TEST_ULONG (
"9999999999999999999", -1, -1, -1, 0,
_ef, 10, 0, -1, ulmax);
1020template <
class CharT,
class Traits>
1026 info (cname, tname,
"long long");
1029 cname, tname,
"long long",
"%lli");
1031#define TEST_LLONG(ss, fl, is, ex, ee, es, ne, fw, iv, ev) \
1032 TEST (long long, "%lli", ss, fl, is, ex, ee, es, ne, fw, iv, ev)
1034 LocaleData locale_data = { 0, -1, -1, 0, 0, 0 };
1037#if 2 == _RWSTD_LLONG_SIZE
1038 const long long llmax = +32767LL;
1039 const long long llmin = -llmax - 1;
1048#elif 4 == _RWSTD_LLONG_SIZE
1049 const long long llmax = +2147483647LL;
1050 const long long llmin = -llmax - 1;
1052 TEST_LLONG (
"-2147483648", -1, -1, -1, 0,
_e_, 11, 0, -1, llmin);
1053 TEST_LLONG (
"-2147483649", -1, -1, -1, 0,
_ef, 11, 0, -1, llmin);
1054 TEST_LLONG (
"-9999999999", -1, -1, -1, 0,
_ef, 11, 0, -1, llmin);
1056 TEST_LLONG (
"+2147483647", -1, -1, -1, 0,
_e_, 11, 0, -1, llmax);
1057 TEST_LLONG (
"+2147483648", -1, -1, -1, 0,
_ef, 11, 0, -1, llmax);
1058 TEST_LLONG (
"99999999999", -1, -1, -1, 0,
_ef, 11, 0, -1, llmax);
1059#elif 8 == _RWSTD_LLONG_SIZE
1060 const long long llmax = +9223372036854775807LL;
1061 const long long llmin = -llmax - 1;
1063 TEST_LLONG (
"-9223372036854775808", -1, -1, -1, 0,
_e_, 20, 0, -1, llmin);
1064 TEST_LLONG (
"-9223372036854775809", -1, -1, -1, 0,
_ef, 20, 0, -1, llmin);
1065 TEST_LLONG (
"-9999999999999999999", -1, -1, -1, 0,
_ef, 20, 0, -1, llmin);
1067 TEST_LLONG (
"+9223372036854775807", -1, -1, -1, 0,
_e_, 20, 0, -1, llmax);
1068 TEST_LLONG (
"+9223372036854775808", -1, -1, -1, 0,
_ef, 20, 0, -1, llmax);
1069 TEST_LLONG (
"99999999999999999999", -1, -1, -1, 0,
_ef, 20, 0, -1, llmax);
1076template <
class CharT,
class Traits>
1082 info (cname, tname,
"unsigned long long");
1085 cname, tname,
"unsigned long long",
"%llu");
1087#define TEST_ULLONG(ss, fl, is, ex, ee, es, ne, fw, iv, ev) \
1088 TEST (unsigned long long, "%llu", ss, fl, is, ex, ee, es, ne, fw, iv, ev)
1090 LocaleData locale_data = { 0, -1, -1, 0, 0, 0 };
1093#if 2 == _RWSTD_ULLONG_SIZE
1094 const unsigned long long ullmax = 65535ULL;
1099#elif 4 == _RWSTD_ULLONG_SIZE
1100 const unsigned long long ullmax = 4294967295ULL;
1102 TEST_ULLONG (
"4294967295", -1, -1, -1, 0,
_e_, 10, 0, -1, ullmax);
1103 TEST_ULLONG (
"4294967296", -1, -1, -1, 0,
_ef, 10, 0, -1, ullmax);
1104 TEST_ULLONG (
"9999999999", -1, -1, -1, 0,
_ef, 10, 0, -1, ullmax);
1105#elif 8 == _RWSTD_ULLONG_SIZE
1106 const unsigned long long ullmax = 9223372036854775807ULL;
1108 TEST_ULLONG (
"9223372036854775807", -1, -1, -1, 0,
_e_, 10, 0, -1, ullmax);
1109 TEST_ULLONG (
"9223372036854775808", -1, -1, -1, 0,
_ef, 10, 0, -1, ullmax);
1110 TEST_ULLONG (
"9999999999999999999", -1, -1, -1, 0,
_ef, 10, 0, -1, ullmax);
1117template <
class CharT,
class Traits,
class FloatingType>
1125 typedef FloatingType
T;
1128 cname, tname, fname, fmt);
1130#define TEST_FLOATING(ss, fl, is, ex, ee, es, ne, fw, iv, ev) \
1131 TEST (T, fmt, ss, fl, is, ex, ee, es, ne, fw, T (iv), T (ev))
1133 LocaleData locale_data = { 0, -1, -1, 0, 0, 0 };
1141template <
class CharT,
class Traits>
1147 const char fmt[] =
"%g";
1148 const char fname[] =
"float";
1150 info (cname, tname, fname);
1153 cname, tname, fname, fmt);
1155#define TEST_FLT(ss, fl, is, ex, ee, es, ne, fw, iv, ev) \
1156 TEST (float, fmt, ss, fl, is, ex, ee, es, ne, fw, iv, ev)
1158 LocaleData locale_data = { 0, -1, -1, 0, 0, 0 };
1161 TEST_FLT (
"", -1, -1, -1, 0,
_ef, 0, 0, 1.0f, 1.0f);
1164 "%{$CLASS}::operator>>(%s&) insufficiently exercised", fname);
1169template <
class CharT,
class Traits>
1175 const char fmt[] =
"%g";
1176 const char fname[] =
"double";
1178 info (cname, tname, fname);
1181 cname, tname, fname, fmt);
1183#define TEST_DBL(ss, fl, is, ex, ee, es, ne, fw, iv, ev) \
1184 TEST (double, fmt, ss, fl, is, ex, ee, es, ne, fw, iv, ev)
1186 LocaleData locale_data = { 0, -1, -1, 0, 0, 0 };
1189 TEST_DBL (
"", -1, -1, -1, 0,
_ef, 0, 0, 1.0, 1.0);
1192 "%{$CLASS}::operator>>(%s&) insufficiently exercised", fname);
1197template <
class CharT,
class Traits>
1203 const char fmt[] =
"%Lg";
1204 const char fname[] =
"long double";
1206 info (cname, tname, fname);
1209 cname, tname, fname, fmt);
1211#define TEST_LDBL(ss, fl, is, ex, ee, es, ne, fw, iv, ev) \
1212 TEST (long double, fmt, ss, fl, is, ex, ee, es, ne, fw, iv, ev)
1214 LocaleData locale_data = { 0, -1, -1, 0, 0, 0 };
1220 "%{$CLASS}::operator>>(%s&) insufficiently exercised", fname);
1239template <
class CharT,
class Traits>
1250 if (rw_note (0 == opt_ ## T, 0, __LINE__, "%s tests disabled", #T)) \
1251 test_ ## T ((CharT*)0, (Traits*)0, cname, tname)
1306static int opt_char_traits;
1307static int opt_user_traits;
1314#define TEST(CharT, Traits) \
1315 test_extractor ((CharT*)0, (Traits*)0, #CharT, #Traits)
1317 if (
rw_note (0 <= opt_char && 0 <= opt_char_traits, 0, __LINE__,
1318 "basic_istream<char, char_traits<char>>::operator>>() "
1320 TEST (
char, std::char_traits<char>);
1322 if (
rw_note (0 <= opt_char && 0 <= opt_user_traits, 0, __LINE__,
1323 "basic_istream<char, UserTraits<char>>::operator>>() "
1327#ifndef _RWSTD_NO_WCHAR_T
1329 if (
rw_note (0 <= opt_wchar && 0 <= opt_char_traits, 0, __LINE__,
1330 "basic_istream<wchar_t, char_traits<wchar_t>>::operator>>() "
1332 TEST (
wchar_t, std::char_traits<wchar_t>);
1334 if (
rw_note (0 <= opt_wchar && 0 <= opt_user_traits, 0, __LINE__,
1335 "basic_istream<wchar_t, UserTraits<wchar_t>>::operator>>() "
1348 return rw_test (argc, argv, __FILE__,
1349 "istream.formatted.arithmetic",
1358 "|-unsigned-short~ "
1364 "|-unsigned-long-long~ "
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
std::char_traits< S > Traits
void test_ulong(CharT *, Traits *, const char *cname, const char *tname)
#define TEST_LLONG(ss, fl, is, ex, ee, es, ne, fw, iv, ev)
#define TEST_SHRT(ss, fl, is, ex, ee, es, ne, fw, iv, ev)
void test_ullong(CharT *, Traits *, const char *cname, const char *tname)
#define TEST_ULONG(ss, fl, is, ex, ee, es, ne, fw, iv, ev)
void test_ushrt(CharT *, Traits *, const char *cname, const char *tname)
void test_floating(CharT *, Traits *, FloatingType *, const char *cname, const char *tname, const char *fname, const char *fmt)
void test_shrt(CharT *, Traits *, const char *cname, const char *tname)
void test_extractor(CharT *, Traits *, ArithmeticType *, const char *cname, const char *tname, const char *aname, int line, const char *valfmt, const char *cbuf, std::size_t cbuf_size, const LocaleData &locale_data, int flags, int init_state, int exceptions, int expect_exception, int expect_state, int expect_extract, int fail_when, ArithmeticType init_value, ArithmeticType expect_value)
void test_uint(CharT *, Traits *, const char *cname, const char *tname)
void test_dbl(CharT *, Traits *, const char *cname, const char *tname)
#define TEST_DBL(ss, fl, is, ex, ee, es, ne, fw, iv, ev)
void test_long(CharT *, Traits *, const char *cname, const char *tname)
#define TEST(str, fl, is, ex, ee, es, ne, fw, iv, ev)
#define TEST_INT(ss, fl, is, ex, ee, es, ne, fw, iv, ev)
#define TEST_LDBL(ss, fl, is, ex, ee, es, ne, fw, iv, ev)
#define TEST_ULLONG(ss, fl, is, ex, ee, es, ne, fw, iv, ev)
#define TEST_BOOL(ss, fl, is, ex, ee, es, ne, fw, iv, ev)
void test_flt(CharT *, Traits *, const char *cname, const char *tname)
#define TEST_FLT(ss, fl, is, ex, ee, es, ne, fw, iv, ev)
void test_llong(CharT *, Traits *, const char *cname, const char *tname)
void test_ldbl(CharT *, Traits *, const char *cname, const char *tname)
#define TEST_LONG(ss, fl, is, ex, ee, es, ne, fw, iv, ev)
#define TEST_FLOATING(ss, fl, is, ex, ee, es, ne, fw, iv, ev)
const std::locale make_locale(const CharT *, const LocaleData &data)
void test_int(CharT *, Traits *, const char *cname, const char *tname)
void test_bool(CharT *, Traits *, const char *cname, const char *tname)
#define _RWSTD_UNUSED(arg)
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_note(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 *,...)
_TEST_EXPORT int rw_fprintf(rw_file *, const char *,...)