diff --git a/tests/UBinomialCoefficientsTestCases.pas b/tests/UBinomialCoefficientsTestCases.pas index 4de87b4..76d24a3 100644 --- a/tests/UBinomialCoefficientsTestCases.pas +++ b/tests/UBinomialCoefficientsTestCases.pas @@ -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.