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

📄 sstr_02.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 3 页
字号:
  //     relational and logical methods  //  //---------------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: relational and logical methods...\n");    Console::increaseIndention();  }  // test generic compare methods  //  str1.assign(L"red");  str2.assign(L"boat");  str3.assign(L"boat");    if (str1.compare(str2) != Integral::GREATER) {    Error::handle(name(), L"compare 0", Error::TEST, __FILE__, __LINE__);  }    if (str2.compare(str1) != Integral::LESSER) {    Error::handle(name(), L"compare 1", Error::TEST, __FILE__, __LINE__);  }    if (str2.compare(str3) != Integral::EQUAL) {    Error::handle(name(), L"compare 2", Error::TEST, __FILE__, __LINE__);  }  if (str2.comparePartial(str3, 1, 2, 1) != Integral::EQUAL) {    Error::handle(name(), L"comparePartial", Error::TEST, __FILE__, __LINE__);  }  if (str2.comparePartial(L"boat", 1, 2, 1) != Integral::EQUAL) {    Error::handle(name(), L"comparePartial", Error::TEST, __FILE__, __LINE__);  }  if (str1.eq(str2)) {    Error::handle(name(), L"eq", Error::TEST, __FILE__, __LINE__);  }    if (!str2.eq(str3)) {    Error::handle(name(), L"eq", Error::TEST, __FILE__, __LINE__);  }  str3.assign(L"Boat");  if (str2.eq(str3)) {    Error::handle(name(), L"eq, case sensitive ", Error::TEST, __FILE__,                  __LINE__);  }  if (str2.ne(str3, false)) {    Error::handle(name(), L"ne, case insensitive", Error::TEST, __FILE__,                  __LINE__);  }  str3.toLower();  if (!str1.gt(str2)) {    Error::handle(name(), L"gt", Error::TEST, __FILE__, __LINE__);  }  // test relational methods  //  if (str2.gt(str3)) {    Error::handle(name(), L"gt", Error::TEST, __FILE__, __LINE__);  }    if (!str1.ge(str2)) {    Error::handle(name(), L"ge", Error::TEST, __FILE__, __LINE__);  }    if (!str2.ge(str3)) {    Error::handle(name(), L"ge", Error::TEST, __FILE__, __LINE__);  }    if (!str2.lt(str1)) {    Error::handle(name(), L"lt", Error::TEST, __FILE__, __LINE__);  }    if (str3.lt(str2)) {    Error::handle(name(), L"lt", Error::TEST, __FILE__, __LINE__);  }    if (!str2.le(str1)) {    Error::handle(name(), L"le", Error::TEST, __FILE__, __LINE__);  }    if (!str3.le(str2)) {    Error::handle(name(), L"le", Error::TEST, __FILE__, __LINE__);  }    if (!str2.ne(str1)) {    Error::handle(name(), L"ne", Error::TEST, __FILE__, __LINE__);  }    if (str2.ne(str3)) {    Error::handle(name(), L"ne", Error::TEST, __FILE__, __LINE__);  }    // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    //---------------------------------------------------------------------------  //  // 4. class-specific public methods:  //     indexing methods  //  //---------------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: indexing methods...\n");    Console::increaseIndention();  }  // declare a string  //  SysString oper_str(L"rjck");  unichar c = oper_str(1);  if (c != L'j') {    Error::handle(name(), L"operator scalar <-", Error::TEST,                  __FILE__, __LINE__);  }    c = L'i';  oper_str(1) = c;  if (oper_str.ne(L"rick")) {    Error::handle(name(), L"operator scalar ->", Error::TEST,                  __FILE__, __LINE__);  }    // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    //---------------------------------------------------------------------------  //  // 5. class-specific public methods:  //     conversion methods  //  //---------------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: conversion methods...\n");    Console::increaseIndention();  }  // test byte* and unichar* conversion methods  //  // pull out all the values at once. interleave the different width  // characters to test alignment. Note that sparcs are long word  // aligned while pentiums are not, so a program which runs on a  // pentium may not run on a sparc. If you get a bus error on a Sun  // for a program that works on a Pentium, check that your addresses  // are long word aligned.  //  SysString priv_str1((byte*)"hello my name is");  SysString priv_str2(L"rick");    unichar* ws1 = priv_str1;  byte* s1 = priv_str1;  unichar* ws2 = priv_str2;  byte* s2 = priv_str2;    if (isip_wcscmp(ws1, L"hello my name is") != 0) {    Error::handle(name(), L"operator unichar* 1", Error::TEST,                  __FILE__, __LINE__);  }  if (isip_wcscmp(ws2, L"rick") != 0) {    Error::handle(name(), L"operator unichar* 2", Error::TEST,                  __FILE__, __LINE__);  }  if (strcmp((char*)s1, (char*)"hello my name is") != 0) {    Error::handle(name(), L"operator byte* 1", Error::TEST,                  __FILE__, __LINE__);  }  if (strcmp((char*)s2, (char*)"rick") != 0) {    Error::handle(name(), L"operator byte* 2", Error::TEST,                  __FILE__, __LINE__);  }  // all the get methods have been tested in "extensions to the  // required public methods" part of diagnose method  //    // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    //---------------------------------------------------------------------------  //  // 6. 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();  }  // declare a string  //  SysString tmp(L"12");    // test memSize  //  if (tmp.memSize() != 20) {    Error::handle(name(), L"memSize", Error::TEST, __FILE__, __LINE__);  }  // test memSize  //  long len = tmp.length();  if (len != 2) {    fprintf(stdout, "len = %ld", len);    Error::handle(name(), L"length", Error::TEST, __FILE__, __LINE__);  }  // test setCapacity  //  tmp.setCapacity(5);  if (tmp.capacity_d != 5) {    Error::handle(name(), L"setCapacity", Error::TEST, __FILE__, __LINE__);  }    // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    //---------------------------------------------------------------------------  //  // 7. class-specific public methods:  //     string manipulation methods  //  //---------------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: string manipulation methods...\n");    Console::increaseIndention();  }  // test insert methods  //  SysString str5(L"alphonso");  str2.assign((byte*)"hello my name is");  str3.assign(L"real ");  str4.assign(L" duncan");  str2.insert(str3, 9);  if (level_a > Integral::ALL) {    str2.debug(L"str2");  }  if (str2.ne(L"hello my real name is")) {    Error::handle(name(), L"insert", Error::TEST, __FILE__, __LINE__);  }    str2.insert(str4, 9999);  if (level_a > Integral::ALL) {    str2.debug(L"str2");  }  if (str2.ne(L"hello my real name is duncan")) {    Error::handle(name(), L"insert", Error::TEST, __FILE__, __LINE__);  }    str3.assign(L" jennings");  str2.insert(str3, 21);  if (level_a > Integral::ALL) {    str2.debug(L"str2");  }  if (str2.ne(L"hello my real name is jennings duncan")) {    Error::handle(name(), L"insert", Error::TEST, __FILE__, __LINE__);  }    str3.assign(L"richard ");  str2.insert(str3, 22);  if (level_a > Integral::ALL) {    str2.debug(L"str2");  }  if (str2.ne(L"hello my real name is richard jennings duncan")) {    Error::handle(name(), L"insert", Error::TEST, __FILE__, __LINE__);  }  // test replace methods  //  str3.assign(L"JoeBobb");  str2.replace(str3, 22);  if (level_a > Integral::ALL) {    str2.debug(L"str2");  }  if (str2.ne(L"hello my real name is JoeBobb jennings duncan")) {    Error::handle(name(), L"replace", Error::TEST, __FILE__, __LINE__);  }  str3.assign(str2);  str3.replace(L" duncan", L"");  if (str3.ne(L"hello my real name is JoeBobb jennings")) {    Error::handle(name(), L"replace", Error::TEST, __FILE__, __LINE__);  }  str3.replaceAll(L" ", L"");   if (str3.ne(L"hellomyrealnameisJoeBobbjennings")) {    Error::handle(name(), L"replace", Error::TEST, __FILE__, __LINE__);  }  str5.replaceAll(L"o", L" o ");  if (str5.ne(L"alph o ns o ")) {    Error::handle(name(), L"replace", Error::TEST, __FILE__, __LINE__);  }       str4.assign(L"...or maybe not");  str2.replace(str4, str2.length());  if (level_a > Integral::ALL) {    str2.debug(L"str2");  }  if(str2.ne(L"hello my real name is JoeBobb jennings duncan...or maybe not")){    Error::handle(name(), L"replace", Error::TEST, __FILE__, __LINE__);  }  // test deleteRange methods  //  str2.deleteRange(str2.length() - 15, -1);  if (level_a > Integral::ALL) {    str2.debug(L"str2");  }  if (str2.ne(L"hello my real name is JoeBobb jennings duncan")) {    Error::handle(name(), L"deleteRange", Error::TEST, __FILE__, __LINE__);  }    str2.deleteRange(22, 8);  if (level_a > Integral::ALL) {    str2.debug(L"str2");  }  if (str2.ne(L"hello my real name is jennings duncan")) {    Error::handle(name(), L"deleteRange", Error::TEST, __FILE__, __LINE__);  }    str2.deleteRange(22, 9);  if (level_a > Integral::ALL) {    str2.debug(L"str2");  }  if (str2.ne(L"hello my real name is duncan")) {    Error::handle(name(), L"deleteRange", Error::TEST, __FILE__, __LINE__);  }  // test boundary condition for deleteRange  //  SysString str(L"0123456789");  str.deleteRange(8, 2);  if (str.length() != 8) {    return Error::handle(name(), L"deleteRange", Error::TEST, __FILE__,			 __LINE__);  }    // test concat methods  //  str1.assign(L"Hello my name");  str1.concat(L" is");  if (level_a > Integral::ALL) {    str1.debug(L"str1");  }  if (str1.ne(L"Hello my name is")) {    Error::handle(name(), L"concat", Error::TEST, __FILE__, __LINE__);  }    str2.assign(L" Rick");  str3.assign(str1);  str3.concat(str2);  if (level_a > Integral::ALL) {    str3.debug(L"str3");  }  if (str3.ne(L"Hello my name is Rick")) {    Error::handle(name(), L"concat", Error::TEST, __FILE__, __LINE__);  }    str4.concat(str1, str2);  if (str4.ne(L"Hello my name is Rick")) {    Error::handle(name(), L"concat", Error::TEST, __FILE__, __LINE__);  }  str4.concat((unichar)L'y');  if (str4.ne(L"Hello my name is Ricky")) {    str4.debug(L"str4");    Error::handle(name(), L"concat", Error::TEST, __FILE__, __LINE__);  }  str4.concat((unichar)L'J', L"asdf %c qwer");  if (str4.ne(L"Hello my name is Rickyasdf J qwer")) {    str4.debug(L"str4");    Error::handle(name(), L"concat", Error::TEST, __FILE__, __LINE__);  }  str4.concat(L"xyz", L"asdf %s qwer");  if (str4.ne(L"Hello my name is Rickyasdf J qwerasdf xyz qwer")) {    str4.debug(L"str4");    Error::handle(name(), L"concat", Error::TEST, __FILE__, __LINE__);  }  str4.concat(str, L"num = %s xyz");  if (str4.ne(L"Hello my name is Rickyasdf J qwerasdf xyz qwernum = 01234567 xyz")) {    str4.debug(L"str4");    Error::handle(name(), L"concat", Error::TEST, __FILE__, __LINE__);  }    // make sure we can concat an empty string  //  SysString foo;  SysString bar;  foo.concat(bar);  if (foo.length() != 0) {    return Error::handle(name(), L"concat", Error::TEST, __FILE__, __LINE__);  }  // test numeric concat methods  //    // test the byte conversions  //  num.clear();  num.concat(dbyte);  num.get(dbyte_v);  if (dbyte != dbyte_v) {    Error::handle(name(), L"assign(byte)", Error::TEST, __FILE__, __LINE__);  }  num.clear();  num.concat(dbyte, L"asdf = %u xyz");  if (num.ne(L"asdf = 27 xyz")) {    Error::handle(name(), L"assign(byte)", Error::TEST, __FILE__, __LINE__);  }    // test the short conversions  //  num.clear();  num.concat(dshort);  num.get(dshort_v);  if (dshort != dshort_v) {    Error::handle(name(), L"assign(short)", Error::TEST, __FILE__, __LINE__);  }  num.clear();  num.concat(dshort, L"asdf = %d xyz");  if (num.ne(L"asdf = 27 xyz")) {    Error::handle(name(), L"assign(short)", Error::TEST, __FILE__, __LINE__);  }    // test the long conversions  //  num.clear();  num.concat(dlong);  num.get(dlong_v);  if (dlong != dlong_v) {    Error::handle(name(), L"assign(long)", Error::TEST, __FILE__, __LINE__);  }  num.clear();  num.concat(dlong, L"asdf = %ld xyz");  if (num.ne(L"asdf = 277 xyz")) {    Error::handle(name(), L"assign(long)", Error::TEST, __FILE__, __LINE__);  }  // test the llong conversions  //  num.clear();  num.concat(dllong);  num.get(dllong_v);    if (dllong != dllong_v) {    Error::handle(name(), L"assign(llong)", Error::TEST, __FILE__, __LINE__);  }    num.clear();  num.concat(dllong, L"asdf = %lld xyz");  if (num.ne(L"asdf = 13020756033 xyz")) {    Error::handle(name(), L"assign(llong)", Error::TEST, __FILE__, __LINE__);  }  // test the ushort conversions  //  num.clear();  num.concat(dushort);  num.get(dushort_v);    if (dushort != dushort_v) {    Error::handle(name(), L"assign(ushort)", Error::TEST, __FILE__, __LINE__);  }  num.clear();  num.concat(dushort, L"asdf = %lu xyz");  if (num.ne(L"asdf = 6907 xyz")) {    Error::handle(name(), L"assign(ushort)", Error::TEST, __FILE__, __LINE__);  }  // test the ulong conversions  //  num.clear();  num.concat(dulong);  num.get(dulong_v);  if (dulong != dulong_v) {    Error::handle(name(), L"assign(ulong)", Error::TEST, __FILE__, __LINE__);  }  num.clear();  num.concat(dulong, L"asdf = %lu xyz");  if (num.ne(L"asdf = 2777 xyz")) {    Error::handle(name(), L"assign(ulong)", Error::TEST, __FILE__, __LINE__);  }  // test the ullong conversions  //  num.clear();  num.concat(dullong);  num.get(dullong_v);  if (dullong != dullong_v) {    Error::handle(name(), L"assign(ullong)", Error::TEST, __FILE__, __LINE__);  }  num.clear();  num.concat(dullong, L"asdf = %llu xyz");  if (num.ne(L"asdf = 1302075603332 xyz")) {    num.debug(L"");    Error::handle(name(), L"assign(long)", Error::TEST, __FILE__, __LINE__);  }  // test the float conversions  //  num.clear();  num.concat(dfloat);  num.get(dfloat_v);  if (level_a > Integral::ALL) {    num.debug(L"float");  }    if (!Integral::almostEqual(dfloat, dfloat_v)) {    fprintf(stdout, "%f != %f != '%s'\n", dfloat, dfloat_v, (char*)(byte*)num);    Error::handle(name(), L"assign(float)", Error::TEST, __FILE__, __LINE__);  }  num.clear();  num.concat(dfloat, L"asdf = %e xyz");  if (num.ne(L"asdf = 2.727000e-18 xyz")) {    Error::handle(name(), L"assign(float)", Error::TEST, __FILE__, __LINE__);  }  // test the double conversions  //  num.clear();  num.concat(ddouble);  num.get(ddouble_v);

⌨️ 快捷键说明

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