Esempio n. 1
0
double test1() {
	int t0[] = {16, 16, 16};
	vector <int> p0(t0, t0+sizeof(t0)/sizeof(int));
	IncrementAndDoubling * obj = new IncrementAndDoubling();
	clock_t start = clock();
	int my_answer = obj->getMin(p0);
	clock_t end = clock();
	delete obj;
	cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
	int p1 = 7;
	cout <<"Desired answer: " <<endl;
	cout <<"\t" << p1 <<endl;
	cout <<"Your answer: " <<endl;
	cout <<"\t" << my_answer <<endl;
	if (p1 != my_answer) {
		cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
		return -1;
	}
	else {
		cout <<"Match :-)" <<endl <<endl;
		return (double)(end-start)/CLOCKS_PER_SEC;
	}
}
// BEGIN CUT HERE
void main( int argc, char* argv[] ) {
    {
        int desiredArrayARRAY[] = {2, 1};
        vector <int> desiredArray( desiredArrayARRAY, desiredArrayARRAY+ARRSIZE(desiredArrayARRAY) );
        IncrementAndDoubling theObject;
        eq(0, theObject.getMin(desiredArray),3);
    }
    {
        int desiredArrayARRAY[] = {16, 16, 16};
        vector <int> desiredArray( desiredArrayARRAY, desiredArrayARRAY+ARRSIZE(desiredArrayARRAY) );
        IncrementAndDoubling theObject;
        eq(1, theObject.getMin(desiredArray),7);
    }
    {
        int desiredArrayARRAY[] = {100};
        vector <int> desiredArray( desiredArrayARRAY, desiredArrayARRAY+ARRSIZE(desiredArrayARRAY) );
        IncrementAndDoubling theObject;
        eq(2, theObject.getMin(desiredArray),9);
    }
    {
        int desiredArrayARRAY[] = {0, 0, 1, 0, 1};
        vector <int> desiredArray( desiredArrayARRAY, desiredArrayARRAY+ARRSIZE(desiredArrayARRAY) );
        IncrementAndDoubling theObject;
        eq(3, theObject.getMin(desiredArray),2);
    }
    {
        int desiredArrayARRAY[] = {123, 234, 345, 456, 567, 789};
        vector <int> desiredArray( desiredArrayARRAY, desiredArrayARRAY+ARRSIZE(desiredArrayARRAY) );
        IncrementAndDoubling theObject;
        eq(4, theObject.getMin(desiredArray),40);
    }
    {
        int desiredArrayARRAY[] = {7,5,8,1,8,6,6,5,3,5,5,2,8,9,9,4,6,9,4,4,1,9,9,2,8,4,7,4,8,8,6,3,9,4,3,4,5,1,9,8,3,8,3,7,9,3,8,4,4,7};
        vector <int> desiredArray( desiredArrayARRAY, desiredArrayARRAY+ARRSIZE(desiredArrayARRAY) );
        IncrementAndDoubling theObject;
        eq(5, theObject.getMin(desiredArray),84);
    }
}