⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setdiagnose.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
📖 第 1 页 / 共 2 页
字号:
    characters[i].assign(temp_char);        // insert the character to the list    //    char_list->insert(&characters[i]);        // increment the character value    //    temp_char++;  }    // self-allocated  //  Set<Char>* char_copy_list_1 = new Set<Char>();  char_copy_list_1->assign(*char_list);    // not self-allocated  //  Set<Char>* char_copy_list_2 =    new Set<Char>(USER);  char_copy_list_2->assign(*char_list);    // char_copy_list_1 and char_copy_list_2 should be the same as the  // char_list  //  if (!char_list->eq(*char_copy_list_1)) {    return Error::handle(name(), L"eq", Error::TEST, __FILE__, __LINE__);  }    if (char_list->ne(*char_copy_list_1)) {    return Error::handle(name(), L"ne", Error::TEST, __FILE__, __LINE__);  }    if (!char_list->eq(*char_copy_list_2)) {    return Error::handle(name(), L"eq", Error::TEST, __FILE__, __LINE__);  }    if (char_list->ne(*char_copy_list_2)) {    return Error::handle(name(), L"ne", Error::TEST, __FILE__, __LINE__);  }    // clean up  //  delete char_list;  delete char_copy_list_1;  delete char_copy_list_2;  delete [] characters;  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }  // --------------------------------------------------------------------  //  // 2. class-specific public methods:  //     positioning methods  //  // --------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: positioning methods...\n");    Console::increaseIndention();   }  // test positioning, node and data accessing methods  //  Set<Char> tmp_list_2;    for (long i = 0; i < 9; i++) {    tmp_list_2.insert(items[i]);  }    // goto the first node  //  if (!tmp_list_2.gotoFirst()) {    return Error::handle(name(), L"gotoFirst", Error::TEST, __FILE__,			 __LINE__);  }  // make sure this is the first node  //  if (!tmp_list_2.isFirst()) {    return Error::handle(name(), L"isFirst", Error::TEST, __FILE__, __LINE__);  }  // make sure this is not the last node  //  if (tmp_list_2.isLast()) {    return Error::handle(name(), L"isLast", Error::TEST, __FILE__, __LINE__);  }  if (tmp_list_2.first_d->getItem()->ne(*items[6]) ||      tmp_list_2.curr_d->getItem()->ne(*items[6])) {    return Error::handle(name(), L"gotoFirst", Error::TEST, __FILE__,			 __LINE__);  }  // goto the next node  //  if (!tmp_list_2.gotoNext()) {    return Error::handle(name(), L"gotoNext", Error::TEST, __FILE__,			 __LINE__);  }    if (tmp_list_2.curr_d->getItem()->ne(*items[3])) {    return Error::handle(name(), L"gotoNext", Error::TEST, __FILE__,			 __LINE__);  }    // is mark_d set?  //  if (tmp_list_2.markIsSet()) {    return Error::handle(name(), L"markIsSet", Error::TEST, __FILE__,			 __LINE__);  }  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    //--------------------------------------------------------------------------  //  // 3. class-specific public methods:  //     marking methods  //  //--------------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: marking methods...\n");    Console::increaseIndention();  }    // set a mark here - the second node   //  tmp_list_2.setMark();    if (tmp_list_2.mark_d->getItem()->ne(*items[3])) {    return Error::handle(name(), L"setMark", Error::TEST, __FILE__,			 __LINE__);  }      if (!tmp_list_2.isMarkedElement()) {    return Error::handle(name(), L"isMarkedElement", Error::TEST, __FILE__,			 __LINE__);  }    if (!tmp_list_2.markIsSet()) {    return Error::handle(name(), L"markIsSet", Error::TEST, __FILE__,			 __LINE__);  }    // goto the last node  //  if (!tmp_list_2.gotoLast()) {    return Error::handle(name(), L"gotoLast", Error::TEST, __FILE__,			 __LINE__);  }  // make sure this is not the first node  //  if (tmp_list_2.isFirst()) {    return Error::handle(name(), L"isFirst", Error::TEST, __FILE__, __LINE__);  }  // make sure this is the last node  //  if (!tmp_list_2.isLast()) {    return Error::handle(name(), L"isLast", Error::TEST, __FILE__, __LINE__);  }  if (tmp_list_2.last_d->getItem()->ne(*items[2]) ||      tmp_list_2.curr_d->getItem()->ne(*items[2])) {    return Error::handle(name(), L"gotoLast", Error::TEST, __FILE__,			 __LINE__);  }    if (tmp_list_2.isMarkedElement()) {    return Error::handle(name(), L"isMarkedElement", Error::TEST, __FILE__,			 __LINE__);  }    // when there is no next node, gotoNext should stay at the current position  // and return false  //  tmp_list_2.gotoLast();  if (tmp_list_2.gotoNext()) {    return Error::handle(name(), L"gotoNext", Error::TEST, __FILE__,			 __LINE__);  }      if (tmp_list_2.curr_d != tmp_list_2.last_d) {    return Error::handle(name(), L"gotoNext", Error::TEST, __FILE__,			 __LINE__);  }    // goto the previous node   //  if (!tmp_list_2.gotoPrev()) {    return Error::handle(name(), L"gotoPrev", Error::TEST, __FILE__,			 __LINE__);  }    if (tmp_list_2.curr_d->getItem()->ne(*items[5])) {    return Error::handle(name(), L"gotoPrev", Error::TEST, __FILE__,			 __LINE__);  }    // when there is no previous node, gotoPrev should stay at the current  // position and return false  //  tmp_list_2.gotoFirst();    if (tmp_list_2.gotoPrev()) {    return Error::handle(name(), L"gotoPrev", Error::TEST, __FILE__,			 __LINE__);  }    if (tmp_list_2.curr_d != tmp_list_2.first_d) {    return Error::handle(name(), L"gotoPrev", Error::TEST, __FILE__,			 __LINE__);  }    // goto the marked node   //  if (!tmp_list_2.gotoMark()) {    return Error::handle(name(), L"gotoMark", Error::TEST, __FILE__,			 __LINE__);  }    if (tmp_list_2.curr_d->getItem()->ne(*items[3]) ||      tmp_list_2.mark_d->getItem()->ne(*items[3])) {    return Error::handle(name(), L"gotoMark", Error::TEST, __FILE__,			 __LINE__);  }    // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }  //--------------------------------------------------------------------------  //  // 4. class-specific public methods:  //     element access methods  //  //--------------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: element access methods...\n");    Console::increaseIndention();  }  // get the element of the current node  //  if (tmp_list_2.getCurr()->ne(*items[3])) {    return Error::handle(name(), L"getCurr", Error::TEST, __FILE__,			 __LINE__);  }  for (long i = 0; i < 9; i++) {    Char x((long)L'a' + i);    if (tmp_list_2(i).ne(x)) {      return Error::handle(name(), L"operator", Error::TEST,			   __FILE__, __LINE__);    }  }  // test getPosition  //  if (tmp_list_2.getPosition() != 1) {    return Error::handle(name(), L"getPosition", Error::TEST, __FILE__,			 __LINE__);  }  // test gotoPosition for all cases  //  for (long i = 0; i < 9; i++) {    tmp_list_2.gotoPosition(i);    if (tmp_list_2.getPosition() != i) {      return Error::handle(name(), L"getPosition", Error::TEST, __FILE__,			   __LINE__);    }  }  // test the contains method  //  tmp_list_2.gotoLast();  for (long i = 0; i < 9; i++) {    if (!tmp_list_2.contains(items[i])) {      return Error::handle(name(), L"contains", Error::TEST, __FILE__,			   __LINE__);    }  }  tmp_list_2.gotoLast();  for (long i = 0; i < 9; i++) {    if (!tmp_list_2.find(items[i])) {      return Error::handle(name(), L"find", Error::TEST, __FILE__,			   __LINE__);    }    if (tmp_list_2.getCurr()->ne(*items[i])) {      return Error::handle(name(), L"getPosition", Error::TEST, __FILE__,			   __LINE__);    }  }  // restore the position  //  tmp_list_2.gotoPosition(1);  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    //--------------------------------------------------------------------------  //  // 5. class-specific public methods:  //     insert and remove methods  //  //--------------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: insert and remove methods...\n");    Console::increaseIndention();  }    // build a simple set  //  Set<Char> set_system(SYSTEM);  Set<Char> set_user(USER);    for (long i = 0; i < 9; i++) {    if (!set_system.insert(items[i])) {      return Error::handle(name(), L"insert", Error::TEST, __FILE__, __LINE__);    }    if (!set_user.insert(items[i])) {      return Error::handle(name(), L"insert", Error::TEST, __FILE__, __LINE__);    }  }  // now try to insert items again, it should fail  //  for (long i = 0; i < 9; i++) {    if (set_system.insert(items[i])) {      return Error::handle(name(), L"insert", Error::TEST, __FILE__, __LINE__);    }    if (set_user.insert(items[i])) {      return Error::handle(name(), L"insert", Error::TEST, __FILE__, __LINE__);    }  }  // find item[4]  //  if (!set_system.find(items[4])) {    return Error::handle(name(), L"find", Error::TEST, __FILE__, __LINE__);  }  if (!set_user.find(items[4])) {    return Error::handle(name(), L"find", Error::TEST, __FILE__, __LINE__);  }  // remove it  //  if (!set_system.remove()) {    return Error::handle(name(), L"remove", Error::TEST, __FILE__, __LINE__);  }  if (!set_user.remove()) {    return Error::handle(name(), L"remove", Error::TEST, __FILE__, __LINE__);  }  // make sure it is gone  //  if (set_system.contains(items[4])) {    return Error::handle(name(), L"contains", Error::TEST, __FILE__, __LINE__);  }  if (set_user.contains(items[4])) {    return Error::handle(name(), L"contains", Error::TEST, __FILE__, __LINE__);  }  Char* x;    // find item[2]  //  if (!set_system.find(items[2])) {    return Error::handle(name(), L"find", Error::TEST, __FILE__, __LINE__);  }  if (!set_user.find(items[2])) {    return Error::handle(name(), L"find", Error::TEST, __FILE__, __LINE__);  }  // remove it: for system mode it should copy the object  //  x = new Char;  if (!set_system.remove(x) || (x == items[2]) || x->ne(*items[2])) {    return Error::handle(name(), L"remove", Error::TEST, __FILE__, __LINE__);  }  delete x;  if (!set_user.remove(x) || (x != items[2])) {    return Error::handle(name(), L"remove", Error::TEST, __FILE__, __LINE__);  }    // make sure it is gone  //  if (set_system.contains(items[2])) {    return Error::handle(name(), L"contains", Error::TEST, __FILE__, __LINE__);  }  if (set_user.contains(items[2])) {    return Error::handle(name(), L"contains", Error::TEST, __FILE__, __LINE__);  }  // make sure everything else is still there  //  for (long i = 0; i < 9; i++) {    if ((i != 2) && (i != 4) && !set_system.contains(items[i])) {      return Error::handle(name(), L"contains", Error::TEST, __FILE__,			   __LINE__);    }    if ((i != 2) && (i != 4) && !set_user.contains(items[i])) {      return Error::handle(name(), L"contains", Error::TEST, __FILE__,			   __LINE__);    }  }  // delete working data  //  for (long i = 0; i < 3; i++) {    for (long j = 0; j < 3; j++) {      delete items[i * 3 + j];    }  }  delete [] items;  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }  //---------------------------------------------------------------------  //  // 9. 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 + -