#include #include "ArrayUtils.h" #include #include #include using namespace std; const size_t MAX_SIZE = 10; const string TEST_ARRAY[] = { "Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel", "India", "Juliett"}; bool TestPrintArray(void); bool TestLoadArray(void); bool TestStoreArray(void); bool TestFindCommon(void); bool TestMerge(void); bool TestFindDiff(void); bool TestFind(void); bool TestSort(void); bool TestCopy(void); bool TestAppendToArray(void); bool TestDeleteFromArray(void); // this is about the only reason to have a global variable. bool GLOBAL_DEBUG = false; const string HOME_DIR = "/home/CS/dbennett/230/hw3B/data"; int main(int argc, char * argv[]) { int i=1; while (i < argc) { if (strcmp(argv[i], "-d") == 0) { GLOBAL_DEBUG = true; i++; } else { cout << "Unknown Arg " << argv[i] << endl; i++; } } TestPrintArray(); TestLoadArray(); TestStoreArray(); TestFindCommon(); TestMerge(); TestFindDiff(); TestFind(); TestSort(); TestCopy(); TestAppendToArray(); TestDeleteFromArray(); return 0; } bool cmp(string a, string b) { return a < b; } void MyPrintArray(const string ary[], size_t size) { size_t i; cout <<"{"; if (size > 0) { cout << ary[0] ; } for(i=1; i < size; i++) { cout << ", " << ary[i]; } cout << "} "; return; } bool CheckPrintResult(string result, const string ary[], size_t size) { size_t i, letterOffset; string outName; char endlChar; bool error = false; letterOffset = 0; for(i=0;i MAX_SIZE) { // check output error message if (buffer.str() != errorMsg) { cout << "\n\tBad Error Message, should be \n\t\"" << errorMsg <<"\"\n but is \n\t\""; cout << buffer.str(); cout << '"' << endl; success = false; } // check size. if (size != MAX_SIZE) { cout <<"\n\tBad Return size, should be " << MAX_SIZE << " but is " << size << endl; success = false; } } else { if (size != realSize) { cout <<"\n\tBad Return size, should be " << realSize << " but is " << size << endl; success = false; } } // check contents; for(i =0;i MAX_SIZE) { cout << "Error in Same, arrays too large" << endl; return false; } for(i=0;i