Added tests for BinomialCoefficients global var
This commit is contained in:
parent
f61abcb9c3
commit
3008efc4ae
|
@ -47,6 +47,15 @@ type
|
||||||
procedure TestRangeError;
|
procedure TestRangeError;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TBinomialCoefficientsGlobalTestCase }
|
||||||
|
|
||||||
|
TBinomialCoefficientsGlobalTestCase = class(TTestCase)
|
||||||
|
private
|
||||||
|
procedure AssertEqualsCalculation(const AN, AK, AExpected: Cardinal);
|
||||||
|
published
|
||||||
|
procedure TestCombined;
|
||||||
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{ TBinomialCoefficientsTestCase }
|
{ TBinomialCoefficientsTestCase }
|
||||||
|
@ -131,8 +140,23 @@ begin
|
||||||
AssertException(ERangeError, @RunRangeError);
|
AssertException(ERangeError, @RunRangeError);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TBinomialCoefficientsGlobalTestCase }
|
||||||
|
|
||||||
|
procedure TBinomialCoefficientsGlobalTestCase.AssertEqualsCalculation(const AN, AK, AExpected: Cardinal);
|
||||||
|
begin
|
||||||
|
AssertEquals('Unexpected calculation result', AExpected, BinomialCoefficients.Get(AN, AK));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBinomialCoefficientsGlobalTestCase.TestCombined;
|
||||||
|
begin
|
||||||
|
AssertEqualsCalculation(5, 1, 5);
|
||||||
|
AssertEqualsCalculation(8, 4, 70);
|
||||||
|
AssertEqualsCalculation(3, 1, 3);
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
|
||||||
RegisterTest('Helper', TBinomialCoefficientsTestCase);
|
RegisterTest('Helper.TBinomialCoefficientCache', TBinomialCoefficientsTestCase);
|
||||||
|
RegisterTest('Helper.TBinomialCoefficientCache', TBinomialCoefficientsGlobalTestCase);
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue