AdventOfCode2023/tests/UPipeMazeTestCases.pas

329 lines
6.8 KiB
Plaintext

{
Solutions to the Advent Of Code.
Copyright (C) 2023 Stefan Müller
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
}
unit UPipeMazeTestCases;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, fpcunit, testregistry, USolver, UBaseTestCases, UPipeMaze;
type
{ TPipeMazeFullDataTestCase }
TPipeMazeFullDataTestCase = class(TEngineBaseTest)
protected
function CreateSolver: ISolver; override;
published
procedure TestPart1;
procedure TestPart2;
end;
{ TPipeMazeExampleTestCase }
TPipeMazeExampleTestCase = class(TExampleEngineBaseTest)
protected
function CreateSolver: ISolver; override;
published
procedure TestPart1;
end;
{ TExample2PipeMaze }
TExample2PipeMaze = class(TPipeMaze)
function GetDataFileName: string; override;
end;
{ TPipeMazeExample2TestCase }
TPipeMazeExample2TestCase = class(TExampleEngineBaseTest)
protected
function CreateSolver: ISolver; override;
published
procedure TestPart1;
end;
{ TExample3PipeMaze }
TExample3PipeMaze = class(TPipeMaze)
function GetDataFileName: string; override;
end;
{ TPipeMazeExample3TestCase }
TPipeMazeExample3TestCase = class(TExampleEngineBaseTest)
protected
function CreateSolver: ISolver; override;
published
procedure TestPart1;
end;
{ TExample4PipeMaze }
TExample4PipeMaze = class(TPipeMaze)
function GetDataFileName: string; override;
end;
{ TPipeMazeExample4TestCase }
TPipeMazeExample4TestCase = class(TExampleEngineBaseTest)
protected
function CreateSolver: ISolver; override;
published
procedure TestPart1;
end;
{ TExample5PipeMaze }
TExample5PipeMaze = class(TPipeMaze)
function GetDataFileName: string; override;
end;
{ TPipeMazeExample5TestCase }
TPipeMazeExample5TestCase = class(TExampleEngineBaseTest)
protected
function CreateSolver: ISolver; override;
published
procedure TestPart2;
end;
{ TExample6PipeMaze }
TExample6PipeMaze = class(TPipeMaze)
function GetDataFileName: string; override;
end;
{ TPipeMazeExample6TestCase }
TPipeMazeExample6TestCase = class(TExampleEngineBaseTest)
protected
function CreateSolver: ISolver; override;
published
procedure TestPart2;
end;
{ TExample7PipeMaze }
TExample7PipeMaze = class(TPipeMaze)
function GetDataFileName: string; override;
end;
{ TPipeMazeExample7TestCase }
TPipeMazeExample7TestCase = class(TExampleEngineBaseTest)
protected
function CreateSolver: ISolver; override;
published
procedure TestPart2;
end;
{ TExample8PipeMaze }
TExample8PipeMaze = class(TPipeMaze)
function GetDataFileName: string; override;
end;
{ TPipeMazeExample8TestCase }
TPipeMazeExample8TestCase = class(TExampleEngineBaseTest)
protected
function CreateSolver: ISolver; override;
published
procedure TestPart2;
end;
implementation
{ TPipeMazeFullDataTestCase }
function TPipeMazeFullDataTestCase.CreateSolver: ISolver;
begin
Result := TPipeMaze.Create;
end;
procedure TPipeMazeFullDataTestCase.TestPart1;
begin
AssertEquals(7097, FSolver.GetResultPart1);
end;
procedure TPipeMazeFullDataTestCase.TestPart2;
begin
AssertEquals(355, FSolver.GetResultPart2);
end;
{ TPipeMazeExampleTestCase }
function TPipeMazeExampleTestCase.CreateSolver: ISolver;
begin
Result := TPipeMaze.Create;
end;
procedure TPipeMazeExampleTestCase.TestPart1;
begin
AssertEquals(4, FSolver.GetResultPart1);
end;
{ TExample2PipeMaze }
function TExample2PipeMaze.GetDataFileName: string;
begin
Result := 'pipe_maze2.txt';
end;
{ TPipeMazeExample2TestCase }
function TPipeMazeExample2TestCase.CreateSolver: ISolver;
begin
Result := TExample2PipeMaze.Create;
end;
procedure TPipeMazeExample2TestCase.TestPart1;
begin
AssertEquals(4, FSolver.GetResultPart1);
end;
{ TExample3PipeMaze }
function TExample3PipeMaze.GetDataFileName: string;
begin
Result := 'pipe_maze3.txt';
end;
{ TPipeMazeExample3TestCase }
function TPipeMazeExample3TestCase.CreateSolver: ISolver;
begin
Result := TExample3PipeMaze.Create;
end;
procedure TPipeMazeExample3TestCase.TestPart1;
begin
AssertEquals(8, FSolver.GetResultPart1);
end;
{ TExample4PipeMaze }
function TExample4PipeMaze.GetDataFileName: string;
begin
Result := 'pipe_maze4.txt';
end;
{ TPipeMazeExample4TestCase }
function TPipeMazeExample4TestCase.CreateSolver: ISolver;
begin
Result := TExample4PipeMaze.Create;
end;
procedure TPipeMazeExample4TestCase.TestPart1;
begin
AssertEquals(8, FSolver.GetResultPart1);
end;
{ TExample5PipeMaze }
function TExample5PipeMaze.GetDataFileName: string;
begin
Result := 'pipe_maze5.txt';
end;
{ TPipeMazeExample5TestCase }
function TPipeMazeExample5TestCase.CreateSolver: ISolver;
begin
Result := TExample5PipeMaze.Create;
end;
procedure TPipeMazeExample5TestCase.TestPart2;
begin
AssertEquals(4, FSolver.GetResultPart2);
end;
{ TExample6PipeMaze }
function TExample6PipeMaze.GetDataFileName: string;
begin
Result := 'pipe_maze6.txt';
end;
{ TPipeMazeExample6TestCase }
function TPipeMazeExample6TestCase.CreateSolver: ISolver;
begin
Result := TExample6PipeMaze.Create;
end;
procedure TPipeMazeExample6TestCase.TestPart2;
begin
AssertEquals(4, FSolver.GetResultPart2);
end;
{ TExample7PipeMaze }
function TExample7PipeMaze.GetDataFileName: string;
begin
Result := 'pipe_maze7.txt';
end;
{ TPipeMazeExample7TestCase }
function TPipeMazeExample7TestCase.CreateSolver: ISolver;
begin
Result := TExample7PipeMaze.Create;
end;
procedure TPipeMazeExample7TestCase.TestPart2;
begin
AssertEquals(8, FSolver.GetResultPart2);
end;
{ TExample8PipeMaze }
function TExample8PipeMaze.GetDataFileName: string;
begin
Result := 'pipe_maze8.txt';
end;
{ TPipeMazeExample8TestCase }
function TPipeMazeExample8TestCase.CreateSolver: ISolver;
begin
Result := TExample8PipeMaze.Create;
end;
procedure TPipeMazeExample8TestCase.TestPart2;
begin
AssertEquals(10, FSolver.GetResultPart2);
end;
initialization
RegisterTest(TPipeMazeFullDataTestCase);
RegisterTest(TPipeMazeExampleTestCase);
RegisterTest(TPipeMazeExample2TestCase);
RegisterTest(TPipeMazeExample3TestCase);
RegisterTest(TPipeMazeExample4TestCase);
RegisterTest(TPipeMazeExample5TestCase);
RegisterTest(TPipeMazeExample6TestCase);
RegisterTest(TPipeMazeExample7TestCase);
RegisterTest(TPipeMazeExample8TestCase);
end.