void testCase3() { string dice_[] = {"1d2", "2d2", "4d2", "6d2", "8d2"}; vector<string> dice(dice_, dice_ + (sizeof(dice_) / sizeof(dice_[0]))); int expected__[] = {21, 42, 31}; vector<int> expected_(expected__, expected__ + (sizeof(expected__) / sizeof(expected__[0]))); assertEquals(3, expected_, solution.dieRolls(dice)); }
void testCase1() { string dice_[] = {"3d4", "1d6"}; vector<string> dice(dice_, dice_ + (sizeof(dice_) / sizeof(dice_[0]))); int expected__[] = {4, 18, 11}; vector<int> expected_(expected__, expected__ + (sizeof(expected__) / sizeof(expected__[0]))); assertEquals(1, expected_, solution.dieRolls(dice)); }
void testCase2() { string dice_[] = {"6d5", "10d10", "10d20"}; vector<string> dice(dice_, dice_ + (sizeof(dice_) / sizeof(dice_[0]))); int expected__[] = {26, 330, 178}; vector<int> expected_(expected__, expected__ + (sizeof(expected__) / sizeof(expected__[0]))); assertEquals(2, expected_, solution.dieRolls(dice)); }
double test1() { string t0[] = {"3d4","1d6"}; vector <string> p0(t0, t0+sizeof(t0)/sizeof(string)); RPG * obj = new RPG(); clock_t start = clock(); vector <int> my_answer = obj->dieRolls(p0); clock_t end = clock(); delete obj; cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl; int t1[] = { 4, 18, 11 }; vector <int> p1(t1, t1+sizeof(t1)/sizeof(int)); cout <<"Desired answer: " <<endl; cout <<"\t{ "; if (p1.size() > 0) { cout <<p1[0]; for (int i=1; i<p1.size(); i++) cout <<", " <<p1[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 != p1) { cout <<"DOESN'T MATCH!!!!" <<endl <<endl; return -1; } else { cout <<"Match :-)" <<endl <<endl; return (double)(end-start)/CLOCKS_PER_SEC; } }