You've already forked lazarus-ccr
Test suite : fix memory leaks.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@915 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -543,6 +543,7 @@ begin
|
|||||||
CheckNull(x.Root,'Root <> nil');
|
CheckNull(x.Root,'Root <> nil');
|
||||||
Check(( x.TargetClass = TClass_A ), 'TargetClass');
|
Check(( x.TargetClass = TClass_A ), 'TargetClass');
|
||||||
finally
|
finally
|
||||||
|
x.Clear(clrFreeObjects);
|
||||||
x.Free();
|
x.Free();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -691,6 +692,7 @@ begin
|
|||||||
x.AddCondition('IntProp',nfoEqual,VAL_4,fcAnd);
|
x.AddCondition('IntProp',nfoEqual,VAL_4,fcAnd);
|
||||||
PrintTree(x.Root,@Display,2);
|
PrintTree(x.Root,@Display,2);
|
||||||
finally
|
finally
|
||||||
|
x.Clear(clrFreeObjects);
|
||||||
x.Free();
|
x.Free();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -775,7 +777,7 @@ begin
|
|||||||
x.EndGroup();
|
x.EndGroup();
|
||||||
x.AddCondition('IntProp',nfoEqual,VAL_4,fcOr);
|
x.AddCondition('IntProp',nfoEqual,VAL_4,fcOr);
|
||||||
PrintTree(x.Root,@Display,2);
|
PrintTree(x.Root,@Display,2);
|
||||||
|
|
||||||
Display(#10#13);
|
Display(#10#13);
|
||||||
Display(#10#13);
|
Display(#10#13);
|
||||||
x.Clear(clrFreeObjects);
|
x.Clear(clrFreeObjects);
|
||||||
@ -790,6 +792,7 @@ begin
|
|||||||
x.AddCondition('IntProp',nfoGreater,VAL_4,fcAnd);
|
x.AddCondition('IntProp',nfoGreater,VAL_4,fcAnd);
|
||||||
PrintTree(x.Root,@Display,2);
|
PrintTree(x.Root,@Display,2);
|
||||||
finally
|
finally
|
||||||
|
x.Clear(clrFreeObjects);
|
||||||
x.Free();
|
x.Free();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1051,6 +1054,7 @@ begin
|
|||||||
CheckEquals('EnumProp',xN.PropInfo^.Name);
|
CheckEquals('EnumProp',xN.PropInfo^.Name);
|
||||||
CheckEquals(Ord(VAL_1),xN.ComparedValue);
|
CheckEquals(Ord(VAL_1),xN.ComparedValue);
|
||||||
finally
|
finally
|
||||||
|
x.Clear(clrFreeObjects);
|
||||||
x.Free();
|
x.Free();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1070,6 +1074,7 @@ begin
|
|||||||
CheckEquals('EnumProp',xN.PropInfo^.Name);
|
CheckEquals('EnumProp',xN.PropInfo^.Name);
|
||||||
CheckEquals(Ord(VAL_1),xN.ComparedValue);
|
CheckEquals(Ord(VAL_1),xN.ComparedValue);
|
||||||
finally
|
finally
|
||||||
|
x.Clear(clrFreeObjects);
|
||||||
x.Free();
|
x.Free();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1090,6 +1095,7 @@ begin
|
|||||||
CheckEquals(VAL_1,sN.ComparedValue);
|
CheckEquals(VAL_1,sN.ComparedValue);
|
||||||
CheckEquals(Ord(sfoEqualCaseInsensitive),Ord(sN.Operation),'Operation');
|
CheckEquals(Ord(sfoEqualCaseInsensitive),Ord(sN.Operation),'Operation');
|
||||||
finally
|
finally
|
||||||
|
x.Clear(clrFreeObjects);
|
||||||
x.Free();
|
x.Free();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1110,6 +1116,7 @@ begin
|
|||||||
CheckEquals(VAL_1,sN.ComparedValue);
|
CheckEquals(VAL_1,sN.ComparedValue);
|
||||||
CheckEquals(Ord(sfoNotEqual),Ord(sN.Operation),'Operation');
|
CheckEquals(Ord(sfoNotEqual),Ord(sN.Operation),'Operation');
|
||||||
finally
|
finally
|
||||||
|
x.Clear(clrFreeObjects);
|
||||||
x.Free();
|
x.Free();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1130,6 +1137,7 @@ begin
|
|||||||
CheckEquals(VAL_1,sN.ComparedValue);
|
CheckEquals(VAL_1,sN.ComparedValue);
|
||||||
CheckEquals(Ord(nfoEqual),Ord(sN.Operation),'Operation');
|
CheckEquals(Ord(nfoEqual),Ord(sN.Operation),'Operation');
|
||||||
finally
|
finally
|
||||||
|
x.Clear(clrFreeObjects);
|
||||||
x.Free();
|
x.Free();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1150,6 +1158,7 @@ begin
|
|||||||
CheckEquals(VAL_1,sN.ComparedValue);
|
CheckEquals(VAL_1,sN.ComparedValue);
|
||||||
CheckEquals(Ord(nfoNotEqual),Ord(sN.Operation),'Operation');
|
CheckEquals(Ord(nfoNotEqual),Ord(sN.Operation),'Operation');
|
||||||
finally
|
finally
|
||||||
|
x.Clear(clrFreeObjects);
|
||||||
x.Free();
|
x.Free();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1170,6 +1179,7 @@ begin
|
|||||||
CheckEquals(VAL_1,sN.ComparedValue);
|
CheckEquals(VAL_1,sN.ComparedValue);
|
||||||
CheckEquals(Ord(nfoGreaterOrEqual),Ord(sN.Operation),'Operation');
|
CheckEquals(Ord(nfoGreaterOrEqual),Ord(sN.Operation),'Operation');
|
||||||
finally
|
finally
|
||||||
|
x.Clear(clrFreeObjects);
|
||||||
x.Free();
|
x.Free();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1190,6 +1200,7 @@ begin
|
|||||||
CheckEquals(VAL_1,sN.ComparedValue);
|
CheckEquals(VAL_1,sN.ComparedValue);
|
||||||
CheckEquals(Ord(nfoLesserOrEqual),Ord(sN.Operation),'Operation');
|
CheckEquals(Ord(nfoLesserOrEqual),Ord(sN.Operation),'Operation');
|
||||||
finally
|
finally
|
||||||
|
x.Clear(clrFreeObjects);
|
||||||
x.Free();
|
x.Free();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1210,6 +1221,7 @@ begin
|
|||||||
CheckEquals(Ord(VAL_1),Ord(sN.ComparedValue));
|
CheckEquals(Ord(VAL_1),Ord(sN.ComparedValue));
|
||||||
CheckEquals(Ord(nfoEqual),Ord(sN.Operation),'Operation');
|
CheckEquals(Ord(nfoEqual),Ord(sN.Operation),'Operation');
|
||||||
finally
|
finally
|
||||||
|
x.Clear(clrFreeObjects);
|
||||||
x.Free();
|
x.Free();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1230,6 +1242,7 @@ begin
|
|||||||
CheckEquals(Ord(VAL_1),Ord(sN.ComparedValue));
|
CheckEquals(Ord(VAL_1),Ord(sN.ComparedValue));
|
||||||
CheckEquals(Ord(nfoNotEqual),Ord(sN.Operation),'Operation');
|
CheckEquals(Ord(nfoNotEqual),Ord(sN.Operation),'Operation');
|
||||||
finally
|
finally
|
||||||
|
x.Clear(clrFreeObjects);
|
||||||
x.Free();
|
x.Free();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1250,6 +1263,7 @@ begin
|
|||||||
CheckEquals(Ord(VAL_1),Ord(sN.ComparedValue));
|
CheckEquals(Ord(VAL_1),Ord(sN.ComparedValue));
|
||||||
CheckEquals(Ord(nfoGreaterOrEqual),Ord(sN.Operation),'Operation');
|
CheckEquals(Ord(nfoGreaterOrEqual),Ord(sN.Operation),'Operation');
|
||||||
finally
|
finally
|
||||||
|
x.Clear(clrFreeObjects);
|
||||||
x.Free();
|
x.Free();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1270,6 +1284,7 @@ begin
|
|||||||
CheckEquals(Ord(VAL_1),Ord(sN.ComparedValue));
|
CheckEquals(Ord(VAL_1),Ord(sN.ComparedValue));
|
||||||
CheckEquals(Ord(nfoLesserOrEqual),Ord(sN.Operation),'Operation');
|
CheckEquals(Ord(nfoLesserOrEqual),Ord(sN.Operation),'Operation');
|
||||||
finally
|
finally
|
||||||
|
x.Clear(clrFreeObjects);
|
||||||
x.Free();
|
x.Free();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1298,7 +1313,12 @@ begin
|
|||||||
|
|
||||||
CompareTree(x.Root,y.Root);
|
CompareTree(x.Root,y.Root);
|
||||||
finally
|
finally
|
||||||
|
x.Clear(clrFreeObjects);
|
||||||
x.Free();
|
x.Free();
|
||||||
|
if ( y <> nil ) then begin
|
||||||
|
y.Clear(clrFreeObjects);
|
||||||
|
y.Free();
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -442,6 +442,9 @@ begin
|
|||||||
finally
|
finally
|
||||||
ReleaseDomNode(locExistDoc);
|
ReleaseDomNode(locExistDoc);
|
||||||
ReleaseDomNode(locDoc);
|
ReleaseDomNode(locDoc);
|
||||||
|
c_readed.Free();
|
||||||
|
b_readed.Free();
|
||||||
|
a_readed.Free();
|
||||||
c.Free();
|
c.Free();
|
||||||
b.Free();
|
b.Free();
|
||||||
a.Free();
|
a.Free();
|
||||||
@ -892,6 +895,7 @@ var
|
|||||||
locReturn : THRefTestSession;
|
locReturn : THRefTestSession;
|
||||||
locStrPrmName : string;
|
locStrPrmName : string;
|
||||||
begin
|
begin
|
||||||
|
locReturn := nil;
|
||||||
f := soap_formatter.TSOAPFormatter.Create() as IFormatterClient;
|
f := soap_formatter.TSOAPFormatter.Create() as IFormatterClient;
|
||||||
strm := TMemoryStream.Create();
|
strm := TMemoryStream.Create();
|
||||||
try
|
try
|
||||||
@ -909,6 +913,7 @@ begin
|
|||||||
CheckEquals(12,locReturn.PartnerID,'PartnerID');
|
CheckEquals(12,locReturn.PartnerID,'PartnerID');
|
||||||
f.EndScopeRead();
|
f.EndScopeRead();
|
||||||
finally
|
finally
|
||||||
|
FreeAndNil(locReturn);
|
||||||
FreeAndNil(strm);
|
FreeAndNil(strm);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -3601,7 +3601,7 @@ var
|
|||||||
begin
|
begin
|
||||||
SetLength(locBuffer,255);
|
SetLength(locBuffer,255);
|
||||||
pBytePtr := PByte(@(locBuffer[0]));
|
pBytePtr := PByte(@(locBuffer[0]));
|
||||||
for i := 0 to 255 do begin
|
for i := Low(locBuffer) to High(locBuffer) do begin
|
||||||
pBytePtr^ := i;
|
pBytePtr^ := i;
|
||||||
Inc(pBytePtr);
|
Inc(pBytePtr);
|
||||||
end;
|
end;
|
||||||
@ -3629,7 +3629,7 @@ var
|
|||||||
begin
|
begin
|
||||||
SetLength(locBuffer,255);
|
SetLength(locBuffer,255);
|
||||||
pBytePtr := PByte(@(locBuffer[0]));
|
pBytePtr := PByte(@(locBuffer[0]));
|
||||||
for i := 0 to 255 do begin
|
for i := Low(locBuffer) to High(locBuffer) do begin
|
||||||
pBytePtr^ := i;
|
pBytePtr^ := i;
|
||||||
Inc(pBytePtr);
|
Inc(pBytePtr);
|
||||||
end;
|
end;
|
||||||
@ -3658,7 +3658,7 @@ var
|
|||||||
begin
|
begin
|
||||||
SetLength(locBuffer,255);
|
SetLength(locBuffer,255);
|
||||||
pBytePtr := PByte(@(locBuffer[0]));
|
pBytePtr := PByte(@(locBuffer[0]));
|
||||||
for i := 0 to 255 do begin
|
for i := Low(locBuffer) to High(locBuffer) do begin
|
||||||
pBytePtr^ := i;
|
pBytePtr^ := i;
|
||||||
Inc(pBytePtr);
|
Inc(pBytePtr);
|
||||||
end;
|
end;
|
||||||
@ -3690,7 +3690,7 @@ var
|
|||||||
begin
|
begin
|
||||||
SetLength(locBuffer,255);
|
SetLength(locBuffer,255);
|
||||||
pBytePtr := PByte(@(locBuffer[0]));
|
pBytePtr := PByte(@(locBuffer[0]));
|
||||||
for i := 0 to 255 do begin
|
for i := Low(locBuffer) to High(locBuffer) do begin
|
||||||
pBytePtr^ := i;
|
pBytePtr^ := i;
|
||||||
Inc(pBytePtr);
|
Inc(pBytePtr);
|
||||||
end;
|
end;
|
||||||
@ -3824,7 +3824,7 @@ var
|
|||||||
begin
|
begin
|
||||||
SetLength(locBuffer,255);
|
SetLength(locBuffer,255);
|
||||||
pBytePtr := PByte(@(locBuffer[0]));
|
pBytePtr := PByte(@(locBuffer[0]));
|
||||||
for i := 0 to 255 do begin
|
for i := Low(locBuffer) to High(locBuffer) do begin
|
||||||
pBytePtr^ := i;
|
pBytePtr^ := i;
|
||||||
Inc(pBytePtr);
|
Inc(pBytePtr);
|
||||||
end;
|
end;
|
||||||
@ -3852,7 +3852,7 @@ var
|
|||||||
begin
|
begin
|
||||||
SetLength(locBuffer,255);
|
SetLength(locBuffer,255);
|
||||||
pBytePtr := PByte(@(locBuffer[0]));
|
pBytePtr := PByte(@(locBuffer[0]));
|
||||||
for i := 0 to 255 do begin
|
for i := Low(locBuffer) to High(locBuffer) do begin
|
||||||
pBytePtr^ := i;
|
pBytePtr^ := i;
|
||||||
Inc(pBytePtr);
|
Inc(pBytePtr);
|
||||||
end;
|
end;
|
||||||
@ -3881,7 +3881,7 @@ var
|
|||||||
begin
|
begin
|
||||||
SetLength(locBuffer,255);
|
SetLength(locBuffer,255);
|
||||||
pBytePtr := PByte(@(locBuffer[0]));
|
pBytePtr := PByte(@(locBuffer[0]));
|
||||||
for i := 0 to 255 do begin
|
for i := Low(locBuffer) to High(locBuffer) do begin
|
||||||
pBytePtr^ := i;
|
pBytePtr^ := i;
|
||||||
Inc(pBytePtr);
|
Inc(pBytePtr);
|
||||||
end;
|
end;
|
||||||
@ -3913,7 +3913,7 @@ var
|
|||||||
begin
|
begin
|
||||||
SetLength(locBuffer,255);
|
SetLength(locBuffer,255);
|
||||||
pBytePtr := PByte(@(locBuffer[0]));
|
pBytePtr := PByte(@(locBuffer[0]));
|
||||||
for i := 0 to 255 do begin
|
for i := Low(locBuffer) to High(locBuffer) do begin
|
||||||
pBytePtr^ := i;
|
pBytePtr^ := i;
|
||||||
Inc(pBytePtr);
|
Inc(pBytePtr);
|
||||||
end;
|
end;
|
||||||
@ -4197,7 +4197,7 @@ var
|
|||||||
begin
|
begin
|
||||||
SetLength(locBuffer,255);
|
SetLength(locBuffer,255);
|
||||||
pBytePtr := PByte(@(locBuffer[0]));
|
pBytePtr := PByte(@(locBuffer[0]));
|
||||||
for i := 0 to 255 do begin
|
for i := Low(locBuffer) to High(locBuffer) do begin
|
||||||
pBytePtr^ := i;
|
pBytePtr^ := i;
|
||||||
Inc(pBytePtr);
|
Inc(pBytePtr);
|
||||||
end;
|
end;
|
||||||
@ -4221,7 +4221,7 @@ var
|
|||||||
begin
|
begin
|
||||||
SetLength(locBuffer,255);
|
SetLength(locBuffer,255);
|
||||||
pBytePtr := PByte(@(locBuffer[0]));
|
pBytePtr := PByte(@(locBuffer[0]));
|
||||||
for i := 0 to 255 do begin
|
for i := Low(locBuffer) to High(locBuffer) do begin
|
||||||
pBytePtr^ := i;
|
pBytePtr^ := i;
|
||||||
Inc(pBytePtr);
|
Inc(pBytePtr);
|
||||||
end;
|
end;
|
||||||
|
@ -134,6 +134,19 @@ type
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
var
|
||||||
|
ListToRelease : IInterfaceList;
|
||||||
|
procedure Finalize_ListToRelease();
|
||||||
|
var
|
||||||
|
i : Integer;
|
||||||
|
begin
|
||||||
|
if ( ListToRelease <> nil ) and ( ListToRelease.Count > 0 ) then begin
|
||||||
|
for i := 0 to Pred(ListToRelease.Count) do
|
||||||
|
ListToRelease[i]._Release();
|
||||||
|
ListToRelease := nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TTestClass }
|
{ TTestClass }
|
||||||
|
|
||||||
procedure TTestClass.SayHello();
|
procedure TTestClass.SayHello();
|
||||||
@ -156,6 +169,7 @@ begin
|
|||||||
inherited Create();
|
inherited Create();
|
||||||
FPooled := True;
|
FPooled := True;
|
||||||
_AddRef(); // not to allow the rtl to reuse the same memory for another instance of the same class!!
|
_AddRef(); // not to allow the rtl to reuse the same memory for another instance of the same class!!
|
||||||
|
ListToRelease.Add(Self as IInterface);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TTest_TIntfPool }
|
{ TTest_TIntfPool }
|
||||||
@ -183,6 +197,7 @@ begin
|
|||||||
CheckEquals(MIN_A,obj.Min);
|
CheckEquals(MIN_A,obj.Min);
|
||||||
CheckEquals(MAX_A,obj.Max);
|
CheckEquals(MAX_A,obj.Max);
|
||||||
CheckEquals(MIN_A,obj.GetInstancesCount());
|
CheckEquals(MIN_A,obj.GetInstancesCount());
|
||||||
|
obj.Free();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TTest_TIntfPool.Release();
|
procedure TTest_TIntfPool.Release();
|
||||||
@ -214,6 +229,7 @@ begin
|
|||||||
elt.SayHello();
|
elt.SayHello();
|
||||||
obj.Release(elt);
|
obj.Release(elt);
|
||||||
end;
|
end;
|
||||||
|
FreeAndNil(obj);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF WST_SEMAPHORE_TIMEOUT}
|
{$IFDEF WST_SEMAPHORE_TIMEOUT}
|
||||||
@ -253,6 +269,7 @@ begin
|
|||||||
il.Add(elt);
|
il.Add(elt);
|
||||||
obj.Release(elt);
|
obj.Release(elt);
|
||||||
end;
|
end;
|
||||||
|
FreeAndNil(obj);
|
||||||
end;
|
end;
|
||||||
{$ENDIF WST_SEMAPHORE_TIMEOUT}
|
{$ENDIF WST_SEMAPHORE_TIMEOUT}
|
||||||
|
|
||||||
@ -304,6 +321,7 @@ begin
|
|||||||
obj.Discard(elt);
|
obj.Discard(elt);
|
||||||
elt := obj.Get(10) as ITest;
|
elt := obj.Get(10) as ITest;
|
||||||
Check(oldElt <> elt );
|
Check(oldElt <> elt );
|
||||||
|
FreeAndNil(obj);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TTest_TSimpleItemFactoryEx }
|
{ TTest_TSimpleItemFactoryEx }
|
||||||
@ -786,6 +804,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
ListToRelease := TInterfaceList.Create();
|
||||||
|
|
||||||
RegisterTest('Utilities',TTest_TIntfPool.Suite);
|
RegisterTest('Utilities',TTest_TIntfPool.Suite);
|
||||||
RegisterTest('Utilities',TTest_TSimpleItemFactoryEx.Suite);
|
RegisterTest('Utilities',TTest_TSimpleItemFactoryEx.Suite);
|
||||||
RegisterTest('Utilities',TTest_TImplementationFactory.Suite);
|
RegisterTest('Utilities',TTest_TImplementationFactory.Suite);
|
||||||
@ -794,4 +814,7 @@ initialization
|
|||||||
RegisterTest('Utilities',TTest_TwstModuleManager.Suite);
|
RegisterTest('Utilities',TTest_TwstModuleManager.Suite);
|
||||||
RegisterTest('Utilities',TTest_Procs.Suite);
|
RegisterTest('Utilities',TTest_Procs.Suite);
|
||||||
|
|
||||||
|
finalization
|
||||||
|
Finalize_ListToRelease();
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Reference in New Issue
Block a user