void ParsePositionTest::TestFieldPosition() { FieldPosition fp( 7 ); if (fp.getField() == 7) { logln("FP constructor(int) and getField tested."); }else{ errln("*** FP constructor(int) or getField"); } FieldPosition fpc(fp); if (fpc.getField() == 7) { logln("FP Constructor(FP&) passed"); } else { errln("*** FP Constructor(FP&)"); } FieldPosition fph( 3 ); if ( fph.getField() != 3) errln("*** FP getField or heap constr."); UBool err1 = FALSE; UBool err2 = FALSE; UBool err3 = FALSE; // for (long i = -50; i < 50; i++ ) { // fp.setField( i+8 ); // fp.setBeginIndex( i+6 ); // fp.setEndIndex( i+7 ); // if (fp.getField() != i+8) err1 = TRUE; // if (fp.getBeginIndex() != i+6) err2 = TRUE; // if (fp.getEndIndex() != i+7) err3 = TRUE; // } if (!err1) { logln("FP setField and getField tested."); }else{ errln("*** FP setField or getField"); } if (!err2) { logln("FP setBeginIndex and getBeginIndex tested."); }else{ errln("*** FP setBeginIndex or getBeginIndex"); } if (!err3) { logln("FP setEndIndex and getEndIndex tested."); }else{ errln("*** FP setEndIndex or getEndIndex"); } logln(""); FieldPosition *pfp = fp.clone(); if(pfp == &fp || *pfp != fp) { errln("FieldPosition.clone() failed"); } delete pfp; }
int main() { typedef CGAL::Polyhedron_3<Kernel> Polyhedron; typedef CGAL::Polyhedron_corefinement<Polyhedron> Corefinement; std::stringstream fpa(cube_a); std::stringstream fpb(cube_b); Polyhedron pa; Polyhedron pb; fpa >> pa; fpb >> pb; assert( pa.size_of_vertices() == 8); assert( pb.size_of_vertices() == 8); { Corefinement coref; std::list<std::vector<Kernel::Point_3> > polylines; std::vector<std::pair<Polyhedron*, int> > result; coref( pa, pb, std::back_inserter(polylines), std::back_inserter(result), Corefinement::Intersection_tag ); assert( polylines.size() == 1 ); assert( polylines.begin()->size() == 1 ); assert( result.size() == 0 ); } pb.clear(); std::stringstream fpc(inside_a); fpc >> pb; assert( pb.size_of_vertices() == 4); { Corefinement coref; std::list<std::vector<Kernel::Point_3> > polylines; std::vector<std::pair<Polyhedron*, int> > result; coref( pa, pb, std::back_inserter(polylines), std::back_inserter(result), Corefinement::Intersection_tag ); assert( polylines.size() == 4 ); assert( polylines.begin()->size() == 1 ); assert( result.size() == 1 ); assert( result[0].first->size_of_vertices() == 4); } }
void wb_crrgen::write_code(pwr_tStatus* rsts) { pwr_tFileName fname; char text[8192]; sprintf(fname, "$pwrp_load/rtt_crrc_%s.dat", vldh_VolumeIdToStr(m_sp->vid())); dcli_translate_filename(fname, fname); std::ofstream fpc(fname); if (!fpc) { *rsts = LDH__FILEOPEN; return; } for (int i = 0; i < int(sizeof(codelist) / sizeof(codelist[0])); i++) { for (wb_object o = m_sp->object(codelist[i].cid); o; o = o.next()) { // Skip if in LibHier bool in_libhier = false; for (wb_object p = o.parent(); p; p = p.parent()) { if (p.cid() == pwr_eClass_LibHier) { in_libhier = true; break; } } if (in_libhier) continue; wb_attribute a = m_sp->attribute(o.oid(), codelist[i].body, codelist[i].attr); a.value(text); if (!streq(text, "")) { fpc << " _Obj_ " << o.longName().name(cdh_mName_path | cdh_mName_object) << '\n'; fpc << text << '\n'; } } } fpc.close(); *rsts = 1; }
bool ExpressionCalculator (_String data) { //Checking for exit #ifndef __HYPHYQT__ if (data.sLength == 4) { _String checkForExit (data); checkForExit.LoCase(); if (checkForExit == _String ("exit")) { return false; } } #endif _Formula lhs, rhs; _String errMsg; _FormulaParsingContext fpc (&errMsg, nil); long retCode = Parse(&lhs, data, fpc, nil); if (retCode != HY_FORMULA_FAILED) { if (retCode == HY_FORMULA_EXPRESSION) { _PMathObj formRes = lhs.Compute(0,nil,nil,&errMsg); if (errMsg.sLength) { WarnError(errMsg); } else { _String * objValue = (_String*)formRes->toStr(); StringToConsole(*objValue); DeleteObject(objValue); } } else { BufferToConsole ("NO RETURN VALUE"); } } else { WarnError(errMsg); } return true; }