Added test cases for day 21, part 2

This commit is contained in:
Stefan Müller 2023-12-21 21:36:26 +01:00 committed by Stefan Müller
parent 4e28a7a4c2
commit 2f7e95b5c9
1 changed files with 158 additions and 5 deletions

View File

@ -35,13 +35,76 @@ type
procedure TestPart1;
end;
{ TStepCounterMax6ExampleTestCase }
{ TStepCounterMaxStepsExampleTestCase }
TStepCounterMax6ExampleTestCase = class(TExampleEngineBaseTest)
TStepCounterMaxStepsExampleTestCase = class(TExampleEngineBaseTest)
protected
function CreateSolver: ISolver; override;
function GetMaxSteps: Integer; virtual; abstract;
end;
{ TStepCounterMax6ExampleTestCase }
TStepCounterMax6ExampleTestCase = class(TStepCounterMaxStepsExampleTestCase)
protected
function GetMaxSteps: Integer; override;
published
procedure TestPart1;
procedure TestPart2;
end;
{ TStepCounterMax10ExampleTestCase }
TStepCounterMax10ExampleTestCase = class(TStepCounterMaxStepsExampleTestCase)
protected
function GetMaxSteps: Integer; override;
published
procedure TestPart2;
end;
{ TStepCounterMax50ExampleTestCase }
TStepCounterMax50ExampleTestCase = class(TStepCounterMaxStepsExampleTestCase)
protected
function GetMaxSteps: Integer; override;
published
procedure TestPart2;
end;
{ TStepCounterMax100ExampleTestCase }
TStepCounterMax100ExampleTestCase = class(TStepCounterMaxStepsExampleTestCase)
protected
function GetMaxSteps: Integer; override;
published
procedure TestPart2;
end;
{ TStepCounterMax500ExampleTestCase }
TStepCounterMax500ExampleTestCase = class(TStepCounterMaxStepsExampleTestCase)
protected
function GetMaxSteps: Integer; override;
published
procedure TestPart2;
end;
{ TStepCounterMax1000ExampleTestCase }
TStepCounterMax1000ExampleTestCase = class(TStepCounterMaxStepsExampleTestCase)
protected
function GetMaxSteps: Integer; override;
published
procedure TestPart2;
end;
{ TStepCounterMax5000ExampleTestCase }
TStepCounterMax5000ExampleTestCase = class(TStepCounterMaxStepsExampleTestCase)
protected
function GetMaxSteps: Integer; override;
published
procedure TestPart2;
end;
implementation
@ -58,25 +121,115 @@ begin
AssertEquals(3809, FSolver.GetResultPart1);
end;
{ TStepCounterMax6ExampleTestCase }
{ TStepCounterMaxStepsExampleTestCase }
function TStepCounterMax6ExampleTestCase.CreateSolver: ISolver;
function TStepCounterMaxStepsExampleTestCase.CreateSolver: ISolver;
var
solver: TStepCounter;
begin
solver := TStepCounter.Create;
solver.MaxSteps := 6;
solver.MaxSteps := GetMaxSteps;
Result := solver;
end;
{ TStepCounterMax6ExampleTestCase }
function TStepCounterMax6ExampleTestCase.GetMaxSteps: Integer;
begin
Result := 6;
end;
procedure TStepCounterMax6ExampleTestCase.TestPart1;
begin
AssertEquals(16, FSolver.GetResultPart1);
end;
procedure TStepCounterMax6ExampleTestCase.TestPart2;
begin
AssertEquals(16, FSolver.GetResultPart2);
end;
{ TStepCounterMax10ExampleTestCase }
function TStepCounterMax10ExampleTestCase.GetMaxSteps: Integer;
begin
Result := 10;
end;
procedure TStepCounterMax10ExampleTestCase.TestPart2;
begin
AssertEquals(50, FSolver.GetResultPart2);
end;
{ TStepCounterMax50ExampleTestCase }
function TStepCounterMax50ExampleTestCase.GetMaxSteps: Integer;
begin
Result := 50;
end;
procedure TStepCounterMax50ExampleTestCase.TestPart2;
begin
AssertEquals(1594, FSolver.GetResultPart2);
end;
{ TStepCounterMax100ExampleTestCase }
function TStepCounterMax100ExampleTestCase.GetMaxSteps: Integer;
begin
Result := 100;
end;
procedure TStepCounterMax100ExampleTestCase.TestPart2;
begin
AssertEquals(6536, FSolver.GetResultPart2);
end;
{ TStepCounterMax500ExampleTestCase }
function TStepCounterMax500ExampleTestCase.GetMaxSteps: Integer;
begin
Result := 500;
end;
procedure TStepCounterMax500ExampleTestCase.TestPart2;
begin
AssertEquals(167004, FSolver.GetResultPart2);
end;
{ TStepCounterMax1000ExampleTestCase }
function TStepCounterMax1000ExampleTestCase.GetMaxSteps: Integer;
begin
Result := 1000;
end;
procedure TStepCounterMax1000ExampleTestCase.TestPart2;
begin
AssertEquals(668697, FSolver.GetResultPart2);
end;
{ TStepCounterMax5000ExampleTestCase }
function TStepCounterMax5000ExampleTestCase.GetMaxSteps: Integer;
begin
Result := 5000;
end;
procedure TStepCounterMax5000ExampleTestCase.TestPart2;
begin
AssertEquals(16733044, FSolver.GetResultPart2);
end;
initialization
RegisterTest(TStepCounterFullDataTestCase);
RegisterTest(TStepCounterMax6ExampleTestCase);
RegisterTest(TStepCounterMax10ExampleTestCase);
RegisterTest(TStepCounterMax50ExampleTestCase);
RegisterTest(TStepCounterMax100ExampleTestCase);
RegisterTest(TStepCounterMax500ExampleTestCase);
RegisterTest(TStepCounterMax1000ExampleTestCase);
RegisterTest(TStepCounterMax5000ExampleTestCase);
end.