Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
21.string.io.stdcxx-206.cpp
Go to the documentation of this file.
1
29#include <strstream>
30#include <string>
31#include <cassert>
32
33void test (const std::string& str, const std::streamsize width)
34{
35 enum { bufsize = 10 };
36 char buf[bufsize];
37 std::ostrstream os (buf, bufsize);
38
39 os.width (width);
40 os.exceptions (std::ios_base::failbit | std::ios_base::badbit);
41
42 try {
43 os << str;
44 }
45 catch (std::ios_base::failure&) {
46 }
47
48#ifndef _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE
49 assert (width == os.width ());
50#else
51 assert (0 == os.width ());
52#endif
53}
54
55int main ()
56{
57 std::string str ("abcdefghijk");
58
59 test (str, 2);
60 test (str, str.size () + 2);
61
62 return 0;
63}
#define os
Definition 17.names.cpp:511
#define buf
Definition 17.names.cpp:452
#define assert(expr)
Definition _cassert.h:40
const char * str
Definition exec.cpp:170