{ "exercise": "queen-attack", "version": "2.0.0", "comments": [ "Testing invalid positions will vary by language. The expected", "value of -1 is there to indicate some sort of failure should", "occur, while a 0 means no failure.", "Some languages implement tests beyond this set, such as checking", "for two pieces being placed on the same position, representing", "the board graphically, or using standard chess notation. Those", "tests can be offered as extra credit" ], "cases": [ { "description": "Test creation of Queens with valid and invalid positions", "cases": [ { "description": "queen with a valid position", "property": "create", "queen": { "position": { "row": 2, "column": 2 } }, "expected": 0 }, { "description": "queen must have positive row", "property": "create", "queen": { "position": { "row": -2, "column": 2 } }, "expected": -1 }, { "description": "queen must have row on board", "property": "create", "queen": { "position": { "row": 8, "column": 4 } }, "expected": -1 }, { "description": "queen must have positive column", "property": "create", "queen": { "position": { "row": 2, "column": -2 } }, "expected": -1 }, { "description": "queen must have column on board", "property": "create", "queen": { "position": { "row": 4, "column": 8 } }, "expected": -1 } ] }, { "description": "Test the ability of one queen to attack another", "cases": [ { "description": "can not attack", "property": "canAttack", "white_queen": { "position": { "row": 2, "column": 4 } }, "black_queen": { "position": { "row": 6, "column": 6 } }, "expected": false }, { "description": "can attack on same row", "property": "canAttack", "white_queen": { "position": { "row": 2, "column": 4 } }, "black_queen": { "position": { "row": 2, "column": 6 } }, "expected": true }, { "description": "can attack on same column", "property": "canAttack", "white_queen": { "position": { "row": 4, "column": 5 } }, "black_queen": { "position": { "row": 2, "column": 5 } }, "expected": true }, { "description": "can attack on first diagonal", "property": "canAttack", "white_queen": { "position": { "row": 2, "column": 2 } }, "black_queen": { "position": { "row": 0, "column": 4 } }, "expected": true }, { "description": "can attack on second diagonal", "property": "canAttack", "white_queen": { "position": { "row": 2, "column": 2 } }, "black_queen": { "position": { "row": 3, "column": 1 } }, "expected": true }, { "description": "can attack on third diagonal", "property": "canAttack", "white_queen": { "position": { "row": 2, "column": 2 } }, "black_queen": { "position": { "row": 1, "column": 1 } }, "expected": true }, { "description": "can attack on fourth diagonal", "property": "canAttack", "white_queen": { "position": { "row": 2, "column": 2 } }, "black_queen": { "position": { "row": 5, "column": 5 } }, "expected": true } ] } ] }