📄 bicolorhashdiagnose.h
字号:
if (level_a > Integral::NONE) { Console::put(L"testing hash table get and set methods...\n"); Console::increaseIndention(); } // declare a hash table // BiColorHash<Char> hash_05; // create some data // BiGraphVertex<Char> vert_03; BiGraphVertex<Char> vert_04; BiGraphVertex<Char> vert_05; BiGraphVertex<Char> vert_06; BiGraphVertex<Char> vert_07; // add some vertices to teh hash table // hash_05.insert(&vert_01, Integral::GREEN); hash_05.insert(&vert_02, Integral::WHITE); hash_05.insert(&vert_03, Integral::GREY); hash_05.insert(&vert_04, Integral::BLACK); hash_05.insert(&vert_05, Integral::BLUE); hash_05.insert(&vert_06, Integral::BLUE); hash_05.insert(&vert_07, Integral::GREY); // test the get methods // if (hash_05.get(&vert_02) != Integral::WHITE) { return Error::handle(name(), L"insert/get", Error::TEST, __FILE__, __LINE__); } if (hash_05.get(&vert_04) != Integral::BLACK) { return Error::handle(name(), L"insert/get", Error::TEST, __FILE__, __LINE__); } if (hash_05.get(&vert_01) != Integral::GREEN) { return Error::handle(name(), L"insert/get", Error::TEST, __FILE__, __LINE__); } if (hash_05.get(&vert_03) != Integral::GREY) { return Error::handle(name(), L"insert/get", Error::TEST, __FILE__, __LINE__); } if (hash_05.get(&vert_05) != Integral::BLUE) { return Error::handle(name(), L"insert/get", Error::TEST, __FILE__, __LINE__); } if (hash_05.get(&vert_06) != Integral::BLUE) { return Error::handle(name(), L"insert/get", Error::TEST, __FILE__, __LINE__); } if (hash_05.get(&vert_07) != Integral::GREY) { return Error::handle(name(), L"insert/get", Error::TEST, __FILE__, __LINE__); } // test the set methods // hash_05.set(&vert_02, Integral::BLUE); if (hash_05.get(&vert_02) != Integral::BLUE) { return Error::handle(name(), L"set/get", Error::TEST, __FILE__, __LINE__); } hash_05.set(&vert_02, Integral::WHITE); if (hash_05.get(&vert_02) != Integral::WHITE) { return Error::handle(name(), L"set/get", Error::TEST, __FILE__, __LINE__); } hash_05.set(&vert_06, Integral::GREY); if (hash_05.get(&vert_06) != Integral::GREY) { return Error::handle(name(), L"set/get", Error::TEST, __FILE__, __LINE__); } hash_05.set(&vert_06, Integral::WHITE); if (hash_05.get(&vert_06) != Integral::WHITE) { return Error::handle(name(), L"set/get", Error::TEST, __FILE__, __LINE__); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //-------------------------------------------------------------------------- // // 4. hash table insert and remove methods // //-------------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put(L"testing hash table insert and remove methods...\n"); Console::increaseIndention(); } // declare a hash table // BiColorHash<Char> hash_06; // insert some vertices to teh hash table // hash_06.insert(&vert_01, Integral::GREEN); hash_06.insert(&vert_02, Integral::WHITE); hash_06.insert(&vert_03, Integral::GREY); hash_06.insert(&vert_04, Integral::BLACK); hash_06.insert(&vert_05, Integral::BLUE); hash_06.insert(&vert_06, Integral::BLUE); hash_06.insert(&vert_07, Integral::GREY); // test the insert methods // if (hash_06.get(&vert_02) != Integral::WHITE) { return Error::handle(name(), L"insert/get", Error::TEST, __FILE__, __LINE__); } if (hash_06.get(&vert_04) != Integral::BLACK) { return Error::handle(name(), L"insert/get", Error::TEST, __FILE__, __LINE__); } if (hash_06.get(&vert_01) != Integral::GREEN) { return Error::handle(name(), L"insert/get", Error::TEST, __FILE__, __LINE__); } if (hash_06.get(&vert_03) != Integral::GREY) { return Error::handle(name(), L"insert/get", Error::TEST, __FILE__, __LINE__); } if (hash_06.get(&vert_05) != Integral::BLUE) { return Error::handle(name(), L"insert/get", Error::TEST, __FILE__, __LINE__); } if (hash_06.get(&vert_06) != Integral::BLUE) { return Error::handle(name(), L"insert/get", Error::TEST, __FILE__, __LINE__); } if (hash_06.get(&vert_07) != Integral::GREY) { return Error::handle(name(), L"insert/get", Error::TEST, __FILE__, __LINE__); } // test the remove methods // hash_06.remove(&vert_01); hash_06.remove(&vert_02); hash_06.remove(&vert_03); hash_06.remove(&vert_06); if (hash_06.containsKey(&vert_03)) { return Error::handle(name(), L"containsKey", Error::TEST, __FILE__, __LINE__); } if (hash_06.containsKey(&vert_06)) { return Error::handle(name(), L"containsKey", Error::TEST, __FILE__, __LINE__); } if (hash_06.containsKey(&vert_01)) { return Error::handle(name(), L"containsKey", Error::TEST, __FILE__, __LINE__); } if (hash_06.containsKey(&vert_02)) { return Error::handle(name(), L"containsKey", Error::TEST, __FILE__, __LINE__); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //-------------------------------------------------------------------------- // // 5. hash table contains methods // //-------------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put(L"testing hash table contains methods...\n"); Console::increaseIndention(); } // declare a hash table // BiColorHash<Char> hash_07; // insert some vertices to teh hash table // hash_07.insert(&vert_01, Integral::GREEN); hash_07.insert(&vert_02, Integral::GREY); hash_07.insert(&vert_03, Integral::GREY); hash_07.insert(&vert_04, Integral::BLACK); // test the containsKey method // if (!hash_07.containsKey(&vert_01)) { return Error::handle(name(), L"containsKey", Error::TEST, __FILE__, __LINE__); } if (!hash_07.containsKey(&vert_02)) { return Error::handle(name(), L"containsKey", Error::TEST, __FILE__, __LINE__); } if (!hash_07.containsKey(&vert_03)) { return Error::handle(name(), L"containsKey", Error::TEST, __FILE__, __LINE__); } if (!hash_07.containsKey(&vert_04)) { return Error::handle(name(), L"containsKey", Error::TEST, __FILE__, __LINE__); } if (hash_07.containsKey(&vert_05)) { return Error::handle(name(), L"containsKey", Error::TEST, __FILE__, __LINE__); } if (hash_07.containsKey(&vert_06)) { return Error::handle(name(), L"containsKey", Error::TEST, __FILE__, __LINE__); } if (hash_07.containsKey(&vert_07)) { return Error::handle(name(), L"containsKey", Error::TEST, __FILE__, __LINE__); } // test the containsValue method // if (!hash_07.containsValue(Integral::GREY)) { return Error::handle(name(), L"containsValue", Error::TEST, __FILE__, __LINE__); } if (!hash_07.containsValue(Integral::GREEN)) { return Error::handle(name(), L"containsValue", Error::TEST, __FILE__, __LINE__); } if (!hash_07.containsValue(Integral::BLACK)) { return Error::handle(name(), L"containsValue", Error::TEST, __FILE__, __LINE__); } if (hash_07.containsValue(Integral::WHITE)) { return Error::handle(name(), L"containsValue", Error::TEST, __FILE__, __LINE__); } if (hash_07.containsValue(Integral::BLUE)) { return Error::handle(name(), L"containsValue", Error::TEST, __FILE__, __LINE__); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //--------------------------------------------------------------------------- // // 6. 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -