"Land grab in space" has insufficient test coverage for the plot with longest side

It is currently possible to “pass” the tests for finding the plot with longest side by just returning the 1st plot.

I propose to add these 2 tests:

    [Fact]
    [Task(4)]
    public void GetLongestSideReverseInsertionOrder()
    {
        var ch = new ClaimsHandler();
        var longer = CreatePlot(new Coord(10, 1), new Coord(20, 1), new Coord(10, 2), new Coord(20, 2));
        var shorter = CreatePlot(new Coord(1, 1), new Coord(2, 1), new Coord(1, 2), new Coord(2, 2));
        ch.StakeClaim(shorter);
        ch.StakeClaim(longer);
        Assert.Equal(longer, ch.GetClaimWithLongestSide());
    }

    [Fact]
    [Task(4)]
    public void GetLongestSideDiagonal1()
    {
        var ch = new ClaimsHandler();
        // Bottom left, bottom right, top left, top right. The longest side is 10, diagonal is >14
        var shorter = CreatePlot(new Coord(0, 0), new Coord(0, 10), new Coord(10, 0), new Coord(10, 10));
        // Bottom left, top left, top right, bottom right, longest side 11
        var longer = CreatePlot(new Coord(0, 0), new Coord(11, 0), new Coord(11, 11), new Coord(0, 11));
        ch.StakeClaim(shorter);
        ch.StakeClaim(longer);
        Assert.Equal(longer, ch.GetClaimWithLongestSide());
    }

What language is this? :slight_smile:

Should have mentioned - I’m talking about C# in particular. I don’t know if other languages also have this problem.

The info in the Screenshot is what they are refering too. I was going through my old Solutions and found this Problem aswell.

In the C# track, exercise " Land Grab in Space" You can solve the last task by simply returning the First element of the HashSet. That’s probably why my old (commentet out) solution just early returned in the foreach loop, but I made it more Clear by using the First() Method on the HashSet. Simply needs better test cases.

1 Like

(cc @ErikSchierboom)

Agreed. Would you be willing to submit a PR?

Sure.

1 Like