// file: $isip/class/dstr/BiGraphVertex/BiGraphVertexDiagnose.h // version: $Id: BiGraphVertexDiagnose.h 10636 2007-01-26 22:18:09Z tm334 $ // // make sure definitions are only made once // #ifndef ISIP_BIGRAPH_VERTEX_DIAGNOSE #define ISIP_BIGRAPH_VERTEX_DIAGNOSE // isip include files // #ifndef ISIP_BIGRAPH_VERTEX #include #endif // BiGraphVertexDiagnose: a class that contains the diagnose method of // BiGraphVertex class. // template class BiGraphVertexDiagnose : public BiGraphVertex { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // define the class name // //---------------------------------------- // // i/o related constants // //---------------------------------------- //---------------------------------------- // // default values and arguments // //---------------------------------------- // default values // // default arguments to methods // //---------------------------------------- // // error codes // //---------------------------------------- //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return BiGraphVertex::name(); } // other static methods // static bool8 diagnose(Integral::DEBUG debug_level); // debug methods // these methods are omitted since this class does not have data // members and operations // // destructor/constructor(s): // these methods are omitted since this class does not have data // members and operations // // assign methods: // these methods are omitted since this class does not have data // members and operations // // operator= methods: // these methods are omitted since this class does not have data // members and operations // // i/o methods: // these methods are omitted since this class does not have data // members and operations // // equality methods: // these methods are omitted since this class does not have data // members and operations // // memory-management methods: // these methods are omitted since this class does not have data // members and operations // //--------------------------------------------------------------------------- // // class-specific public methods // //--------------------------------------------------------------------------- // these methods are omitted since this class does not have data // members and operations // //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: }; // below are all the methods for the BiGraphVertexDiagnose template class // //----------------------------------------------------------------------------- // // required static methods // //----------------------------------------------------------------------------- // method: diagnose // // arguments: // Integral::DEBUG level: (input) debug level for diagnostics // // return: a bool8 value indicating status // template bool8 BiGraphVertexDiagnose::diagnose(Integral::DEBUG level_a) { //---------------------------------------------------------------------- // // 0. preliminaries // //---------------------------------------------------------------------- // output the class name // if (level_a > Integral::NONE) { SysString output(L"diagnosing class "); output.concat(BiGraphVertex::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 the debug methods // if (level_a > Integral::BRIEF) { Integral::debug(L"debug"); } // default constructor // BiGraphVertex def_vertex; TObject item; def_vertex.setItem(&item); // copy constructor // BiGraphVertex copy_vertex(def_vertex); // all of the constructed vertices should contain the same item now // if (def_vertex.item_d->ne(*copy_vertex.item_d)) { return Error::handle(name(), L"constructors", Error::TEST, __FILE__, __LINE__); } // check the constructors and destructors for allocating on the dynamic // memory heap // BiGraphVertex* def_dyn_vert = new BiGraphVertex(); def_dyn_vert->setItem(&item); // copy constructor // BiGraphVertex* copy_dyn_vert = new BiGraphVertex(*def_dyn_vert); // all of the constructed nodes should contain the same item now // if (def_dyn_vert->item_d->ne(*copy_dyn_vert->item_d)) { return Error::handle(name(), L"constructors", Error::TEST, __FILE__, __LINE__); } // clear some vertices // def_dyn_vert->clear(); def_vertex.clear(); copy_dyn_vert->clear(); copy_vertex.clear(); // see if we can dynamically delete // delete def_dyn_vert; delete copy_dyn_vert; // check the constructors for allocating on the stack // BiGraphVertex def_vert_2; def_vert_2.setItem(&item); BiGraphVertex copy_vert_2(def_vert_2); // copy constructor // all of the constructed nodes should contain the exact same item now // if (def_vert_2.item_d != copy_vert_2.item_d) { return Error::handle(name(), L"constructors", Error::TEST, __FILE__, __LINE__); } // default constructor // BiGraphVertex* def_dyn_vert_2 = new BiGraphVertex(); def_dyn_vert_2->setItem(&item); // copy constructor // BiGraphVertex* copy_dyn_vert_2 = new BiGraphVertex(*def_dyn_vert_2); // all of the constructed nodes should contain the same item now // if (def_dyn_vert_2->item_d != copy_dyn_vert_2->item_d) { return Error::handle(name(), L"constructors", Error::TEST, __FILE__, __LINE__); } // clear some vertices // def_dyn_vert_2->clear(); copy_vert_2.clear(); // see if we can dynamically delete // delete def_dyn_vert_2; delete copy_dyn_vert_2; // test large allocation construction and deletion // if (level_a >= Integral::ALL) { // output an informative message // 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 // BiGraphVertex::setGrowSize((int32)731); // loop for a large number of times creating and deleting a large number // of vertices at each loop // for (int32 j = 1; j <= 100; j++) { BiGraphVertex** self_verts = new BiGraphVertex*[j * 100]; BiGraphVertex** verts = new BiGraphVertex*[j * 100]; // create the vertices // for (int32 i = 0; i < j * 100; i++) { self_verts[i] = new BiGraphVertex(); verts[i] = new BiGraphVertex(); } // delete nodes // for (int32 i = (j * 100) - 1; i >= 0; i--) { delete self_verts[i]; delete verts[i]; } delete [] self_verts; delete [] verts; } // perform the same test using the new[] and delete [] operators // for (int32 j = 1; j <= 100; j++) { // allocate a large number of nodes // BiGraphVertex* self_verts = new BiGraphVertex[j * 100]; BiGraphVertex* verts = new BiGraphVertex[j * 100](); // clean up memory // delete [] self_verts; delete [] verts; } } // test assign methods // TObject item0; TObject item1; BiGraphVertex tmp_vert; BiGraphVertex* tmp_dyn_vert = new BiGraphVertex(); // set the items // tmp_vert.setItem(&item0); tmp_dyn_vert->setItem(&item1); // try the copy assign // tmp_vert.assign(*tmp_dyn_vert); if ((tmp_vert.item_d->ne(item1)) || (tmp_dyn_vert->item_d->ne(item1))) { return Error::handle(name(), L"vertex assign", Error::TEST, __FILE__, __LINE__); } // clean up // delete tmp_dyn_vert; // testing remaining required methods // Char chr_item_0(L'A'); BiGraphVertex dbg_vert; dbg_vert.setItem(&chr_item_0); if (level_a >= Integral::ALL) { dbg_vert.debug(L"testing debug method"); } // create two vertices // BiGraphVertex eq_vert_00; BiGraphVertex eq_vert_10; // create a character // Char eq_char(L'a'); // set the first vertex // eq_vert_00.setItem(&eq_char); // assign the second item // eq_vert_10.assign(eq_vert_00); // call the eq method // if (!eq_vert_00.eq(eq_vert_10)) { return Error::handle(name(), L"eq", Error::TEST, __FILE__, __LINE__); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } // -------------------------------------------------------------------- // // 2. class-specific public methods: // BiGraph manipulation methods // // -------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put(L"testing class-specific public methods: BiGraph manipulation methods...\n"); Console::increaseIndention(); } // test item, arc, and parent BiGraph manipulations // Char* chars[128]; for (int32 i = 0; i < 128; i++) { chars[i] = new Char((unichar)i); } // create two BiGraphs to manipulate // BiGraph bigraph1(DstrBase::USER); BiGraph bigraph2(DstrBase::USER); // create an array of vertices to test // BiGraphVertex* vertices[128]; for (int32 i = 0; i < 128; i++) { vertices[i] = new BiGraphVertex(); // set the item in each vertex // vertices[i]->setItem(chars[i]); } // make sure the setParentBiGraph and getParentBiGraph methods work // // assign one of the two BiGraphs to each node // for (int32 i = 0; i < 64; i++) { if (!vertices[i]->setParentGraph(&bigraph1)) { return Error::handle(name(), L"setParentGraph", Error::TEST, __FILE__, __LINE__); } } for (int32 i = 64; i < 128; i++) { if (!vertices[i]->setParentGraph(&bigraph2)) { return Error::handle(name(), L"setParentGraph", Error::TEST, __FILE__, __LINE__); } } // make sure that the proper BiGraph was assigned // for (int32 i = 0; i < 64; i++) { if ((vertices[i]->getParentGraph() != &bigraph1) || (vertices[128 - i - 1]->getParentGraph() != &bigraph2) || (vertices[i]->getParentGraph() == vertices[128 - i - 1]->getParentGraph())) { return Error::handle(name(), L"getParentGraph", Error::TEST, __FILE__, __LINE__); } } // start building a binary tree BiGraph where the first (left) child of each // vertex is the (2*i + 1) element of the character array and the // second (right) child is the (2*i + 2) element of the character array // // create the first vertex // vertices[0]->setItem(chars[0]); // set the BiGraph characteristics // bigraph1.setWeighted(); // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } // -------------------------------------------------------------------- // // 3. class-specific public methods: // vertex manipuation methods // // -------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put(L"testing class-specific public methods: vertex manipuation methods...\n"); Console::increaseIndention(); } { // attach this as the first node in the BiGraph // bigraph1.getStart()->insertArcChild(vertices[0], 0.0, false); // now loop over the remaining vertices - the tree will be built when we // get to 63. the 63rd vertex will only have one child (the root node // takes one vertex) // for (int32 i = 0; i < 63; i++) { vertices[i]->insertArcChild(vertices[2 * i + 1], (float32)i, false); vertices[i]->insertArcChild(vertices[2 * i + 2], (float32)i, false); } vertices[63]->insertArcChild(vertices[127], (float32)127, false); // reverse engineer the binary tree to make sure it is correct // bigraph1.getStart()->gotoFirstChild(); // get the first element and make sure it is the proper root vertex // if (!(bigraph1.getStart()->isAdjacentChild(vertices[0])) || (bigraph1.getStart()->getCurrChild()->getVertex() != vertices[0])) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // the leaf vertices should be empty // for (int32 i = 127; i >= 64; --i) { if (!vertices[i]->isEmptyChild()) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } } // handle the 63rd item that has only one child vertex // if (vertices[63]->getCurrChild()->getVertex() != vertices[2 * 63 + 1]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove the first arc // if (!vertices[63]->removeArcChild()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // the remaining vertices should have the appropriate child vertices in the // appropriate order and with the appropriate weight // for (int32 i = 62; i >= 0; --i) { // go to the front of the list // vertices[i]->gotoFirstChild(); // the first vertex should point to the (2*i + 1) element // if (vertices[i]->getCurrChild()->getVertex() != vertices[2 * i + 1]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove the first arc // if (!vertices[i]->removeArcChild()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // the second vertex should point to the (2*i + 2) element // if (vertices[i]->getCurrChild()->getVertex() != vertices[2 * i + 2]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove the second arc // if (!vertices[i]->removeArcChild()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // make sure the list is now empty // if (!vertices[i]->isEmptyChild()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } } // the root vertex should still be attached to the start vertex of the // BiGraph // if (bigraph1.getStart()->getCurrChild()->getVertex() != vertices[0]) { return Error::handle(name(), L"insertArc/removeArc", Error::TEST, __FILE__, __LINE__); } // disconnect the root vertex // if (!bigraph1.getStart()->removeArcChild()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // the BiGraph start vertex should now be empty // if (!bigraph1.getStart()->isEmptyChild()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // now rebuild the same binary tree so we can remove arcs a different // way // // attach this as the first node in the BiGraph // bigraph1.getStart()->insertArcChild(vertices[0], 0.0, false); // now loop over the remaining vertices - the tree will be built when we // get to 63. the 63rd vertex will only have one child (the root node // takes one vertex) // for (int32 i = 0; i < 63; i++) { vertices[i]->insertArcChild(vertices[2 * i + 1], (float32)i, false); vertices[i]->insertArcChild(vertices[2 * i + 2], (float32)i, false); } vertices[63]->insertArcChild(vertices[127], (float32)127, false); // reverse engineer the binary tree to make sure it is correct // bigraph1.getStart()->gotoFirstChild(); } { // attach this as the first node in the BiGraph // bigraph1.getStart()->insertArcParent(vertices[0], 0.0, false); // now loop over the remaining vertices - the tree will be built when we // get to 63. the 63rd vertex will only have one child (the root node // takes one vertex) // for (int32 i = 0; i < 63; i++) { vertices[i]->insertArcParent(vertices[2 * i + 1], (float32)i, false); vertices[i]->insertArcParent(vertices[2 * i + 2], (float32)i, false); } vertices[63]->insertArcParent(vertices[127], (float32)127, false); // reverse engineer the binary tree to make sure it is correct // bigraph1.getStart()->gotoFirstParent(); // get the first element and make sure it is the proper root vertex // if (!(bigraph1.getStart()->isAdjacentParent(vertices[0])) || (bigraph1.getStart()->getCurrParent()->getVertex() != vertices[0])) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // the leaf vertices should be empty // for (int32 i = 127; i >= 64; --i) { if (!vertices[i]->isEmptyParent()) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } } // handle the 63rd item that has only one child vertex // if (vertices[63]->getCurrParent()->getVertex() != vertices[2 * 63 + 1]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove the first arc // if (!vertices[63]->removeArcParent()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // the remaining vertices should have the appropriate child vertices in the // appropriate order and with the appropriate weight // for (int32 i = 62; i >= 0; --i) { // go to the front of the list // vertices[i]->gotoFirstParent(); // the first vertex should point to the (2*i + 1) element // if (vertices[i]->getCurrParent()->getVertex() != vertices[2 * i + 1]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove the first arc // if (!vertices[i]->removeArcParent()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // the second vertex should point to the (2*i + 2) element // if (vertices[i]->getCurrParent()->getVertex() != vertices[2 * i + 2]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove the second arc // if (!vertices[i]->removeArcParent()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // make sure the list is now empty // if (!vertices[i]->isEmptyParent()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } } // the root vertex should still be attached to the start vertex of the // BiGraph // if (bigraph1.getStart()->getCurrParent()->getVertex() != vertices[0]) { return Error::handle(name(), L"insertArc/removeArc", Error::TEST, __FILE__, __LINE__); } // disconnect the root vertex // if (!bigraph1.getStart()->removeArcParent()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // the BiGraph start vertex should now be empty // if (!bigraph1.getStart()->isEmptyParent()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // now rebuild the same binary tree so we can remove arcs a different // way // // attach this as the first node in the BiGraph // bigraph1.getStart()->insertArcParent(vertices[0], 0.0, false); // now loop over the remaining vertices - the tree will be built when we // get to 63. the 63rd vertex will only have one child (the root node // takes one vertex) // for (int32 i = 0; i < 63; i++) { vertices[i]->insertArcParent(vertices[2 * i + 1], (float32)i, false); vertices[i]->insertArcParent(vertices[2 * i + 2], (float32)i, false); } vertices[63]->insertArcParent(vertices[127], (float32)127, false); // reverse engineer the binary tree to make sure it is correct // bigraph1.getStart()->gotoFirstParent(); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } // -------------------------------------------------------------------- // // 4. class-specific public methods: // item manipulation methods // // -------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put(L"testing class-specific public methods: item manupulation methods...\n"); Console::increaseIndention(); } { // get the first element and make sure it is the proper root vertex // if (!(bigraph1.getStart()->isAdjacentChild(vertices[0])) || (bigraph1.getStart()->getCurrChild()->getVertex() != vertices[0]) || (bigraph1.getStart()->getCurrChild()-> getVertex()->getItem()->ne(*chars[0]))) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // the leaf vertices should be empty // for (int32 i = 127; i >= 64; --i) { if (!vertices[i]->isEmptyChild()) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } } // handle the 63rd item that has only one child vertex // if (vertices[63]->getCurrChild()->getVertex() != vertices[2 * 63 + 1]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove the first arc // if (!vertices[63]->removeArcChild()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // the remaining vertices should have the appropriate child vertices in the // appropriate order and with the appropriate weight // for (int32 i = 62; i >= 32; --i) { // go to the front of the list // vertices[i]->gotoFirstChild(); // the first vertex should point to the (2*i + 1) element // if (vertices[i]->getCurrChild()->getVertex() != vertices[2 * i + 1]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // move to the next arc // vertices[i]->gotoNextChild(); // the second vertex should point to the (2*i + 2) element // if (vertices[i]->getCurrChild()->getVertex() != vertices[2 * i + 2]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove all arcs from this vertex // if (!vertices[i]->removeAllArcsChild()) { return Error::handle(name(), L"removeAllArcs", Error::TEST, __FILE__, __LINE__); } if (!vertices[i]->isEmptyChild()) { return Error::handle(name(), L"removeAllArcs", Error::TEST, __FILE__, __LINE__); } } // the remaining vertices should have the appropriate child vertices in the // appropriate order and with the appropriate weight // for (int32 i = 31; i >= 0; --i) { // go to the front of the list // vertices[i]->gotoFirstChild(); // the first vertex should point to the (2*i + 1) element // if (vertices[i]->getCurrChild()->getVertex() != vertices[2 * i + 1]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // move to the next vertex // vertices[i]->gotoNextChild(); // the second vertex should point to the (2*i + 2) element // if (vertices[i]->getCurrChild()->getVertex() != vertices[2 * i + 2]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove the arcs in turn // if (!vertices[i]->removeArcChild(vertices[2 * i + 2])) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } if (!vertices[i]->removeArcChild(vertices[2 * i + 1])) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // make sure the list is now empty // if (!vertices[i]->isEmptyChild()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } } // the root vertex should still be attached to the start vertex of the // BiGraph // if (bigraph1.getStart()->getCurrChild()->getVertex() != vertices[0]) { return Error::handle(name(), L"insertArc/removeArc", Error::TEST, __FILE__, __LINE__); } // disconnect the root vertex // if (!bigraph1.getStart()->removeArcChild()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // the BiGraph start vertex should now be empty // if (!bigraph1.getStart()->isEmptyChild()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } } { // get the first element and make sure it is the proper root vertex // if (!(bigraph1.getStart()->isAdjacentParent(vertices[0])) || (bigraph1.getStart()->getCurrParent()->getVertex() != vertices[0]) || (bigraph1.getStart()->getCurrParent()-> getVertex()->getItem()->ne(*chars[0]))) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // the leaf vertices should be empty // for (int32 i = 127; i >= 64; --i) { if (!vertices[i]->isEmptyParent()) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } } // handle the 63rd item that has only one child vertex // if (vertices[63]->getCurrParent()->getVertex() != vertices[2 * 63 + 1]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove the first arc // if (!vertices[63]->removeArcParent()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // the remaining vertices should have the appropriate child vertices in the // appropriate order and with the appropriate weight // for (int32 i = 62; i >= 32; --i) { // go to the front of the list // vertices[i]->gotoFirstParent(); // the first vertex should point to the (2*i + 1) element // if (vertices[i]->getCurrParent()->getVertex() != vertices[2 * i + 1]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // move to the next arc // vertices[i]->gotoNextParent(); // the second vertex should point to the (2*i + 2) element // if (vertices[i]->getCurrParent()->getVertex() != vertices[2 * i + 2]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove all arcs from this vertex // if (!vertices[i]->removeAllArcsParent()) { return Error::handle(name(), L"removeAllArcs", Error::TEST, __FILE__, __LINE__); } if (!vertices[i]->isEmptyParent()) { return Error::handle(name(), L"removeAllArcs", Error::TEST, __FILE__, __LINE__); } } // the remaining vertices should have the appropriate child vertices in the // appropriate order and with the appropriate weight // for (int32 i = 31; i >= 0; --i) { // go to the front of the list // vertices[i]->gotoFirstParent(); // the first vertex should point to the (2*i + 1) element // if (vertices[i]->getCurrParent()->getVertex() != vertices[2 * i + 1]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // move to the next vertex // vertices[i]->gotoNextParent(); // the second vertex should point to the (2*i + 2) element // if (vertices[i]->getCurrParent()->getVertex() != vertices[2 * i + 2]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove the arcs in turn // if (!vertices[i]->removeArcParent(vertices[2 * i + 2])) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } if (!vertices[i]->removeArcParent(vertices[2 * i + 1])) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // make sure the list is now empty // if (!vertices[i]->isEmptyParent()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } } // the root vertex should still be attached to the start vertex of the // BiGraph // if (bigraph1.getStart()->getCurrParent()->getVertex() != vertices[0]) { return Error::handle(name(), L"insertArc/removeArc", Error::TEST, __FILE__, __LINE__); } // disconnect the root vertex // if (!bigraph1.getStart()->removeArcParent()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // the BiGraph start vertex should now be empty // if (!bigraph1.getStart()->isEmptyParent()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } } // clean up the memory // for (int32 i = 0; i < 128; i++) { delete chars[i]; delete vertices[i]; } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //--------------------------------------------------------------------- // // 7. 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; } // end of include file // #endif