// ----------------------------------------------------------------------------- // FlexArray main program and unit test -- typedef version main.cpp // A. Fischer and M. Fischer, September 2010 // Revised September 2018 // ----------------------------------------------------------------------------- // The base type of the array is controlled by a typedef. #include "tools.hpp" #include "flex.hpp" #include "item.hpp" void unitTest( void ); //------------------------------------------------------------------------------ int main( void ) { banner(); puts( "FlexArray Demonstration Program" ); unitTest(); bye(); return 0; } //------------------------------------------------------------------------------ void unitTest( void ) { cout << "Starting unit test for FlexArray" << endl; // Testing setup and print. cout << "Creating Flex object\n"; Flex f; // Primary data structure. cout <<"User should see array header and no data.\n"; cout << f << endl; // Testing add and print. cout << "Adding 5 items\n"; f.add( Item(6.00, "vollkornbrot") ); f.add( Item(3.00, "croissant") ); f.add( Item(2.50, "baguette") ); f.add( Item(3.00, "danish") ); f.add( Item(5.00, "anise bread" ) ); cout <<"User should see " << f.size() << " items, not sorted.\n"; cout <