📄 cont_02.cc
字号:
// file: $isip/class/search/Context/cont_02.cc// version: $Id: cont_02.cc,v 1.4 2002/12/05 19:57:10 alphonso Exp $//// isip include files//#include "Context.h"// method: diagnose//// arguments:// Integral::DEBUG level: (input) debug level for diagnostics//// return: a boolean value indicating status//// this is the diagnose method//boolean Context::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(); } // declare variables // Context cont_01; Context cont_02(3, 2); Context cont_00(3, 2); GraphVertex<SearchNode>* vert_00 = new GraphVertex<SearchNode>(); GraphVertex<SearchNode>* vert_01 = new GraphVertex<SearchNode>(); GraphVertex<SearchNode>* vert_02 = new GraphVertex<SearchNode>(); GraphVertex<SearchNode>* vert_03 = new GraphVertex<SearchNode>(); // set up the context // cont_00.assignAndAdvance((ulong)vert_00); cont_00.assignAndAdvance((ulong)vert_01); cont_00.assignAndAdvance((ulong)vert_02); // test the assign and eq method // cont_01.assign(cont_00); if (!cont_00.eq(cont_01)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (cont_00.eq(cont_02)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } // test the set/get methods // if (cont_00.getCentralVertex() != vert_01) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (cont_00.getBeforeCentralVertex() != vert_00) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (cont_00.getAfterCentralVertex() != vert_02) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (cont_00.getLastVertex() != vert_02) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!cont_00.setCentralVertex((ulong)vert_00)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (cont_00.getCentralVertex() != vert_00) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!cont_00.setCentralVertex((ulong)vert_01)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (cont_00.getCentralVertex() != vert_01) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!cont_00.setLastVertex((ulong)vert_00)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (cont_00.getLastVertex() != vert_00) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!cont_00.setLastVertex((ulong)vert_02)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (cont_00.getLastVertex() != vert_02) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } // test the extend and fold methods // if (cont_01.isExtended()) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } cont_01.extend(vert_03); if (!cont_01.isExtended()) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } cont_01.fold(); if (cont_01.isExtended()) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } cont_02.assignAndAdvance((ulong)vert_01); cont_02.assignAndAdvance((ulong)vert_02); cont_02.assignAndAdvance((ulong)vert_03); if (!cont_01.eq(cont_02)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } // clean up // delete vert_00; delete vert_01; delete vert_02; delete vert_03; // 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(); } //--------------------------------------------------------------------- // // 4. 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;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -