Пример #1
0
	public void testMultipleQueens() {
		XYLocation loc1 = new XYLocation(3, 3);
		board.addQueenAt(loc1);
		Assert.assertEquals(1, board.getNumberOfAttacksOn(loc1.right()));

		board.addQueenAt(loc1.right().right());
		Assert.assertEquals(1, board.getNumberOfAttacksOn(loc1));
		Assert.assertEquals(2, board.getNumberOfAttacksOn(loc1.right()));

		board.addQueenAt(loc1.right().down());
		Assert.assertEquals(2, board.getNumberOfAttacksOn(loc1));
		Assert.assertEquals(3, board.getNumberOfAttacksOn(loc1.right()));
		Assert
				.assertEquals(2, board.getNumberOfAttacksOn(loc1.right()
						.right()));
	}
Пример #2
0
	public void testSimpleHorizontalAttack() {
		XYLocation loc = new XYLocation(0, 0);
		board.addQueenAt(loc);
		Assert.assertEquals(0, board.getNumberOfAttacksOn(loc));
		Assert
				.assertEquals(1, board
						.getNumberOfAttacksOn(new XYLocation(1, 0)));
		Assert.assertEquals(1, board.getNumberOfAttacksOn(loc.right()));
		Assert
				.assertEquals(1, board
						.getNumberOfAttacksOn(new XYLocation(7, 0)));
	}