Added custom constructors for TCosmicExpansion and TStepCounter to simplify test case setup

This commit is contained in:
2023-12-23 20:16:18 +01:00
committed by Stefan Müller
parent 2bb89c952b
commit c3ecaf59fa
4 changed files with 12 additions and 48 deletions

View File

@@ -45,13 +45,6 @@ type
procedure TestPart1;
end;
{ TFactor10CosmicExpansion }
TFactor10CosmicExpansion = class(TCosmicExpansion)
public
function GetExpansionFactor: Integer; override;
end;
{ TCosmicExpansionExampleFactor10TestCase }
TCosmicExpansionExampleFactor10TestCase = class(TExampleEngineBaseTest)
@@ -61,12 +54,6 @@ type
procedure TestPart2;
end;
{ TFactor100CosmicExpansion }
TFactor100CosmicExpansion = class(TCosmicExpansion)
function GetExpansionFactor: Integer; override;
end;
{ TCosmicExpansionExampleFactor100TestCase }
TCosmicExpansionExampleFactor100TestCase = class(TExampleEngineBaseTest)
@@ -107,18 +94,11 @@ begin
AssertEquals(374, FSolver.GetResultPart1);
end;
{ TFactor10CosmicExpansion }
function TFactor10CosmicExpansion.GetExpansionFactor: Integer;
begin
Result := 9;
end;
{ TCosmicExpansionExampleFactor10TestCase }
function TCosmicExpansionExampleFactor10TestCase.CreateSolver: ISolver;
begin
Result := TFactor10CosmicExpansion.Create;
Result := TCosmicExpansion.Create(9);
end;
procedure TCosmicExpansionExampleFactor10TestCase.TestPart2;
@@ -126,18 +106,11 @@ begin
AssertEquals(1030, FSolver.GetResultPart2);
end;
{ TFactor100CosmicExpansion }
function TFactor100CosmicExpansion.GetExpansionFactor: Integer;
begin
Result := 99;
end;
{ TCosmicExpansionExampleFactor100TestCase }
function TCosmicExpansionExampleFactor100TestCase.CreateSolver: ISolver;
begin
Result := TFactor100CosmicExpansion.Create;
Result := TCosmicExpansion.Create(99);
end;
procedure TCosmicExpansionExampleFactor100TestCase.TestPart2;

View File

@@ -61,12 +61,8 @@ end;
{ TStepCounterMax6ExampleTestCase }
function TStepCounterMax6ExampleTestCase.CreateSolver: ISolver;
var
solver: TStepCounter;
begin
solver := TStepCounter.Create;
solver.MaxSteps := 6;
Result := solver;
Result := TStepCounter.Create(6);
end;
procedure TStepCounterMax6ExampleTestCase.TestPart1;