[CareerCup] 12.3 Test Move Method in a Chess Game 測試象棋遊戲中的移動方法

來源:互聯網
上載者:User

標籤:

 

12.3 We have the following method used in a chess game: boolean canMoveTo( int x, int y). This method is part of the Piece class and returns whether or not the piece can move to position (x, y). Explain howyou would test this method.

 

這道題讓我們測試象棋遊戲中的移動方法boolean canMoveTo( int x, int y),這個方法判斷能否把棋子移動到(x, y)位置。這類問題通常有兩種測試方法,極值測試和常規測試。

極值測試:我們需要測試一些壞的情況,可能會引起程式崩潰的值,例如

1. 檢測x和y為負值的情況

2. 檢測當x超過棋盤寬度的情況

3. 檢測當y超過棋盤高度的情況

4. 檢測一個滿棋盤

5. 檢測一個空棋盤,或是近似為空白的棋盤

6. 檢測白棋子遠大於黑棋子的情況

7. 檢測黑棋子遠大於白棋子的情況

常規測試:檢測全部情況會非常耗時,所以我們只檢測部分地區。

 

[CareerCup] 12.3 Test Move Method in a Chess Game 測試象棋遊戲中的移動方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.