From 47d37e07fdc4b1368bb227008d7a1f422e97b88a Mon Sep 17 00:00:00 2001 From: Matthias Rahlf Date: Mon, 25 May 2015 19:03:48 +0200 Subject: [PATCH 1/2] ignore files created by cmake --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 7b654aa3..97a69ba7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,7 @@ tmp bin/configlet bin/configlet.exe +CMakeCache.txt +CMakeFiles/ +Makefile +cmake_install.cmake From 4703a6dfedfd54b43ba105db602e69d25c8a3845 Mon Sep 17 00:00:00 2001 From: Matthias Rahlf Date: Mon, 25 May 2015 19:05:27 +0200 Subject: [PATCH 2/2] added missing test cases --- queen-attack/example.cpp | 3 ++- queen-attack/queen_attack_test.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/queen-attack/example.cpp b/queen-attack/example.cpp index 73290e95..edda0052 100644 --- a/queen-attack/example.cpp +++ b/queen-attack/example.cpp @@ -41,7 +41,8 @@ bool chess_board::can_attack() const { return (white_.first == black_.first) || (white_.second == black_.second) - || ((white_.first - black_.first) == (white_.second - black_.second)); + || ((white_.first - black_.first) == (white_.second - black_.second)) + || ((white_.first - black_.first) == (black_.second - white_.second)); } } diff --git a/queen-attack/queen_attack_test.cpp b/queen-attack/queen_attack_test.cpp index e45fa740..7f2a434d 100644 --- a/queen-attack/queen_attack_test.cpp +++ b/queen-attack/queen_attack_test.cpp @@ -102,4 +102,18 @@ BOOST_AUTO_TEST_CASE(queens_can_attack_yet_another_diagonally) BOOST_REQUIRE(board.can_attack()); } + +BOOST_AUTO_TEST_CASE(queens_can_attack_on_the_nw_so_diagonal) +{ + const queen_attack::chess_board board{std::make_pair(1, 6), std::make_pair(6, 1)}; + + BOOST_REQUIRE(board.can_attack()); +} + +BOOST_AUTO_TEST_CASE(queens_cannot_attack_if_not_on_same_row_column_or_diagonal) +{ + const queen_attack::chess_board board{std::make_pair(1, 1), std::make_pair(3, 7)}; + + BOOST_REQUIRE(!board.can_attack()); +} #endif