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

📄 vectordiagnose.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
📖 第 1 页 / 共 4 页
字号:
  }  if ((read_partial_str_text.readPartialData(text_file, 1, 3) != (long)3)      || (read_partial_str_text(0).ne(write_strings[1]))) {    read_partial_str_text.debug(L"read_partial_str_text");    return Error::handle(name(), L"read partial str text", Error::TEST,			 __FILE__, __LINE__);  }    if ((read_partial_str_text.readPartialData(text_file, 0, 3) != (long)3)      || (read_partial_str_text(0).ne(write_strings[0]))) {    read_partial_str_text.debug(L"read_partial_str_text");    return Error::handle(name(), L"read partial str text", Error::TEST,			 __FILE__, __LINE__);  }  if ((read_partial_str_text.readPartialData(text_file, 1, 2) != (long)2)      || (read_partial_str_text(0).ne(write_strings[1]))) {    read_partial_str_text.debug(L"read_partial_str_text");    return Error::handle(name(), L"read partial str text", Error::TEST,			 __FILE__, __LINE__);  }  read_partial_str_text.readTerminate(text_file);    if (!read_partial_str_bin.readStart(bin_file)) {    return Error::handle(name(), L"readStart", Error::TEST, __FILE__,			 __LINE__);  }  if ((read_partial_str_bin.readPartialData(bin_file, 1, 3) != (long)3)      || (read_partial_str_bin(0).ne(write_strings[1]))) {          read_partial_str_bin.debug(L"read_partial_str_bin");      return Error::handle(name(), L"read partial str bin", Error::TEST,			 __FILE__, __LINE__);  }  read_partial_str_bin.readTerminate(bin_file);    // partial read for Vector<Float>  //  read_float_vec_text.clear();  read_float_vec_bin.clear();    if (!text_file.find(Vector<Float>::name(), (long)7)) {    return Error::handle(name(), L"find", Error::TEST, __FILE__, __LINE__);  }  if (!bin_file.find(Vector<Float>::name(), (long)7)) {    return Error::handle(name(), L"find", Error::TEST, __FILE__, __LINE__);  }  if (!read_float_vec_text.readStart(text_file)) {    return Error::handle(name(), L"readStart", Error::TEST, __FILE__,			 __LINE__);  }  if (!read_float_vec_bin.readStart(bin_file)) {    return Error::handle(name(), L"readStart", Error::TEST, __FILE__,			 __LINE__);  }  long read_size = 50;  Vector<Float> vecf_expected(read_size);  VectorLong start_positions(L"0, 3, 98, 99, 100, 130, 180, 290, 340, 391, 443, 980, 1273, 1993, 2000, 2100, 841");  for (long j = 0; j < start_positions.length(); j++) {    long start = start_positions(j);        for (long i = 0; i < read_size; i++) {      vecf_expected(i) = float_vec(i + start);    }    if ((read_float_vec_text.readPartialData(text_file,					     start, read_size) != read_size)	|| (read_float_vec_text.ne(vecf_expected))) {            read_float_vec_text.debug(L"read_float_vec_text");      vecf_expected.debug(L"vecf_expected");      return Error::handle(name(), L"read partial float text", Error::TEST,			   __FILE__, __LINE__);    }    if ((read_float_vec_bin.readPartialData(bin_file, start,					    read_size) != read_size)	|| (read_float_vec_bin.ne(vecf_expected))) {      Long(j).debug(L"j=");      read_float_vec_bin.debug(L"read_float_vec_bin");      vecf_expected.debug(L"vecf_expected");      return Error::handle(name(), L"read partial float bin", Error::TEST,			   __FILE__, __LINE__);    }  }  read_size = 1;  for (long j = 995; j < float_vec.length() - read_size; j++) {    long start = j;        for (long i = 0; i < read_size; i++) {      vecf_expected(i) = float_vec(i + start);    }    if ((read_float_vec_text.readPartialData(text_file,					     start, read_size) != read_size)	|| (read_float_vec_text(0).ne(vecf_expected(0)))) {            read_float_vec_text(0).debug(L"read_float_vec_text");      vecf_expected.debug(L"vecf_expected");      return Error::handle(name(), L"read partial float text", Error::TEST,			   __FILE__, __LINE__);    }    if ((read_float_vec_bin.readPartialData(bin_file, start,					    read_size) != read_size)	|| (read_float_vec_bin(0).ne(vecf_expected(0)))) {      Long(j).debug(L"j=");      read_float_vec_bin.debug(L"read_float_vec_bin");      vecf_expected(0).debug(L"vecf_expected");      return Error::handle(name(), L"read partial float bin", Error::TEST,			   __FILE__, __LINE__);    }  }    for (long j = 0; j < float_vec.length() - read_size; j++) {    long start = j;        for (long i = 0; i < read_size; i++) {      vecf_expected(i) = float_vec(i + start);    }    if ((read_float_vec_text.readPartialData(text_file,					     start, read_size) != read_size)	|| (read_float_vec_text(0).ne(vecf_expected(0)))) {            read_float_vec_text(0).debug(L"read_float_vec_text");      vecf_expected.debug(L"vecf_expected");      return Error::handle(name(), L"read partial float text", Error::TEST,			   __FILE__, __LINE__);    }    if ((read_float_vec_bin.readPartialData(bin_file, start,					    read_size) != read_size)	|| (read_float_vec_bin(0).ne(vecf_expected(0)))) {      Long(j).debug(L"j=");      read_float_vec_bin.debug(L"read_float_vec_bin");      vecf_expected(0).debug(L"vecf_expected");      return Error::handle(name(), L"read partial float bin", Error::TEST,			   __FILE__, __LINE__);    }  }  read_float_vec_text.readTerminate(text_file);  read_float_vec_bin.readTerminate(bin_file);  // close and delete the temporary files  //  text_file.close();  bin_file.close();  // cleanup the memory that was created by the Vector read  //  read_char_vector_text.clear();  read_char_vector_bin.clear();  read_str_vector_text.clear();  read_str_vector_bin.clear();  read_llist_vector_text.clear();  read_llist_vector_bin.clear();  read_char_vec_vector_text.clear();  read_char_vec_vector_bin.clear();  read_partial_char_text.clear();  read_partial_char_bin.clear();  read_partial_str_text.clear();  read_partial_str_bin.clear();  read_partial_char_vec_text.clear();  read_partial_char_vec_bin.clear();   read_partial_llist_text.clear();  read_partial_llist_bin.clear();  write_char_vector.clear();  write_str_vector.clear();  write_llist_vector.clear();  write_char_vec_vector.clear();    for (long i = 0; i < 5; i++) {    delete chars[i];  }  delete [] chars;   // test the object assign method  //  Vector<Long> vec_long;  vec_long.setLength(2);  // assign the long object (note we can not assign((long)-1) directly)  //  Long number((long)-1);  vec_long.assign(number);          // test ne methods  //  if (char_vector.ne(char_copy_vector)) {    return Error::handle(name(), L"ne", Error::TEST, __FILE__, __LINE__);  }        // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }  //--------------------------------------------------------------------------  //  // 3. class-specific public methods:  //     item access methods  //  //--------------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: item access methods...\n");    Console::increaseIndention();  }  // test operator() methods  //  if (char_vector(0).ne(L'a')) {    return Error::handle(name(), L"operator()", Error::TEST,			 __FILE__, __LINE__);  }  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }  //---------------------------------------------------------------------------  //  // 4. class-specific public methods:  //     size-related methods  //  //---------------------------------------------------------------------------     // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: size-related methods...\n");    Console::increaseIndention();  }  // testing length methods:  //  initialize a vector of length 10  //  Vector<Char> def_vector_2((long)10);  if (def_vector_2.length() != 10) {    return Error::handle(name(), L"length", Error::TEST, __FILE__,                         __LINE__);  }    // set the capacity  //  def_vector_2.setCapacity((long)500);  if (((long)def_vector_2.capacity_d) != 500) {    return Error::handle(name(), L"setCapacity", Error::TEST, __FILE__,                         __LINE__);  }  if (def_vector_2.getCapacity() != 500) {    return Error::handle(name(), L"getCapacity", Error::TEST, __FILE__,                         __LINE__);  }    // set the length to be a large value, the capacity should also grow if the   // new length is greater than the capacity  //  def_vector_2.setLength((long)1000);    if (((long)(def_vector_2.length_d) != 1000) || (((long)def_vector_2.capacity_d) != 1000)) {    return Error::handle(name(), L"setLength", Error::TEST, __FILE__,                         __LINE__);  }  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }  //---------------------------------------------------------------------------  //  // 5. class-specific public methods:  //     data manipulation methods  //  //--------------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: data manipulation methods...\n");    Console::increaseIndention();  }  // test positioning methods:  //  initialize vectors and chars to use for testing   //  Vector<Char> char_val_0((long)2);  Char tmp(L'f');  char_val_0.assign(tmp);    Vector<Char> char_val_1((long)5);  Vector<Char> char_val_2;  Vector<Char> result((long)5);    tmp_char = L'a';  for (long i = 0; i < 5; i++) {    char_val_1(i).assign(tmp_char);    tmp_char++;  }  // move 4 elements starting from the 2nd element in val1, put into val0  // starting from 2nd element, val0 will be resized  //   char_val_0.move(char_val_1, 4, 1, 1);    result(0).assign(L'f');  result(1).assign(L'b');  result(2).assign(L'c');  result(3).assign(L'd');  result(4).assign(L'e');    if (char_val_0.ne(result)) {    char_val_0.debug(L"move ->");    return Error::handle(name(), L"move", Error::TEST, __FILE__, __LINE__);  }    // move 2 elements starting from the 2nd element  // in char_val_1, put into char_val_0 starting from 1st element  //  char_val_0.move(char_val_1, 2, 1, 0);  // char_val_0 was "f, b, c, d, e", and char_val_1 is "a, b, c, d, e",  // so char_val_0 should be "b, c, c, d, e"  //  result(0).assign(L'b');  result(1).assign(L'c');  result(2).assign(L'c');  result(3).assign(L'd');  result(4).assign(L'e');    if (char_val_0.ne(result)) {    char_val_0.debug(L"char_val_0");    return Error::handle(name(), L"move", Error::TEST, __FILE__, __LINE__);  }   // shift char_val_0 2 elements to the right  //  char_val_1.shift(char_val_0, 2);  char_val_0.shift(2);  result(0).assign(Char::DEF_VALUE);  result(1).assign(Char::DEF_VALUE);  result(2).assign(L'b');  result(3).assign(L'c');  result(4).assign(L'c');    if (char_val_0.ne(result)) {    return Error::handle(name(), L"shift", Error::TEST, __FILE__, __LINE__);  }  if (char_val_1.ne(result)) {    char_val_1.debug(L"char_val_1");    result.debug(L"result");    return Error::handle(name(), L"shift", Error::TEST, __FILE__, __LINE__);  }  // shift char_val_0 1 elements to the left  //  char_val_1.shift(char_val_0, -1);  char_val_0.shift(-1);  result(0).assign(Char::DEF_VALUE);  result(1).assign(L'b');  result(2).assign(L'c');  result(3).assign(L'c');  result(4).assign(Char::DEF_VALUE);    if (char_val_0.ne(result)) {    return Error::handle(name(), L"shift", Error::TEST, __FILE__, __LINE__);  }  if (char_val_1.ne(result)) {    return Error::handle(name(), L"shift", Error::TEST, __FILE__, __LINE__);  }    // concatenate  //  char_val_0.setLength((long)3);  tmp.assign(L'a');  char_val_0.assign(tmp);  char_val_1.setLength((long)2);  tmp.assign(L'b');  char_val_1.assign(tmp);  char_val_2.concat(char_val_0, char_val_1);  char_val_0.concat(char_val_1);  // char_val_0 was "a, a, a", char_val_1 is "b, b", so the result should  // be "a,a,a,b,b"  //  tmp.assign(L'a');  result.assign(tmp);  result(3).assign(L'b');  result(4).assign(L'b');  if (char_val_0.ne(result)) {    return Error::handle(name(), L"concat", Error::TEST, __FILE__, __LINE__);  }   if (char_val_2.ne(result)) {    return Error::handle(name(), L"concat", Error::TEST, __FILE__, __LINE__);  }   char_val_0.clear(Integral::FREE);  Char c(L'a');  char_val_0.concat(c);  char_val_0.concat(c);  char_val_0.concat(c);  c.assign(L'b');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -