Skip to content

v3.0

Choose a tag to compare

@pBouillon pBouillon released this 02 Dec 09:37
· 6 commits to main since this release
ef16fbd

Dependencies

The template now targets .NET 8

Parser testing

You can now test your parsing.

This testing feature allows you to verify the correctness of the ParseInput method by comparing its output with manually provided raw input. It's completely optional, so you can choose to use it based on your preferences.

If you would like to, define the RawInput property along with your Input in your Example:

public override Puzzle PartOne => new()
{
    Example = new()
    {
        // 👇 Since this is defined, a test will run to check if `ParseInput(RawInput)` is equal to `Input`
        RawInput = ["1", "2", "3"],
        Input = [1, 2, 3],
        Result = 3,
    },
    Solution = 5,
};

Since the example might change from one part to the other, the RawInput is defined in each part instead of on the puzzle-level

If ShouldSkipTest is set to true, or if RawInput is not specified or an empty array, no test will be run against Solver.ParseInput:

public override Puzzle PartOne => new()
{
    Example = new()
    {
        // 👇 `RawInput` is empty, no test will be run
        RawInput = [],
        Input = [1, 2, 3],
        Result = 3,
    },
    Solution = 5,
};
public override Puzzle PartTwo => new()
{
    // 👇 `RawInput` is not set, no test will be run
    Example = new()
    {
        Input = [1, 2, 3],
        Result = 6,
    },
    Solution = 15,
};