int main() { int i; for (i = 0; i < 256; i++) chartest[i].c = i; chartest[0].c = 0; /* chartest-done */ Fun1(foo1); Fun2(foo2); Fun3(foo3); Fun4(foo4); Fun5(foo5); Fun6(foo6); Fun7(foo7); Fun8(foo8); Fun9(foo9); Fun10(foo10); Fun11(foo11); Fun12(foo12); Fun13(foo13); Fun14(foo14); Fun15(foo15); Fun16(foo16); Fun17(foo17); Fun18(foo18); /* An (almost-)infinite loop that first clears all the variables and then calls each function. This "hack" is to make testing random functions easier - "advance funN" is guaranteed to have always been preceded by a global variable clearing zed call. We don't let this run forever in case gdb crashes while testing, we don't want to be left eating all cpu on the user's system. */ for (i = 0; i < 1000000; ++i) { zed (); L1 = fun1(); L2 = fun2(); L3 = fun3(); L4 = fun4(); L5 = fun5(); L6 = fun6(); L7 = fun7(); L8 = fun8(); L9 = fun9(); L10 = fun10(); L11 = fun11(); L12 = fun12(); L13 = fun13(); L14 = fun14(); L15 = fun15(); L16 = fun16(); L17 = fun17(); L18 = fun18(); } return 0; }
void test1 () { struct V { float x = 1.0f; float GetX() const { return x; } V() {} } const v; Class c; const Class cc; Fun< int (int) > fun0; Fun< int (int) > fun1(&Twice); Fun< int (int) > fun2(&Class::Twice); Fun< int () > fun3(&VoidParam); Fun< int () > fun4(&Class::VoidParam); Fun< int () > fun5(&Class::VoidParamConst); Fun< void(int&) > fun6(&Class::Void); Fun< int (int) > fun7((Functor())); auto fun8(RetFun()); Fun< float (int, int) > fun9([=](int i, int j) {return float(i/j);}); Fun< float (int, int) > fun10(fun9); Fun< float () > fun11([v](){return v.GetX();}); Fun< void() > vd; try { fun0(9); //must throw assert(false); } catch(...) {} fun0 = fun1; assert(fun0(2) == fun1(2)); assert(fun1(2) == 4); assert(fun2(c, 3) == 6); assert(fun5(cc) == 2); assert(fun7(6) == 18); assert(fun8(7) == 21); assert(fun9(10,4) == float(10/4)); assert(fun10(20, 8) == fun9(20, 8)); assert(fun11() == 1.0f); //void return type int i = 0; fun6(c, i); assert(i == 1234); }
int main(void) { char arr[] = "123x456 17960? 302tab5876"; fun8(arr); return 0; }
int fun7() { set_bp(); return fun8(); }