Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
27.basic_ios.copyfmt.stdcxx-1058.cpp
Go to the documentation of this file.
1
28/*
29 * This program should run to completion and exit with return status 0
30 */
31
32#include <ios>
33#include <stdio.h>
34#include <stdlib.h>
35
36#define TEST_ASSERT(expr) \
37 (expr) ? ret = 0 \
38 : fprintf(stderr,"file %s line %i: Assertion failed: %s\n", \
39 __FILE__, __LINE__, #expr); fflush(stderr); if (ret != 0) abort()
40
41int x;
42
43void testfun (std::ios_base::event ev, std::ios_base& iosobj, int index)
44{
45 x = index;
46
47 switch (ev)
48 {
49 case std::ios_base::copyfmt_event:
50 (void) fprintf(stderr, "copyfmt_event\n"); break;
51 case std::ios_base::imbue_event:
52 (void) fprintf(stderr, "imbue_event\n"); break;
53 case std::ios_base::erase_event:
54 (void) fprintf(stderr, "erase_event\n"); break;
55 default:
56 (void) fprintf(stderr, "unknown (this should never happen)\n"); break;
57 }
58}
59
60
61int main ()
62{
63 struct A: std::streambuf { };
64
65 struct B: std::ios {
66 A sb;
67 B () { init (&sb); }
68 } f0, f1;
69
70 int i = 101;
71 int ret = 1;
72
73 std::ios_base::event_callback e1 = &testfun;
74 f0.register_callback (e1, i);
75
76 x = 0;
77 f0.imbue (f0.getloc());
78 TEST_ASSERT (x == i);
79
80 x = 0;
81 ret = 1;
82 f0.copyfmt (f1);
83 TEST_ASSERT (x == i);
84
85 B s0, s1;
86
87 s0.register_callback (e1, i);
88
89 x = 0;
90 ret = 1;
91 s0.imbue (f0.getloc ());
92 TEST_ASSERT (x == i);
93
94 x = 0;
95 ret = 1;
96 s0.copyfmt (s1);
97 TEST_ASSERT (x == i);
98
99 return ret;
100}
101
#define i
Definition 17.names.cpp:126
#define s1
Definition 17.names.cpp:242
#define B
Definition 17.names.cpp:145
#define f1
Definition 17.names.cpp:230
#define e1
Definition 17.names.cpp:229
#define sb
Definition 17.names.cpp:542
#define index
Definition 17.names.cpp:482
void testfun(std::ios_base::event ev, std::ios_base &iosobj, int index)
#define TEST_ASSERT(expr)
@ s0
Definition HONOR_STD.cpp:38
#define stderr
std::mbstate_t init
Definition codecvt1.cpp:80