Fwd: Unit Testing and Run Loops
Fwd: Unit Testing and Run Loops
- Subject: Fwd: Unit Testing and Run Loops
- From: Jamie Hardt <email@hidden>
- Date: Sat, 4 Jul 2009 12:31:10 -0700
Thanks, I dimly recall seeing something like this before...
On Jul 4, 2009, at 12:19 PM, A.M. wrote:
On Jul 4, 2009, at 3:10 PM, Jamie Hardt wrote:
[...]
But does anyone know how to setup something like a stream read or
URL download, and make sure run loop completely services the
download/stream, and then write a unit test that makes sure all
this happens?
NSTimeInterval timeout=3.0;
while(1)
{
NSTimeInterval runtime=[NSDate timeIntervalSinceReferenceDate];
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:
[NSDate dateWithTimeIntervalSinceNow:t timeout];
timeout-=[NSDate timeIntervalSinceReferenceDate]-runtime;
if(mFileDownloaded || timeout<0.0)
break;
}
STAssertTrue(mFileDownloaded==YES,@"File failed to download");
Cheers,
M
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden