Added polynomial degree and coefficients as public properties

This commit is contained in:
2024-04-04 20:24:56 +02:00
parent 71c8462358
commit 0bbae0a83e
2 changed files with 56 additions and 5 deletions

View File

@@ -29,7 +29,13 @@ type
{ TBigIntPolynomialTestCase }
TBigIntPolynomialTestCase = class(TTestCase)
private
procedure TestCreateWithDegree(const ACoefficients: array of TBigInt; const ADegree: Integer);
published
procedure TestCreate;
procedure TestCreateDegreeOne;
procedure TestCreateDegreeZero;
procedure TestCreateDegreeZeroTrim;
procedure TestEqual;
procedure TestUnequalSameLength;
procedure TestUnequalDifferentLength;
@@ -41,6 +47,34 @@ implementation
{ TBigIntPolynomialTestCase }
procedure TBigIntPolynomialTestCase.TestCreateWithDegree(const ACoefficients: array of TBigInt; const ADegree: Integer);
var
a: TBigIntPolynomial;
begin
a := TBigIntPolynomial.Create(ACoefficients);
AssertEquals('Degree of created polynomial incorrect.', ADegree, a.Degree);
end;
procedure TBigIntPolynomialTestCase.TestCreate;
begin
TestCreateWithDegree([992123, 7, 20, 4550022], 3);
end;
procedure TBigIntPolynomialTestCase.TestCreateDegreeOne;
begin
TestCreateWithDegree([4007], 0);
end;
procedure TBigIntPolynomialTestCase.TestCreateDegreeZero;
begin
TestCreateWithDegree([], -1);
end;
procedure TBigIntPolynomialTestCase.TestCreateDegreeZeroTrim;
begin
TestCreateWithDegree([0], -1);
end;
procedure TBigIntPolynomialTestCase.TestEqual;
var
a, b: TBigIntPolynomial;