31#if !defined _MSC_VER || _MSC_VER > 1310
39# define _RWSTD_NO_REDUNDANT_DEFINITIONS
46# define _RWSTD_NO_TEMPLATE_DEFINITIONS
67template <
typename T >
79type_name< std::char_traits<char> > ()
81 return "std::char_traits<char>";
86type_name< CharTraits<char> > ()
88 return "CharTraits<char>";
91#ifndef _RWSTD_NO_WCHAR_T
102type_name< std::char_traits<wchar_t> > ()
104 return "std::char_traits<wchar_t>";
109type_name< CharTraits<wchar_t> > ()
111 return "CharTraits<wchar_t>";
128template <
class charT,
class Traits>
129struct StreamBuf: std::basic_streambuf<charT, Traits> { };
132template <
class charT,
class Traits>
136 static const char*
const cname = type_name< charT > ();
137 static const char*
const tname = type_name< Traits > ();
139 typedef std::ios_base::fmtflags Fmtflags;
140 typedef std::basic_istream<charT, Traits> Istream;
141 typedef std::basic_ostream<charT, Traits> Ostream;
142 typedef std::basic_iostream<charT, Traits> IOstream;
149 IOstream inout1 (&
sb);
154 IOstream inout2 (&
sb);
162 Istream &in3 = in1 >> std::resetiosflags (Fmtflags (iarg));
163 in2.setf (Fmtflags (0), Fmtflags (iarg));
165 if (in2.flags () != in3.flags ()) {
168 "in >> std::resetiosflags(%{If}) with basic_istream "
169 "<%s, %s >", iarg, cname, tname);
172 Ostream &out3 = out1 << std::resetiosflags (Fmtflags (iarg));
173 out2.setf (Fmtflags (0), Fmtflags (iarg));
175 if (out2.flags () != out3.flags ()) {
178 "out << std::resetiosflags(%{If}) with basic_ostream "
179 "<%s, %s >", iarg, cname, tname);
182 Ostream &inout3 = inout1 << std::resetiosflags (Fmtflags (iarg));
183 inout2.setf (Fmtflags (0), Fmtflags (iarg));
185 if (inout2.flags () != inout3.flags ()) {
188 "io << std::resetiosflags(%{If}) with basic_iostream "
189 "<%s, %s >", iarg, cname, tname);
197 Istream &in3 = in1 >> std::setiosflags (Fmtflags (iarg));
198 in2.setf (Fmtflags (iarg));
200 if (in2.flags () != in3.flags ()) {
203 "std::setiosflags (%s) with basic_istream "
204 "<%s, %s >", iarg, cname, tname);
207 Ostream &out3 = out1 << std::setiosflags (Fmtflags (iarg));
208 out2.setf (Fmtflags (iarg));
210 if (out2.flags () != out3.flags ()) {
213 "std::setiosflags (%s) with basic_ostream "
214 "<%s, %s >", iarg, cname, tname);
217 Ostream &inout3 = inout1 << std::setiosflags (Fmtflags (iarg));
218 inout2.setf (Fmtflags (iarg));
220 if (inout2.flags () != inout3.flags ()) {
223 "std::setiosflags (%s) with basic_iostream "
224 "<%s, %s >", iarg, cname, tname);
232 out1 << std::setbase (iarg);
234 if (0 == iarg || 2 == iarg || 8 == iarg || 10 ==iarg || 16 == iarg) {
235 out2.setf ( 8 == iarg ? std::ios_base::oct
236#ifndef _RWSTD_NO_EXT_BIN_IO
237 : 2 == iarg ?
std::ios_base::
bin
239 : 10 == iarg ?
std::ios_base::
dec
240 : 16 == iarg ?
std::ios_base::
hex
244 if (out1.flags () != out2.flags ()) {
247 "std::setbase (%d)", iarg);
251 std::basic_ostringstream<charT, std::char_traits<charT> >
ostrm;
253 static const struct {
256 { {
'1',
'2',
'3',
'4',
'\0' } },
257 { {
'm',
'c',
'c',
'x',
'x',
'x',
'i',
'v',
'\0' } },
258 { {
'1',
'0',
'0',
'1',
'1',
'0',
'1',
'0',
'0',
'1',
'0',
'\0' } },
259 { {
'1',
'2',
'0',
'0',
'2',
'0',
'1',
'\0' } },
260 { {
'1',
'0',
'3',
'1',
'0',
'2',
'\0' } },
261 { {
'1',
'4',
'4',
'1',
'4',
'\0' } },
262 { {
'5',
'4',
'1',
'4',
'\0' } },
263 { {
'3',
'4',
'1',
'2',
'\0' } },
264 { {
'2',
'3',
'2',
'2',
'\0' } },
265 { {
'1',
'6',
'2',
'1',
'\0' } },
266 { {
'1',
'2',
'3',
'4',
'\0' } },
267 { {
'a',
'2',
'2',
'\0' } },
268 { {
'8',
'6',
'a',
'\0' } },
269 { {
'7',
'3',
'c',
'\0' } },
270 { {
'6',
'4',
'2',
'\0' } },
271 { {
'5',
'7',
'4',
'\0' } },
272 { {
'4',
'd',
'2',
'\0' } },
273 { {
'4',
'4',
'a',
'\0' } },
274 { {
'3',
'e',
'a',
'\0' } },
275 { {
'3',
'7',
'i',
'\0' } },
276 { {
'3',
'1',
'e',
'\0' } },
277 { {
'2',
'g',
'g',
'\0' } },
278 { {
'2',
'c',
'2',
'\0' } },
279 { {
'2',
'7',
'f',
'\0' } },
280 { {
'2',
'3',
'a',
'\0' } },
281 { {
'1',
'o',
'9',
'\0' } },
282 { {
'1',
'l',
'c',
'\0' } },
283 { {
'1',
'i',
'j',
'\0' } },
284 { {
'1',
'g',
'2',
'\0' } },
285 { {
'1',
'd',
'g',
'\0' } },
286 { {
'1',
'b',
'4',
'\0' } },
287 { {
'1',
'8',
'p',
'\0' } },
288 { {
'1',
'6',
'i',
'\0' } },
289 { {
'1',
'4',
'd',
'\0' } },
290 { {
'1',
'2',
'a',
'\0' } },
291 { {
'1',
'0',
'9',
'\0' } },
292 { {
'y',
'a',
'\0' } }
295 ostrm << std::setbase (iarg);
298 const int inx = iarg >= 0 && iarg <= 36 ? iarg : 0;
303 "std::setbase (%d) inserted 1234 as \"%s\"; "
304 "expected \"%s\"", iarg,
312 Istream &in3 = in1 >> std::setfill (carg);
315 if (in2.fill () != in3.fill ()) {
318 "in >> std::setfill('%c') with basic_istream"
319 "<%s, %s >", carg, cname, tname);
322 Ostream &out3 = out1 << std::setfill (carg);
325 if (out2.fill () != out3.fill ()) {
328 "out << std::setfill('%c') with basic_ostream"
329 "<%s, %s >", carg, cname, tname);
332 Ostream &inout3 = inout1 << std::setfill (carg);
335 if (inout2.fill () != inout3.fill ()) {
338 "io << std::setfill('%c') with basic_iostream"
339 "<%s, %s >", carg, cname, tname);
347 Istream &in3 = in1 >> std::setprecision (iarg);
348 in2.precision (std::streamsize (iarg));
350 if (in2.precision () != in3.precision ()) {
353 "std::setprecision (%d) with basic_istream "
354 "<%s, %s >", iarg, cname, tname);
357 Ostream &out3 = out1 << std::setprecision (iarg);
358 out2.precision (std::streamsize (iarg));
360 if (out2.precision () != out3.precision ()) {
363 "std::setprecision (%d) with basic_ostream "
364 "<%s, %s >", iarg, cname, tname);
367 Ostream &inout3 = inout1 << std::setprecision (iarg);
368 inout2.precision (std::streamsize (iarg));
370 if (inout2.precision () != inout3.precision ()) {
373 "std::setprecision (%d) with basic_iostream "
374 "<%s, %s >", iarg, cname, tname);
382 Istream &in3 = in1 >> std::setw (iarg);
383 in2.width (std::streamsize (iarg));
385 if (in2.width () != in3.width ()) {
388 "std::setw (%d) with basic_istream<%s, %s >",
392 Ostream &out3 = out1 << std::setw (iarg);
393 out2.width (std::streamsize (iarg));
395 if (out2.width () != out3.width ()) {
398 "std::setw (%d) with basic_ostream<%s, %s >",
402 Ostream &inout3 = inout1 << std::setw (iarg);
403 inout2.width (std::streamsize (iarg));
405 if (inout2.width () != inout3.width ()) {
408 "std::setw (%d) with basic_iostream<%s, %s >",
423#define Boolalpha std::ios_base::boolalpha
424#define Dec std::ios_base::dec
425#define Fixed std::ios_base::fixed
426#define Hex std::ios_base::hex
427#define Internal std::ios_base::internal
428#define Left std::ios_base::left
429#define Oct std::ios_base::oct
430#define Right std::ios_base::right
431#define Scientific std::ios_base::scientific
432#define Showbase std::ios_base::showbase
433#define Showpoint std::ios_base::showpoint
434#define Showpos std::ios_base::showpos
435#define Skipws std::ios_base::skipws
436#define Unitbuf std::ios_base::unitbuf
437#define Uppercase std::ios_base::uppercase
438#define Bin std::ios_base::bin
439#define Adjustfield std::ios_base::adjustfield
440#define Basefield std::ios_base::basefield
441#define Floatfield std::ios_base::floatfield
442#define Nolock std::ios_base::nolock
443#define Nolockbuf std::ios_base::nolockbuf
446template <
class charT,
class Traits>
449#define TEST(M, V, C) \
450 ++ntried; nfailed += test< charT, Traits > (__LINE__, M, V, C)
458 const char*
const cname = type_name< charT > ();
459 const char*
const tname = type_name< Traits > ();
461 rw_info (0, __FILE__, __LINE__,
462 "27.6.3, p3 - std::resetiosflags(ios_base::"
463 "fmtflags) with basic_{i,o,io}stream<%s, %s >",
482#ifndef _RWSTD_NO_EXT_BIN_IO
492#ifndef _RWSTD_NO_EXT_REENTRANT_IO
516 "std::resetiosflags failed %d out "
517 "of %d assertions", nfailed, ntried);
522 rw_info (0, __FILE__, __LINE__,
523 "27.6.3, p4 - std::setiosflags(ios_base::"
524 "fmtflags) with basic_{i,o,io}stream<%s, %s >",
527 ntried = nfailed = 0;
545#ifndef _RWSTD_NO_EXT_BIN_IO
559 "std::setiosflags failed %d out "
560 "of %d assertions", nfailed, ntried);
565 rw_info (0, __FILE__, __LINE__,
566 "27.6.3, p5 - std::setbase(int) with "
567 "basic_{i,o,io}stream<%s, %s >", cname, tname);
569 ntried = nfailed = 0;
576#ifndef _RWSTD_NO_EXT_BIN_IO
582#ifndef _RWSTD_NO_EXT_SETBASE
607 "std::setbase failed %d out "
608 "of %d assertions", nfailed, ntried);
613 rw_info (0, __FILE__, __LINE__,
614 "27.6.3, p6 - std::setfill(%s) with "
615 "basic_{i,o,io}stream<%s, %s >", cname, cname, tname);
617 ntried = nfailed = 0;
631 "std::setfill failed %d out "
632 "of %d assertions", nfailed, ntried);
637 rw_info (0, __FILE__, __LINE__,
638 "27.6.3, p7 - std::setprecision(int) with "
639 "basic_{i,o,io}stream<%s, %s >", cname, tname);
641 ntried = nfailed = 0;
655 "std::setprecision failed %d out "
656 "of %d assertions", nfailed, ntried);
661 rw_info (0, __FILE__, __LINE__,
662 "27.6.3, p8 - std::setw(int) with "
663 "basic_{i,o,io}stream<%s, %s >", cname, tname);
665 ntried = nfailed = 0;
679 "std::setw failed %d out "
680 "of %d assertions", nfailed, ntried);
688 do_test<char, std::char_traits<char> > ();
689 do_test<char, CharTraits<char> > ();
691#ifndef _RWSTD_NO_WCHAR_T
693 do_test<wchar_t, std::char_traits<wchar_t> > ();
694 do_test<wchar_t, CharTraits<wchar_t> > ();
705 return rw_test (argc, argv, __FILE__,
707 "27.6.3 Standard manipulators",
void do_test(int line, const char *src, std::size_t resoff, ForwardIterator dummy_iter, const T *, const char *predname)
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
_RWSTD_SPECIALIZED_FUNCTION const char * type_name< wchar_t >()
_RWSTD_SPECIALIZED_FUNCTION const char * type_name< char >()
#define _RWSTD_SPECIALIZED_FUNCTION
_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 *,...)