mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-02 04:39:48 +01:00
TAChart: Add IsEquivalent utility function
git-svn-id: trunk@38811 -
This commit is contained in:
parent
685097901a
commit
4b2fe13853
@ -293,6 +293,7 @@ function FormatIfNotEmpty(AFormat, AStr: String): String; inline;
|
||||
function IfThen(ACond: Boolean; ATrue, AFalse: TObject): TObject; overload;
|
||||
function InterpolateRGB(AColor1, AColor2: Integer; ACoeff: Double): Integer;
|
||||
function IntToColorHex(AColor: Integer): String; inline;
|
||||
function IsEquivalent(const A1, A2: Double): Boolean; inline;
|
||||
function IsNan(const APoint: TDoublePoint): Boolean; overload; inline;
|
||||
function NumberOr(ANum: Double; ADefault: Double = 0.0): Double; inline;
|
||||
|
||||
@ -424,6 +425,11 @@ begin
|
||||
Result := '$' + IntToHex(AColor, 6);
|
||||
end;
|
||||
|
||||
function IsEquivalent(const A1, A2: Double): Boolean;
|
||||
begin
|
||||
Result := CompareDWord(A1, A2, SizeOf(A1) div SizeOf(DWord)) = 0;
|
||||
end;
|
||||
|
||||
function IsNan(const APoint: TDoublePoint): Boolean;
|
||||
begin
|
||||
Result := IsNan(APoint.X) or IsNan(APoint.Y);
|
||||
|
||||
@ -40,6 +40,7 @@ type
|
||||
TMathTest = class(TTestCase)
|
||||
published
|
||||
procedure CumulNurmDistrTest;
|
||||
procedure TestIsEquivalent;
|
||||
end;
|
||||
|
||||
TGeometryTest = class(TTestCase)
|
||||
@ -172,6 +173,16 @@ begin
|
||||
AssertEquals(p, InvCumulNormDistr(CumulNormDistr(p)));
|
||||
end;
|
||||
|
||||
procedure TMathTest.TestIsEquivalent;
|
||||
begin
|
||||
AssertTrue(IsEquivalent(1.2345, 1.2345));
|
||||
AssertTrue(IsEquivalent(SafeNaN, SafeNaN));
|
||||
AssertTrue(IsEquivalent(1e100, 1e100+1));
|
||||
AssertFalse(IsEquivalent(1e10, 1e10+1));
|
||||
AssertFalse(IsEquivalent(5, SafeNaN));
|
||||
AssertFalse(IsEquivalent(SafeNaN, 5));
|
||||
end;
|
||||
|
||||
{ TGeometryTest }
|
||||
|
||||
procedure TGeometryTest.AssertEquals(const Expected, Actual: TDoublePoint);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user