// file: $isip/class/pr/PhoneticDecisionTree/pdt_02.cc // version: $Id: pdt_02.cc 9319 2003-10-09 15:50:22Z gao $ // // isip include files // #include "PhoneticDecisionTree.h" #include // method: diagnose // // arguments: // Integral::DEBUG level: (input) debug level for diagnostics // // return: logical error status // // this is the diagnostics method // bool8 PhoneticDecisionTree::diagnose(Integral::DEBUG level_a) { //---------------------------------------------------------------------- // // 0. preliminaries // //---------------------------------------------------------------------- // output the class name // if (level_a > Integral::NONE) { SysString output(L"diagnosing class "); output.concat(CLASS_NAME); output.concat(L": "); Console::put(output); Console::increaseIndention(); } //--------------------------------------------------------------------- // // 1. required public methods // //--------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put(L"testing required public methods...\n"); Console::increaseIndention(); } // test destructor/constructor(s) and memory management // PhoneticDecisionTree pdt0; PhoneticDecisionTree pdt1(pdt0); if (!pdt1.eq(pdt0)) { return Error::handle(name(), L"copy constructor", Error::TEST, __FILE__, __LINE__); } // test large allocation construction and deletion // if (level_a == Integral::ALL) { Console::put(L"\ntesting large chunk memory allocation and deletion:\n"); // set the memory to a strange block size so we can hopefully catch any // frame overrun errors // PhoneticDecisionTree::setGrowSize((int32)500); PhoneticDecisionTree* pdt = new PhoneticDecisionTree(); for (int32 j = 1; j <= 100; j++) { PhoneticDecisionTree** pdts = new PhoneticDecisionTree*[j * 100]; // create the objects // for (int32 i = 0; i < j * 100; i++) { pdts[i] = new PhoneticDecisionTree(); } // delete objects // for (int32 i = (j * 100) - 1; i >= 0; i--) { delete pdts[i]; } delete [] pdts; } delete pdt; } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //--------------------------------------------------------------------- // // 2. class-specific public methods // //--------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put(L"testing class-specific public methods...\n"); Console::increaseIndention(); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //--------------------------------------------------------------------- // // 3. print completion message // //--------------------------------------------------------------------- // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } if (level_a > Integral::NONE) { SysString output(L"diagnostics passed for class"); output.concat(name()); output.concat(L"\n"); Console::put(output); } // exit gracefully // return true; }