mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 13:38:00 +02:00
tests: avglvltree
git-svn-id: trunk@36123 -
This commit is contained in:
parent
44af0bd032
commit
4d16618629
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -6306,6 +6306,7 @@ test/customdrawn/mainform.lfm svneol=native#text/plain
|
||||
test/customdrawn/mainform.pas svneol=native#text/plain
|
||||
test/hello.ahk svneol=native#text/plain
|
||||
test/lazutils/TestLazLogger.lpr svneol=native#text/pascal
|
||||
test/lazutils/testavglvltree.pas svneol=native#text/plain
|
||||
test/lazutils/testlazloggercase.pas svneol=native#text/pascal
|
||||
test/lazutils/testlazutf8.pas svneol=native#text/plain
|
||||
test/lazutils/testlazutils.pas svneol=native#text/plain
|
||||
|
95
test/lazutils/testavglvltree.pas
Normal file
95
test/lazutils/testavglvltree.pas
Normal file
@ -0,0 +1,95 @@
|
||||
{
|
||||
Test all with:
|
||||
./runtests --format=plain --suite=TTestAvgLvlTree
|
||||
|
||||
Test specific with:
|
||||
./runtests --format=plain --suite=TestAVLTreeAddsDeletes
|
||||
}
|
||||
unit TestAvgLvlTree;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, fpcunit, testglobals, AvgLvlTree, LazLogger;
|
||||
|
||||
type
|
||||
{ TTestAvgLvlTree }
|
||||
|
||||
TTestAvgLvlTree = class(TTestCase)
|
||||
private
|
||||
procedure TestSequence(Args: array of const);
|
||||
published
|
||||
procedure TestAVLTreeAddsDeletes;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTestAvgLvlTree }
|
||||
|
||||
procedure TTestAvgLvlTree.TestSequence(Args: array of const);
|
||||
{ $DEFINE VerboseTestSequence}
|
||||
var
|
||||
Tree: TAvgLvlTree;
|
||||
i: Integer;
|
||||
Value: LongInt;
|
||||
begin
|
||||
Tree:=TAvgLvlTree.Create;
|
||||
//writeln(Tree.ReportAsString);
|
||||
Tree.ConsistencyCheck;
|
||||
|
||||
for i:=Low(Args) to high(Args) do begin
|
||||
if Args[i].VType<>vtInteger then continue;
|
||||
Value:=Args[i].vinteger;
|
||||
if Value>0 then begin
|
||||
{$IFDEF VerboseTestSequence}
|
||||
DebugLn([' add value ',Value]);
|
||||
{$ENDIF}
|
||||
Tree.Add(Pointer(Value));
|
||||
end else begin
|
||||
{$IFDEF VerboseTestSequence}
|
||||
debugln([' remove value ',Value]);
|
||||
{$ENDIF}
|
||||
Tree.Remove(Pointer(Value));
|
||||
end;
|
||||
{$IFDEF VerboseTestSequence}
|
||||
DebugLn(Tree.ReportAsString);
|
||||
{$ENDIF}
|
||||
Tree.ConsistencyCheck;
|
||||
end;
|
||||
|
||||
Tree.Clear;
|
||||
//writeln(Tree.ReportAsString);
|
||||
Tree.ConsistencyCheck;
|
||||
|
||||
Tree.Free;
|
||||
end;
|
||||
|
||||
procedure TTestAvgLvlTree.TestAVLTreeAddsDeletes;
|
||||
begin
|
||||
// rotate left
|
||||
TestSequence([]);
|
||||
TestSequence([1]);
|
||||
TestSequence([1,2]);
|
||||
TestSequence([1,2,3]);
|
||||
TestSequence([1,2,3,4]);
|
||||
TestSequence([1,2,3,4,5]);
|
||||
TestSequence([1,2,3,4,5,6]);
|
||||
TestSequence([1,2,3,4,5,6,7,8,9,10]);
|
||||
|
||||
// rotate right
|
||||
TestSequence([10,9,8,7,6,5,4,3,2,1]);
|
||||
|
||||
// double rotate right, left
|
||||
TestSequence([5,7,6]);
|
||||
|
||||
// double rotate left, right
|
||||
TestSequence([5,3,4]);
|
||||
end;
|
||||
|
||||
initialization
|
||||
AddToLazUtilsTestSuite(TTestAvgLvlTree);
|
||||
|
||||
end.
|
||||
|
@ -39,7 +39,7 @@
|
||||
<PackageName Value="LCL"/>
|
||||
</Item4>
|
||||
</RequiredPackages>
|
||||
<Units Count="14">
|
||||
<Units Count="15">
|
||||
<Unit0>
|
||||
<Filename Value="runtests.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -110,6 +110,11 @@
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="TestLazXML"/>
|
||||
</Unit13>
|
||||
<Unit14>
|
||||
<Filename Value="lazutils\testavglvltree.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="TestAvgLvlTree"/>
|
||||
</Unit14>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
@ -24,7 +24,7 @@ uses
|
||||
Classes, consoletestrunner,
|
||||
testglobals, testunits, dom,
|
||||
{Unit needed to set the LCL version and widget set name}
|
||||
LCLVersion, InterfaceBase, Interfaces, testlazxml;
|
||||
LCLVersion, InterfaceBase, Interfaces, testlazxml, testavglvltree;
|
||||
|
||||
type
|
||||
|
||||
|
@ -30,7 +30,7 @@ uses
|
||||
TestLpi, BugTestCase,
|
||||
bug8432, testfileutil, testfileproc,
|
||||
// lazutils
|
||||
TestLazUtils, TestLazUTF8,
|
||||
TestLazUtils, TestLazUTF8, TestAvgLvlTree,
|
||||
// codetools
|
||||
TestBasicCodetools, TestCTXMLFixFragments, TestCTRangeScan, TestCTH2Pas,
|
||||
TestCompleteBlock, TestStdCodetools,
|
||||
|
Loading…
Reference in New Issue
Block a user