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