AFF --- A container for numbers (array) by Friederich and Forbriger.
reprtest.cc
Go to the documentation of this file.
1 
44 #define AFF_REPRTEST_CC_VERSION \
45  "AFF_REPRTEST_CC V1.3"
46 
47 #include <aff/lib/sharedheap.h>
48 #include <aff/dump.h>
49 
50 using std::cout;
51 using std::endl;
52 
67 void section(const char* s)
69 {
70  cout << endl
71  << s << endl;
72  const char* p=s;
73  while (*p) {
74  cout << "-";
75  ++p;
76  }
77  cout << endl;
78 }
79 
81 int main()
82 {
83  cout << AFF_REPRTEST_CC_VERSION << endl;
84 
85  section("array dimensions");
86  CODE( const int N=10; )
87  CODE( const int N2=23; )
88 
89  section("instantiate arrays");
90  CODE( aff::SharedHeap<int> A(N); )
91  CODE( aff::SharedHeap<int> B(N2); )
92 #ifdef SENSELESS
93 #warning intentionally compiling senseless code
94  CODE( aff::ConstSharedHeap<int> Cuseless(N2); )
95 #endif
98 
99  section("create a const reference to D");
101 
102  section("const int array should share memory with int array");
103  CODE( C=B; )
104 
105  section("fill arrays");
106  CODE( for (int i=0; i<N; i++) { A[i]=(i+1)*10; } )
107  CODE( for (int i=0; i<N2; i++) { B[i]=(i+4)*3; } )
108  CODE( for (int i=0; i<N2; i++) { D[i]=(i+2.45)*2; } )
109 
110  section("dump contents - C is filled through B and E is filled through D");
112  DUMP( B );
113  DUMP( C );
114  DUMP( E );
115 
116  section("modify C through B");
117  CODE( B[8]=632; )
118  DUMP( C );
119 
120 #ifdef ILLEGAL1
121  // you may activate this section by passing -DILLEGAL1 to the compiler
122  section("modify C directly - is illegal");
123  C[9]=354;
124  DUMP( C );
125 #endif
126 
127  section("make B a reference to A");
128  CODE( B=A; )
129  section("modification should be visible through B");
130  CODE( A[5]=453; )
131  DUMP( B );
132  section("but C holds the original values");
133  DUMP( C );
134 }
135 
136 /* ----- END OF reprtest.cc ----- */
int main()
testing SharedHeap
Definition: reprtest.cc:81
#define DUMP(A)
Dump any object through its dump function.
Definition: dump_macros.h:62
A template class to share heap memory for different array projections.
Definition: sharedheap.h:252
#define CODE(C)
Dump code and execute (works like echo)
Definition: dump_macros.h:82
void section(const char *s)
print headline
Definition: reprtest.cc:68
shared heap representation (prototypes)
#define AFF_REPRTEST_CC_VERSION
Definition: reprtest.cc:44
This is the base class for const elements.
Definition: sharedheap.h:139
debug helpers (prototypes)