Ejemplo n.º 1
0
// BEGIN KAWIGIEDIT TESTING
// Generated by KawigiEdit 2.1.4 (beta) modified by pivanof
bool KawigiEdit_RunTest(int testNum, vector <int> p0, int p1, bool hasAnswer, int p2) {
   cout << "Test " << testNum << ": [" << "{";
   for (int i = 0; int(p0.size()) > i; ++i) {
      if (i > 0) {
         cout << ",";
      }
      cout << p0[i];
   }
   cout << "}" << "," << p1;
   cout << "]" << endl;
   WalkOverATree *obj;
   int answer;
   obj = new WalkOverATree();
   clock_t startTime = clock();
   answer = obj->maxNodesVisited(p0, p1);
   clock_t endTime = clock();
   delete obj;
   bool res;
   res = true;
   cout << "Time: " << double(endTime - startTime) / CLOCKS_PER_SEC << " seconds" << endl;
   if (hasAnswer) {
      cout << "Desired answer:" << endl;
      cout << "\t" << p2 << endl;
   }
   cout << "Your answer:" << endl;
   cout << "\t" << answer << endl;
   if (hasAnswer) {
      res = answer == p2;
   }
   if (!res) {
      cout << "DOESN'T MATCH!!!!" << endl;
   } else if (double(endTime - startTime) / CLOCKS_PER_SEC >= 2) {
      cout << "FAIL the timeout" << endl;
      res = false;
   } else if (hasAnswer) {
      cout << "Match :-)" << endl;
   } else {
      cout << "OK, but is it right?" << endl;
   }
   cout << "" << endl;
   return res;
}
Ejemplo n.º 2
0
int main( int argc, char* argv[] ) {
    {
        int parentARRAY[] = {0, 0};
        vector <int> parent( parentARRAY, parentARRAY+ARRSIZE(parentARRAY) );
        WalkOverATree theObject;
        eq(0, theObject.maxNodesVisited(parent, 2),2);
    }
    {
        int parentARRAY[] = {0, 0};
        vector <int> parent( parentARRAY, parentARRAY+ARRSIZE(parentARRAY) );
        WalkOverATree theObject;
        eq(1, theObject.maxNodesVisited(parent, 3),3);
    }
    {
        int parentARRAY[] = {0, 1, 2, 3};
        vector <int> parent( parentARRAY, parentARRAY+ARRSIZE(parentARRAY) );
        WalkOverATree theObject;
        eq(2, theObject.maxNodesVisited(parent, 2),3);
    }
    {
        int parentARRAY[] = {0,0,0,0,2,4,2,3,1};
        vector <int> parent( parentARRAY, parentARRAY+ARRSIZE(parentARRAY) );
        WalkOverATree theObject;
        eq(3, theObject.maxNodesVisited(parent, 1),2);
    }
    {
        int parentARRAY[] = {0,0,1,2,3,2,3,1,3,0,1,8,6,8,0,5,15,0,9};
        vector <int> parent( parentARRAY, parentARRAY+ARRSIZE(parentARRAY) );
        WalkOverATree theObject;
        eq(4, theObject.maxNodesVisited(parent, 4),5);
    }
    {
        int parentARRAY[] = {0,0,0,1,1,3,5,1,4,5,2,2,10,5,10,10,11,13,8,3,18,15,20,20,23,8,11,26,4};
        vector <int> parent( parentARRAY, parentARRAY+ARRSIZE(parentARRAY) );
        WalkOverATree theObject;
        eq(5, theObject.maxNodesVisited(parent, 26),17);
    }
    {
        int parentARRAY[] = {0, 0, 2, 0}
           ;
        vector <int> parent( parentARRAY, parentARRAY+ARRSIZE(parentARRAY) );
        WalkOverATree theObject;
        eq(6, theObject.maxNodesVisited(parent, 100),5);
    }
    {
        int parentARRAY[] = {0, 0, 2};
        vector <int> parent( parentARRAY, parentARRAY+ARRSIZE(parentARRAY) );
        WalkOverATree theObject;
        eq(7, theObject.maxNodesVisited(parent, 4),4);
    }
	return 0;
}