int tree_parent_pos(TreeHist* treeh) { static int stopint = 0; InputTree* tree = treeh->tree; if(!stopint) { ECString stopnm("STOP"); stopint = Term::get(stopnm)->toInt(); } InputTree* par = tree->parent(); if(!par) return stopint; const ECString& trmStr = par->hTag(); const Term* trm = Term::get(trmStr); assert(trm); if(!trm->terminal_p()) { cerr << "Bad head Part of Speech: " << *trm << " in " <<endl; cerr << *tree << endl; assert(trm->terminal_p()); } int ans = trm->toInt(); if(ans < 2 && toBe(par->head())) return 48; return ans; }
int fh_parent_pos(FullHist* fh) { static int stopint = 0; if(!stopint) { ECString stopnm("STOP"); stopint = Term::get(stopnm)->toInt(); } FullHist* par = fh->back; if(!par) return stopint; int ans = par->preTerm; if(ans < 2 && toBe(par->hd->lexeme())) return 48; return ans; }
#include "../Cegta.h" CegtaMain(); SpecBegin(CegtaDemo) describe("Cegta's expect()", ^{ it("should work well with integers and floating point numbers", ^{ int demo_int = 42; expectInt(demo_int, toBe(42)); // ...Like() for integers does exactly the same thing expectInt(demo_int, toBeLike(42)); expectInt(demo_int, notToBe(90)); expectInt(demo_int, notToBeLike(90)); double demo_double = 38.121; expectDouble(demo_double, toBe(38.121)); // ...Like() for floating point numbers is verifying // whether fabs(a-b) is less or equal to EPS expectDouble(demo_double, toBeLike(demo_double + CEGTA_EPSILON)); expectDouble(demo_double, toBeLike(demo_double - CEGTA_EPSILON)); expectDouble(demo_double, notToBeLike(demo_double + CEGTA_EPSILON*2)); expectDouble(demo_double, notToBe(0.444444)); }); }); describe("Cegta's expect()", ^{ it("should work well with strings (char*) as well", ^{ char* demo_str = "i am a demo string"; // toBe() for strings is a strcmp()-based comparison expectString(demo_str, toBe("i am a demo string"));