mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-15 08:29:32 +02:00
TAChart: Add basic tests for TListChartSource
git-svn-id: trunk@26784 -
This commit is contained in:
parent
0a1544f155
commit
1cad1a2a99
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -2218,6 +2218,7 @@ components/tachart/tasubcomponentseditor.pas svneol=native#text/pascal
|
||||
components/tachart/tatools.pas svneol=native#text/pascal
|
||||
components/tachart/tatransformations.pas svneol=native#text/pascal
|
||||
components/tachart/tatypes.pas svneol=native#text/plain
|
||||
components/tachart/test/SourcesTest.pas svneol=native#text/pascal
|
||||
components/tachart/test/UtilsTest.pas svneol=native#text/pascal
|
||||
components/tachart/test/test.lpi svneol=native#text/plain
|
||||
components/tachart/test/test.lpr svneol=native#text/pascal
|
||||
|
95
components/tachart/test/SourcesTest.pas
Normal file
95
components/tachart/test/SourcesTest.pas
Normal file
@ -0,0 +1,95 @@
|
||||
{
|
||||
*****************************************************************************
|
||||
* *
|
||||
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
|
||||
* for details about the copyright. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* *
|
||||
*****************************************************************************
|
||||
|
||||
Authors: Alexander Klenin
|
||||
|
||||
}
|
||||
|
||||
unit SourcesTest;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FPCUnit, TestRegistry, TASources;
|
||||
|
||||
type
|
||||
|
||||
{ TIntervalListTest }
|
||||
|
||||
{ TListSourceTest }
|
||||
|
||||
TListSourceTest = class(TTestCase)
|
||||
private
|
||||
FSource: TListChartSource;
|
||||
protected
|
||||
procedure SetUp; override;
|
||||
procedure TearDown; override;
|
||||
published
|
||||
procedure Basic;
|
||||
procedure DataPoint;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
TAChartUtils;
|
||||
|
||||
{ TListSourceTest }
|
||||
|
||||
procedure TListSourceTest.Basic;
|
||||
begin
|
||||
FSource.Clear;
|
||||
AssertEquals(0, FSource.Count);
|
||||
AssertEquals(0, FSource.Add(1, 2, 'text', $FFFFFF));
|
||||
AssertEquals(1, FSource.Count);
|
||||
FSource.Delete(0);
|
||||
AssertEquals(0, FSource.Count);
|
||||
end;
|
||||
|
||||
procedure TListSourceTest.DataPoint;
|
||||
begin
|
||||
FSource.Clear;
|
||||
FSource.DataPoints.Add('3|4|?|text1');
|
||||
FSource.DataPoints.Add('5|6|$FF0000|');
|
||||
AssertEquals(2, FSource.Count);
|
||||
AssertEquals(3, FSource[0]^.X);
|
||||
AssertEquals(4, FSource[0]^.Y);
|
||||
AssertEquals('text1', FSource[0]^.Text);
|
||||
AssertEquals(clTAColor, FSource[0]^.Color);
|
||||
AssertEquals(5, FSource[1]^.X);
|
||||
AssertEquals(6, FSource[1]^.Y);
|
||||
AssertEquals('', FSource[1]^.Text);
|
||||
AssertEquals($FF0000, FSource[1]^.Color);
|
||||
FSource[0]^.Color := 0;
|
||||
AssertEquals('3|4|$000000|text1', FSource.DataPoints[0]);
|
||||
end;
|
||||
|
||||
procedure TListSourceTest.SetUp;
|
||||
begin
|
||||
inherited SetUp;
|
||||
FSource := TListChartSource.Create(nil);
|
||||
end;
|
||||
|
||||
procedure TListSourceTest.TearDown;
|
||||
begin
|
||||
FreeAndNil(FSource);
|
||||
inherited TearDown;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
RegisterTests([TListSourceTest]);
|
||||
|
||||
end.
|
||||
|
@ -39,7 +39,7 @@
|
||||
<PackageName Value="TAChartLazarusPkg"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Units Count="3">
|
||||
<Unit0>
|
||||
<Filename Value="test.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -50,6 +50,11 @@
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="UtilsTest"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="SourcesTest.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="SourcesTest"/>
|
||||
</Unit2>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
@ -23,7 +23,7 @@ uses
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Classes, SysUtils, CustApp,
|
||||
FPCUnit, TestReport, TestRegistry, PlainTestReport, UtilsTest;
|
||||
FPCUnit, TestReport, TestRegistry, PlainTestReport, UtilsTest, SourcesTest;
|
||||
|
||||
// This is deliberately a console application to also test a proper
|
||||
// separation of logic and presentation in TAChart units.
|
||||
|
Loading…
Reference in New Issue
Block a user