Queen Attack Duplicate Diagonal Test

Two of the tests in Queen Attack check the same diagonal.
Specifically, tests for diagonals “three” and “four” are the same direction.

Suggestion: change test for diagonal “three” to use (2, 2) and (3, 3) instead of (2, 2) and (1, 1).

As a check, I was able to make all tests pass even with only three of the four diagonals covered by my code.
Making the suggested change to the test requires the fourth check to make them all pass.

That sounds like a good catch.

Could you show us the code that incorrectly passes with the current test cases and no longer passes with the new test case? That will make it extremely easy to approve a PR on the problem-specs repository which will propagate this change to all tracks that implement it.

In the canonical tests, I think is is “can attack on first diagonal” and “can attack on second diagonal” that check the same diagonal.

Diagonals “third” and “fourth” are parallel but distinct.

I hope a published iteration is a good demonstration: gjbianco's solution for Queen Attack in C on Exercism

In particular, note the commented lines 22-23.
If I change the test case (locally) to my suggestion, the tests no longer pass without uncommenting those lines.

EDIT: once given the go-ahead, I’m more than happy to open a PR.

1 Like

I have double-checked the values in the canonical tests that you linked and it still seems like tests three and four are the duplicates.

If I arrange the grid as 0-7 rows with 0-7 columns, top-down and left-to-right respectively, “third diagonal” checks the northwest diagonal and so does “fourth diagonal”.