Test helper classes.
This test program gives an example of the usage of the following classes, functions, and preprocessor macros:
#define AFF_HELPERTEST_CC_VERSION \
"AFF_HELPERTEST_CC V1.4"
using std::cout;
using std::endl;
void section(
const char* s,
const char l=
'-')
{
cout << endl << s << endl;
const char* p=s;
while (*p) { cout << l; ++p; }
cout << endl;
}
template<class T>
{
cout << endl;
cout << "Received array in function:" << endl;
}
{
section(
"Tests for class Iterator",
'=');
{
{ *I=i; i++; });
{ cout << i << ", " << *I << endl; i++; });
}
section(
"Tests for class Subarray",
'=');
{
section(
"First mode: Use a Subarray object just for initialization",
'.');
}
section(
"Tests of subarray function",
'-');
{
section(
"First mode: Use a Subarray object just for initialization",
'.');
section(
"Second mode: Create a Subarray object to which you can assign",
'.');
}
section(
"Test for subarray of ConstArray",
'-');
{
}
section(
"Tests for class Slice",
'=');
{
section(
"First mode: Use a Slice object just for initialization",
'.');
}
section(
"Test slice function",
'-');
{
section(
"First mode: Use a Slice object just for initialization",
'.');
section(
"Second mode: Create a Slice object to which you can assign",
'.');
}
section(
"Test slice of ConstArray",
'-');
{
}
{
{ *I=i; i++; });
}
{
{ *I=i; i++; });
}
section(
"Extract copy of subarray");
{
}
section(
"Test external access interfaces",
'=');
section(
"Test interface to raw memory array: aff::CArray");
{
for(int i=A.f(0); i<=A.l(0); i++)
{
for(int j=A.f(1); j<=A.l(1); j++)
{
for(int k=A.f(2); k<=A.l(2); k++)
{
for(int l=A.f(3); l<=A.l(3); l++)
{
A(i,j,k,l)=(i-A.f(0)+1)+(j-A.f(1)+1)*10
+(k-A.f(2)+1)*100+(l-A.f(3)+1)*1000;
}
}
}
}
CODE(
int* p=C.pointer(); )
for (unsigned i=0; i<C.size(0); ++i)
{
for (unsigned j=0; j<C.size(1); ++j)
{
p[i*C.stride(0)+j*C.stride(1)]=i+10*j;
}
}
)
}
section(
"Test interface to raw memory array: aff::CSeries");
{
CODE(
for (
int i=A.f(); i<=A.l(); ++i) { A(i)=i; })
CODE(
int* p=CS.pointer(); )
CODE(
for (
int i=0; i<CS.size(); ++i) { p[i]=i; })
}
section(
"Test conversion from Array to Series");
{
for(int i=A.f(0); i<=A.l(0); i++)
{
for(int j=A.f(1); j<=A.l(1); j++)
{
for(int k=A.f(2); k<=A.l(2); k++)
{
for(int l=A.f(3); l<=A.l(3); l++)
{
A(i,j,k,l)=(i-A.f(0)+1)+(j-A.f(1)+1)*10
+(k-A.f(2)+1)*100+(l-A.f(3)+1)*1000;
}
}
}
}
}
}