Skip to content

Commit 11cfb78

Browse files
committed
Removed memory leak in tComponent
1 parent 21d8b54 commit 11cfb78

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/tComponent.m

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@ function checkConstruction( testCase )
2424
testCase.ComponentType = extractAfter( testClassName, 1 );
2525

2626
% Attempt to construct the component.
27-
m = Model();
28-
componentConstructor = @() feval( testCase.ComponentType, m );
29-
testCase.fatalAssertWarningFree( componentConstructor, ...
27+
m = Model();
28+
testCase.fatalAssertWarningFree( @() constructComponent, ...
3029
"Calling the " + testCase.ComponentType + ...
3130
" constructor was not warning free." )
3231

32+
function constructComponent()
33+
34+
c = feval( testCase.ComponentType, m );
35+
oc = onCleanup( @() delete( c ) );
36+
37+
end % constructComponent
38+
3339
end % checkConstruction
3440

3541
end % methods ( TestClassSetup )

0 commit comments

Comments
 (0)