示例#1
0
int test54() {
    vector<string> cards = {"JS"};
    TheBlackJackDivTwo* pObj = new TheBlackJackDivTwo();
    clock_t start = clock();
    int result = pObj->score(cards);
    clock_t end = clock();
    delete pObj;
    int expected = 10;
    if(result == expected) {
        cout << "Test Case 54: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 54: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
示例#2
0
int test45() {
    vector<string> cards = {"3D", "2D", "3C", "4S", "4D", "3S", "3H", "2S", "4H", "4C", "2C", "2H"};
    TheBlackJackDivTwo* pObj = new TheBlackJackDivTwo();
    clock_t start = clock();
    int result = pObj->score(cards);
    clock_t end = clock();
    delete pObj;
    int expected = 36;
    if(result == expected) {
        cout << "Test Case 45: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 45: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
示例#3
0
int test46() {
    vector<string> cards = {"8S", "KS", "JC", "TS", "QC", "TC", "TD", "QD", "7H", "2H", "8D", "6H", "TH", "KD", "6D", "3C", "KH", "5S", "2S", "9D", "2D", "9H", "QH", "4H", "5H", "2C", "8C", "9C", "3D", "5C", "JH", "6C", "JD", "JS", "KC", "3H", "3S", "4D", "7D", "7S", "8H", "4C", "7C", "4S", "9S", "QS", "5D", "6S"};
    TheBlackJackDivTwo* pObj = new TheBlackJackDivTwo();
    clock_t start = clock();
    int result = pObj->score(cards);
    clock_t end = clock();
    delete pObj;
    int expected = 336;
    if(result == expected) {
        cout << "Test Case 46: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 46: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
示例#4
0
int test40() {
    vector<string> cards = {"JS", "8S", "AC", "7C", "9C", "TH", "KH", "4D", "5S", "6S", "QD", "TS", "4S", "8D", "2S", "6D", "3S", "7S", "9D", "2H", "AD", "2D", "QS", "JD", "9S", "KC"};
    TheBlackJackDivTwo* pObj = new TheBlackJackDivTwo();
    clock_t start = clock();
    int result = pObj->score(cards);
    clock_t end = clock();
    delete pObj;
    int expected = 193;
    if(result == expected) {
        cout << "Test Case 40: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 40: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
示例#5
0
int test42() {
    vector<string> cards = {"9C", "4D", "QH", "8S", "TS", "2S", "6S", "KD", "3D", "6C", "TH", "QC", "JH", "TD", "AS", "3S", "KH", "AH", "QS", "5D", "9S", "AD", "3C", "8C", "7S", "5S", "4S"};
    TheBlackJackDivTwo* pObj = new TheBlackJackDivTwo();
    clock_t start = clock();
    int result = pObj->score(cards);
    clock_t end = clock();
    delete pObj;
    int expected = 205;
    if(result == expected) {
        cout << "Test Case 42: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 42: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
示例#6
0
int test19() {
    vector<string> cards = {"7D", "5C", "8S", "AC", "4D", "5D", "5S", "AD", "4S", "AH", "3D", "2C", "8C", "2S", "JC", "QD", "KH", "KS", "3H", "8D", "3C", "QH", "2D", "JD", "QS", "9H", "2H"};
    TheBlackJackDivTwo* pObj = new TheBlackJackDivTwo();
    clock_t start = clock();
    int result = pObj->score(cards);
    clock_t end = clock();
    delete pObj;
    int expected = 183;
    if(result == expected) {
        cout << "Test Case 19: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 19: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
示例#7
0
int test18() {
    vector<string> cards = {"2D", "AH", "9H", "QS", "8S", "7D", "JS", "5S", "8D", "9S", "2C"};
    TheBlackJackDivTwo* pObj = new TheBlackJackDivTwo();
    clock_t start = clock();
    int result = pObj->score(cards);
    clock_t end = clock();
    delete pObj;
    int expected = 81;
    if(result == expected) {
        cout << "Test Case 18: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 18: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
示例#8
0
int test13() {
    vector<string> cards = {"7S", "AD", "2S", "QC", "9S", "KD", "5D", "3H", "3D", "2C", "TC", "KH", "TS", "9D", "KS"};
    TheBlackJackDivTwo* pObj = new TheBlackJackDivTwo();
    clock_t start = clock();
    int result = pObj->score(cards);
    clock_t end = clock();
    delete pObj;
    int expected = 111;
    if(result == expected) {
        cout << "Test Case 13: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 13: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
示例#9
0
int test9() {
    vector<string> cards = {"7S", "8H", "KD", "5S", "KS", "6C", "AS", "2D", "6S", "3C", "KC", "9D", "4C"};
    TheBlackJackDivTwo* pObj = new TheBlackJackDivTwo();
    clock_t start = clock();
    int result = pObj->score(cards);
    clock_t end = clock();
    delete pObj;
    int expected = 91;
    if(result == expected) {
        cout << "Test Case 9: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 9: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
示例#10
0
double test2() {
	string t0[] = {"AS", "AD", "AH", "AC"};
	vector <string> p0(t0, t0+sizeof(t0)/sizeof(string));
	TheBlackJackDivTwo * obj = new TheBlackJackDivTwo();
	clock_t start = clock();
	int my_answer = obj->score(p0);
	clock_t end = clock();
	delete obj;
	cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
	int p1 = 44;
	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;
	}
}