On Jun 26, 2013, at 6:15 AM, Andreas Grosam <agro...@onlinehome.de> wrote:

> There is a class whose implementation may be prone to accidentally have a 
> _strong_ reference elsewhere (namely within a block), which effectively 
> prevents the object to be deallocated in certain scenarios when it should.
> 
> When carefully implemented that doesn't happen, though.
> 
> 
> How can I create a Unit Test which tests such cases, e.g.:
> 
> Foo* foo;
> @autoreleaspool {
>    foo = [Foo new];
>    [foo doSomething]; 
>    foo = nil;   // should deallocate foo
> }
> ASSERT_DEALLOCATED_TRUE(foo);   
> 
> 
> Of course, the "doSomething" is more complicated involving possibly suspended 
> dispatch queues and blocks, etc.

Create a __weak reference to foo and assert that it is nil?

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to