add tests

This commit is contained in:
Geoffrey Goh
2015-11-13 16:34:43 -08:00
parent 5566742182
commit 46ed57ee44
9 changed files with 261 additions and 0 deletions

View File

@@ -58,6 +58,9 @@ failCallback:(void (^)(NSError *err))failCallback {
self.progressCallback(self.expectedContentLength, self.receivedContentLength);
// bytesLeft should not be negative.
assert(bytesLeft >= 0);
if (bytesLeft) {
[self.outputFileStream close];
[connection cancel];
@@ -72,6 +75,9 @@ failCallback:(void (^)(NSError *err))failCallback {
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
// We should have received all of the bytes if this is called.
assert(self.receivedContentLength == self.expectedContentLength);
[self.outputFileStream close];
self.doneCallback();
}