AFF --- A container for numbers (array) by Friederich and Forbriger.
tests/reprtest.cc

Test representation class aff::SharedHeap.

This test program gives an example of the usage of the following classes and preprocessor macros:

See also
tests/reprtest.cc
#define AFF_REPRTEST_CC_VERSION \
"AFF_REPRTEST_CC V1.3"
#include <aff/dump.h>
using std::cout;
using std::endl;
void section(const char* s)
{
cout << endl
<< s << endl;
const char* p=s;
while (*p) {
cout << "-";
++p;
}
cout << endl;
}
int main()
{
cout << AFF_REPRTEST_CC_VERSION << endl;
section("array dimensions");
CODE( const int N=10; )
CODE( const int N2=23; )
section("instantiate arrays");
#ifdef SENSELESS
#warning intentionally compiling senseless code
#endif
section("create a const reference to D");
section("const int array should share memory with int array");
CODE( C=B; )
section("fill arrays");
CODE( for (int i=0; i<N; i++) { A[i]=(i+1)*10; } )
CODE( for (int i=0; i<N2; i++) { B[i]=(i+4)*3; } )
CODE( for (int i=0; i<N2; i++) { D[i]=(i+2.45)*2; } )
section("dump contents - C is filled through B and E is filled through D");
DUMP( B );
DUMP( C );
DUMP( E );
section("modify C through B");
CODE( B[8]=632; )
DUMP( C );
#ifdef ILLEGAL1
// you may activate this section by passing -DILLEGAL1 to the compiler
section("modify C directly - is illegal");
C[9]=354;
DUMP( C );
#endif
section("make B a reference to A");
CODE( B=A; )
section("modification should be visible through B");
CODE( A[5]=453; )
DUMP( B );
section("but C holds the original values");
DUMP( C );
}
/* ----- END OF reprtest.cc ----- */