Added tests for BinomialCoefficients global var
This commit is contained in:
parent
f61abcb9c3
commit
3008efc4ae
|
@ -47,6 +47,15 @@ type
|
|||
procedure TestRangeError;
|
||||
end;
|
||||
|
||||
{ TBinomialCoefficientsGlobalTestCase }
|
||||
|
||||
TBinomialCoefficientsGlobalTestCase = class(TTestCase)
|
||||
private
|
||||
procedure AssertEqualsCalculation(const AN, AK, AExpected: Cardinal);
|
||||
published
|
||||
procedure TestCombined;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TBinomialCoefficientsTestCase }
|
||||
|
@ -131,8 +140,23 @@ begin
|
|||
AssertException(ERangeError, @RunRangeError);
|
||||
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
|
||||
|
||||
RegisterTest('Helper', TBinomialCoefficientsTestCase);
|
||||
RegisterTest('Helper.TBinomialCoefficientCache', TBinomialCoefficientsTestCase);
|
||||
RegisterTest('Helper.TBinomialCoefficientCache', TBinomialCoefficientsGlobalTestCase);
|
||||
end.
|
||||
|
||||
|
|
Loading…
Reference in New Issue