Пример #1
0
double test2() {
	int t0[] = {750,800,850,900,950};
	vector <int> p0(t0, t0+sizeof(t0)/sizeof(int));
	int t1[] = {800,850,900,950,1000};
	vector <int> p1(t1, t1+sizeof(t1)/sizeof(int));
	DiskSpace * obj = new DiskSpace();
	clock_t start = clock();
	int my_answer = obj->minDrives(p0, p1);
	clock_t end = clock();
	delete obj;
	cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
	int p2 = 5;
	cout <<"Desired answer: " <<endl;
	cout <<"\t" << p2 <<endl;
	cout <<"Your answer: " <<endl;
	cout <<"\t" << my_answer <<endl;
	if (p2 != my_answer) {
		cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
		return -1;
	}
	else {
		cout <<"Match :-)" <<endl <<endl;
		return (double)(end-start)/CLOCKS_PER_SEC;
	}
}
Пример #2
0
double test4() {
	int t0[] = {331,242,384,366,428,114,145,89,381,170,329,190,482,246,2,38,220,290,402,385};
	vector <int> p0(t0, t0+sizeof(t0)/sizeof(int));
	int t1[] = {992,509,997,946,976,873,771,565,693,714,755,878,897,789,969,727,765,521,961,906};
	vector <int> p1(t1, t1+sizeof(t1)/sizeof(int));
	DiskSpace * obj = new DiskSpace();
	clock_t start = clock();
	int my_answer = obj->minDrives(p0, p1);
	clock_t end = clock();
	delete obj;
	cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
	int p2 = 6;
	cout <<"Desired answer: " <<endl;
	cout <<"\t" << p2 <<endl;
	cout <<"Your answer: " <<endl;
	cout <<"\t" << my_answer <<endl;
	if (p2 != my_answer) {
		cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
		return -1;
	}
	else {
		cout <<"Match :-)" <<endl <<endl;
		return (double)(end-start)/CLOCKS_PER_SEC;
	}
}
Пример #3
0
bool do_test(vector<int> used, vector<int> total, int __expected) {
    time_t startClock = clock();
    DiskSpace *instance = new DiskSpace();
    int __result = instance->minDrives(used, total);
    double elapsed = (double)(clock() - startClock) / CLOCKS_PER_SEC;
    delete instance;

    if (__result == __expected) {
        cout << "PASSED!" << " (" << elapsed << " seconds)" << endl;
        return true;
    }
    else {
        cout << "FAILED!" << " (" << elapsed << " seconds)" << endl;
        cout << "           Expected: " << to_string(__expected) << endl;
        cout << "           Received: " << to_string(__result) << endl;
        return false;
    }
}