示例#1
0
int main()
{
    GeneralChess g;
    vector<string> v{"-1000,1000", "-999,999", "-999,997"};
    vector<string>ans = g.attackPositions(v);
    for(int i=0; i<ans.size(); ++i)
    {
        cout<<ans[i]<<"\t";
    }
    return 0;
}
示例#2
0
int test31() {
    vector<string> pieces = {"-3,0"};
    GeneralChess* pObj = new GeneralChess();
    clock_t start = clock();
    vector<string> result = pObj->attackPositions(pieces);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"-5,-1", "-5,1", "-4,-2", "-4,2", "-2,-2", "-2,2", "-1,-1", "-1,1"};
    if(result == expected) {
        cout << "Test Case 31: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 31: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
示例#3
0
int test3() {
    vector<string> pieces = {"-1000,1000", "-999,999", "-999,997"};
    GeneralChess* pObj = new GeneralChess();
    clock_t start = clock();
    vector<string> result = pObj->attackPositions(pieces);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"-1001,998"};
    if(result == expected) {
        cout << "Test Case 3: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 3: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
示例#4
0
int test30() {
    vector<string> pieces = {"42,5"};
    GeneralChess* pObj = new GeneralChess();
    clock_t start = clock();
    vector<string> result = pObj->attackPositions(pieces);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"40,4", "40,6", "41,3", "41,7", "43,3", "43,7", "44,4", "44,6"};
    if(result == expected) {
        cout << "Test Case 30: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 30: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}