/*! \file simplearraytest.cc * \brief test simple array class (implementation) * * ---------------------------------------------------------------------------- * * $Id: simplearraytest.cc,v 1.2 2002-12-13 23:48:30 forbrig Exp $ * \author Thomas Forbriger * \date 25/05/2002 * * test simple array class (implementation) * * Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) * * REVISIONS and CHANGES * - 25/05/2002 V1.0 Thomas Forbriger * - 24/11/2002 V1.1 add rawarfun tests * - 25/11/2002 V1.2 new inline tests * - 13/12/2002 V1.3 reworked for libaff * * ============================================================================ */ #define AFF_SIMPLEARRAYTEST_CC_VERSION \ "AFF_SIMPLEARRAYTEST_CC V1.3" #define AFF_SIMPLEARRAYTEST_CC_CVSID \ "$Id: simplearraytest.cc,v 1.2 2002-12-13 23:48:30 forbrig Exp $" /*! \example tests/simplearraytest.cc * * Tests for aff::SimpleRidigArray and aff::util::Inline. * * \sa tests/simplearraytest.cc * \sa aff::SimpleRidigArray * \sa aff::util::Inline */ #include #include #include using std::cout; using std::endl; using namespace aff; //! Print code and execute #define CODE( code ) cout << #code << endl; code //! return string for bool value const char* boolchar(const bool& v) { char *s; if (v) { s="true"; } else { s="false"; } return(s); } //! Test for the SimpleRigidArray module and associated functions int main() { cout << AFF_SIMPLEARRAYTEST_CC_VERSION << endl; cout << AFF_SIMPLEARRAYTEST_CC_CVSID << endl << endl;; // test for basic functionality of SimpleRigidArray { cout << "Test SimpleRigidArray" << endl << "=====================" << endl << endl; SimpleRigidArray A,B(8.); SimpleRigidArray C,D(100); cout << "SimpleRigidArray A,B(8.);" << endl; cout << "SimpleRigidArray C,D(100);" << endl; DUMP( A ); DUMP( B ); DUMP( C ); DUMP( D ); CODE( A=B; ) CODE( C=D; ) CODE( B[3]=78.; ) CODE( D[2]=7883; ) DUMP( A ); DUMP( B ); DUMP( C ); DUMP( D ); CODE( D=777; ) DUMP( D ); const SimpleRigidArray E(C); DUMP( E ); #ifdef ILLEGAL1 E[4]=334; #endif } cout << endl; { cout << "Test raw array functions" << endl << "========================" << endl << endl; SimpleRigidArray A; CODE( A[0]=2; ) CODE( A[1]=3; ) CODE( A[2]=4; ) CODE( A[3]=5; ) DUMP(A); cout << endl << "----" << endl << endl; cout << "sum A: " << inline_sum(A) << endl; cout << "product A: " << inline_product(A) << endl; /* { CODE( (SimpleRigidArray B(1)); ) DUMP(B); CODE( (inline_set(B, 16)); ) DUMP(B) CODE(( inline_copy(A, B)) ); DUMP(B); } { SimpleRigidArray B(A); DUMP(B); cout << "anysmaller AB: " << boolchar(inline_anylarger(A, B)); cout << endl; B[2]++; DUMP(B); cout << "anysmaller AB: " << boolchar(inline_anylarger(A, B)); cout << endl; B[1]--; DUMP(B); cout << "anysmaller AB: " << boolchar(inline_anylarger(A, B)); cout << endl; B[2]--; DUMP(B); cout << "anysmaller AB: " << boolchar(inline_anylarger(A, B)); cout << endl; } */ } } /* ----- END OF simplearraytest.cc ----- */