fpc/packages/fcl-stl/tests/gsetrefcounttest.pp
michael a33e5eb0eb * Initial check-in of stl
git-svn-id: trunk@17233 -
2011-04-03 09:15:56 +00:00

60 lines
908 B
ObjectPascal

{$mode objfpc}
unit gsetrefcounttest;
interface
uses fpcunit, testregistry, gset, gutil;
type
arr = class
a:longint;
end;
lll=class
class function c(a,b: arr):boolean;
end;
type setlli=specialize RBSet<arr,lll>;
type TGSetRefCountTest = class(TTestCase)
Published
procedure SetTest;
public
procedure Setup;override;
private
data:setlli;
end;
implementation
class function lll.c(a,b: arr):boolean;
begin
c:=a.a<b.a;
end;
procedure TGSetRefCountTest.SetTest;
var x:arr; i:longint;
it:setlli.pnode;
begin
for i:=0 to 20000 do begin
x:=arr.create;
x.a:=i;
{code should crash on this insert}
data.insert(x);
end;
it:=data.min;
while it<>nil do begin
writeln(it^.data.a);
it:=data.next(it);
end;
end;
procedure TGSetRefCountTest.Setup;
begin
data:=setlli.create;
end;
initialization
RegisterTest(TGSetRefCountTest);
end.