TEST(LongInt, Construct) { std::string number1("13ojp4f12"); ASSERT_THROW(LongInt long_int(number1), std::invalid_argument); number1 = "0x098dcadcCDA23e4462384"; EXPECT_NO_THROW({ LongInt long_int(number1); });
void check2(Config &conf, int n, uint4 *pati[]) { register uint4 *p1 = pati[0]; register uint4 *p2 = pati[1]; register int k = n; register uint4 and; do { if ((and = (*p1++ & *p2++))) conf.n += number1(and); } while (--k); }
void main() {int a[4][4]; cout<<"please input the int"<<endl; for(int x=0;x<4;x++) for(int y=0;y<4;y++) cin>>a[x][y]; int b=number1(a); int c=number2(a); cout<<"第一条对角线的和为:"<<" "<<b<<endl; cout<<"第二条对角线的和为:"<<" "<<c<<endl; }
void check3(Config &conf, int n, uint4 *pati[]) { register uint4 *p1 ASM86("%ecx") = pati[0]; register uint4 *p2 ASM86("%ebx") = pati[1]; register uint4 *p3 ASM86("%edi") = pati[2]; register int k = n; register uint4 and; do { if ((and = (*p1++ & *p2++ & *p3++))) conf.n += number1(and); } while (--k); }
void checkn(int sq_num, Config &conf, int n, uint4 *pati[]) { register int k = n; if (sq_num < 2) Error("sq_num < 2"); do { register int j ASM86("%ecx") = sq_num-2; register uint4 and ASM86("%ebx") = *(pati[0]++); register uint4 **p ASM86("%edi") = &pati[1]; do { and &= *(*p++)++; } while (--j >= 0); if (and) conf.n += number1(and); } while (--k); }
void peano::applications::latticeboltzmann::blocklatticeboltzmann::configurations::PlaneBoundaryConfiguration:: parseInterval(std::string interval){ for (int d = 0; d < DIMENSIONS; d++){ std::string number1(""); std::string number2(""); tarch::irr::io::IrrXMLReader* getNumbers = tarch::irr::io::createIrrXMLReaderFromString(""); size_t closedPos1 = interval.find("["); size_t openPos1 = interval.find("("); size_t closedPos2 = interval.find("]"); size_t openPos2 = interval.find(")"); size_t semicolonPos = interval.find(";"); size_t first = 0; size_t last = 0; // determine left bracket position if ( (closedPos1 == std::string::npos) && (openPos1 == std::string::npos) ){ logDebug("parseInterval()", "No left brackets found!"); assertion(false); } if (closedPos1 == std::string::npos){ first = openPos1; } if (openPos1 == std::string::npos){ first = closedPos1; } if ( (closedPos1 != std::string::npos) && (openPos1 != std::string::npos) ){ first = std::min(closedPos1,openPos1); } // determine right bracket position if ( (closedPos2 == std::string::npos) && (openPos2 == std::string::npos) ){ logDebug("parseInterval()", "No right brackets found!"); assertion(false); } if (closedPos2 == std::string::npos){ last = openPos2; } if (openPos2 == std::string::npos){ last = closedPos2; } if ( (closedPos2 != std::string::npos) && (openPos2 != std::string::npos) ){ last = std::min(closedPos2,openPos2); } // check validity if (first >= last){ logDebug("parseInterval()", "Right brackets before left brackets!"); assertion(false); } if ( (semicolonPos <=first) || (semicolonPos >= last) || (semicolonPos == std::string::npos) ){ logDebug("parseInterval()", "No valid semicolon separation could not be detected!"); assertion(false); } // find out type of brackets if (first == closedPos1){ _isOpen(2*d) = false; } else { _isOpen(2*d) = true; } if (last == closedPos2){ _isOpen(2*d+1) = false; } else { _isOpen(2*d+1) = true; } // get start and end interval and set offset and width of box range number1 = interval.substr(first+1,semicolonPos-1-first); number2 = interval.substr(semicolonPos+1,last-1-semicolonPos); _offset(d) = getNumbers->convertValueStringToDouble( number1 ); _width(d) = getNumbers->convertValueStringToDouble(number2) - _offset(d); logDebug("parseInterval()", "Number1: " << number1 << " offset " << d << ": " << _offset(d)); logDebug("parseInterval()", "Number2: " << number2 << " width " << d << ": " << _width(d)); // remove this part from string interval = interval.substr(last+1); // find sign 'x' and next left bracket if (d < DIMENSIONS-1){ size_t closedNext = interval.find("["); size_t openNext = interval.find("("); first = interval.find("x"); if ( (closedNext == std::string::npos) && (openNext == std::string::npos) ){ logDebug("parseInterval()", "No new left brackets found!"); assertion(false); } if (closedNext == std::string::npos){ last = openNext; } if (openNext == std::string::npos){ last = closedNext; } if ( (closedNext != std::string::npos) && (openNext != std::string::npos) ){ last = std::min(closedNext,openNext); } if (last <= first){ logDebug("parseInterval()", "No 'x' between intervals could be found!"); assertion(false); } // remove all just until the first letter behind 'x' interval = interval.substr(first+1); } logDebug("parseInterval()", "Rest to parse: " << interval); } // check width for (int d = 0; d < DIMENSIONS; d++){ if (tarch::la::smaller(_width(d),0.0)){ logDebug("parseInterval()", "Width of box is smaller than zero!"); assertion(false); } } }
int main() { cout << "以下实验是规定了Document的值,测试时可以自行改变其值与测试内容" << endl; char b1[5] = { 'i', '9', '5', ',', 's' }; Line a1 (b1, b1 + 5); char b2[7] = { ' ', 'c', 'r', 'l', ' ','c','o' }; Line a2(b2,b2+7); char b3[6] = { '8','w', ' ', 'l', '*', 'l'}; Line a3(b3, b3 + 6); list<Line>answer; answer.push_back(a1); answer.push_back(a2); answer.push_back(a3); Document my_doc(answer); Document tmp = my_doc; cout << "原来文件为:" << endl; print(tmp); cout << endl; cout << "文件的字符数为:" << number(tmp) << endl; cout << "文件的字数为(根据第一种算法):" << number1(tmp) << endl; cout << "其中字母序列(第二种算法):" << number2(tmp)<<endl; const string pre= "i7"; cout << "查找单词为:" << pre<<endl; Text_iterator p = find_text(tmp, pre); if (p==tmp.end() ) { cout << "不存在该单词" << endl; } else { cout << "存在该单词" << endl; int length = pre.length(); string now = "wa56 ker"; cout << "替换为:" << now << endl; cout << "替换后的文件为:" << endl; p.change(length, now); print(tmp); cout << endl; cout << "文件的字符数为:" << number(tmp) << endl; cout << "文件的字数为(根据第一种算法):" << number1(tmp) << endl; cout << "其中字母序列(第二种算法):" << number2(tmp) << endl; } tmp = my_doc; string pres = "crl"; cout << "查找单词为:" << pres << endl; Text_iterator s = find_text(tmp, pres); if (s == tmp.end()) { cout << "不存在该单词" << endl; } else { cout << "存在该单词" << endl; int length = pres.length(); string now = "wa56 er"; cout << "替换为:" << now << endl; cout << "替换后的文件为:" << endl; s.change(length, now); print(tmp); cout << endl; cout << "文件的字符数为:" << number(tmp) << endl; cout << "文件的字数为(根据第一种算法):" << number1(tmp) << endl; cout << "其中字母序列(第二种算法):" << number2(tmp) << endl; } getchar(); getchar(); getchar(); }