AdventOfCode2023/tests/UPipeMazeTestCases.pas

189 lines
4.0 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;
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(-1, 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;
initialization
RegisterTest(TPipeMazeFullDataTestCase);
RegisterTest(TPipeMazeExampleTestCase);
RegisterTest(TPipeMazeExample2TestCase);
RegisterTest(TPipeMazeExample3TestCase);
RegisterTest(TPipeMazeExample4TestCase);
end.