int main() { int array1[] = {20, 20}; int array2[] = {5, 8}; int array3[] = {0}; int array4[] = {1}; vector <int> capacities(array1, array1 + (sizeof(array1)/sizeof(int))); vector <int> bottles(array2, array2 + (sizeof(array2)/sizeof(int))); vector <int> fromId(array3, array3 + (sizeof(array3)/sizeof(int))); vector <int> toId(array4, array4 + (sizeof(array4)/sizeof(int))); KiwiJuiceEasy test; test.thePouring(capacities, bottles, fromId, toId); return 0; }
double test1() { int t0[] = {10, 10}; vector <int> p0(t0, t0+sizeof(t0)/sizeof(int)); int t1[] = {5, 8}; vector <int> p1(t1, t1+sizeof(t1)/sizeof(int)); int t2[] = {0}; vector <int> p2(t2, t2+sizeof(t2)/sizeof(int)); int t3[] = {1}; vector <int> p3(t3, t3+sizeof(t3)/sizeof(int)); KiwiJuiceEasy * obj = new KiwiJuiceEasy(); clock_t start = clock(); vector <int> my_answer = obj->thePouring(p0, p1, p2, p3); clock_t end = clock(); delete obj; cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl; int t4[] = {3, 10 }; vector <int> p4(t4, t4+sizeof(t4)/sizeof(int)); cout <<"Desired answer: " <<endl; cout <<"\t{ "; if (p4.size() > 0) { cout <<p4[0]; for (int i=1; i<p4.size(); i++) cout <<", " <<p4[i]; cout <<" }" <<endl; } else cout <<"}" <<endl; cout <<endl <<"Your answer: " <<endl; cout <<"\t{ "; if (my_answer.size() > 0) { cout <<my_answer[0]; for (int i=1; i<my_answer.size(); i++) cout <<", " <<my_answer[i]; cout <<" }" <<endl; } else cout <<"}" <<endl; if (my_answer != p4) { cout <<"DOESN'T MATCH!!!!" <<endl <<endl; return -1; } else { cout <<"Match :-)" <<endl <<endl; return (double)(end-start)/CLOCKS_PER_SEC; } }
bool do_test(vector<int> capacities, vector<int> bottles, vector<int> fromId, vector<int> toId, vector<int> __expected) { time_t startClock = clock(); KiwiJuiceEasy *instance = new KiwiJuiceEasy(); vector<int> __result = instance->thePouring(capacities, bottles, fromId, toId); 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; } }