Skip to content

Commit

Permalink
Cleaned up some cruft, small bugs, and copy/paste errors in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abbeycode committed Dec 19, 2014
1 parent 46a28c5 commit aff1110
Showing 1 changed file with 16 additions and 27 deletions.
43 changes: 16 additions & 27 deletions Tests/URKArchiveTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ - (void)testListFilenames
NSError *error = nil;
NSArray *filesInArchive = [archive listFilenames:&error];

XCTAssertNil(error, @"Error returned by unrarListFiles");
XCTAssertNil(error, @"Error returned by listFilenames");
XCTAssertNotNil(filesInArchive, @"No list of files returned");
XCTAssertEqual(filesInArchive.count, expectedFileSet.count,
@"Incorrect number of files listed in archive");
Expand Down Expand Up @@ -233,7 +233,7 @@ - (void)testListFilenames_Unicode
NSError *error = nil;
NSArray *filesInArchive = [archive listFilenames:&error];

XCTAssertNil(error, @"Error returned by unrarListFiles");
XCTAssertNil(error, @"Error returned by listFilenames");
XCTAssertNotNil(filesInArchive, @"No list of files returned");
XCTAssertEqual(filesInArchive.count, expectedFileSet.count,
@"Incorrect number of files listed in archive");
Expand Down Expand Up @@ -265,7 +265,7 @@ - (void)testListFilenames_HeaderPassword
NSError *error = nil;
NSArray *filesInArchive = [archiveNoPassword listFilenames:&error];

XCTAssertNotNil(error, @"No error returned by unrarListFiles (no password given)");
XCTAssertNotNil(error, @"No error returned by listFilenames (no password given)");
XCTAssertNil(filesInArchive, @"List of files returned (no password given)");

URKArchive *archive = [URKArchive rarArchiveAtURL:testArchiveURL password:@"password"];
Expand All @@ -274,7 +274,7 @@ - (void)testListFilenames_HeaderPassword
error = nil;
filesInArchive = [archive listFilenames:&error];

XCTAssertNil(error, @"Error returned by unrarListFiles");
XCTAssertNil(error, @"Error returned by listFilenames");
XCTAssertEqual(filesInArchive.count, expectedFileSet.count,
@"Incorrect number of files listed in archive");

Expand Down Expand Up @@ -399,7 +399,7 @@ - (void)testListFileInfo_Unicode
NSError *error = nil;
NSArray *filesInArchive = [archive listFileInfo:&error];

XCTAssertNil(error, @"Error returned by unrarListFiles");
XCTAssertNil(error, @"Error returned by listFileInfo");
XCTAssertNotNil(filesInArchive, @"No list of files returned");
XCTAssertEqual(filesInArchive.count, expectedFileSet.count,
@"Incorrect number of files listed in archive");
Expand Down Expand Up @@ -430,7 +430,7 @@ - (void)testListFileInfo_HeaderPassword
NSError *error = nil;
NSArray *filesInArchive = [archiveNoPassword listFileInfo:&error];

XCTAssertNotNil(error, @"No error returned by unrarListFiles (no password given)");
XCTAssertNotNil(error, @"No error returned by listFileInfo (no password given)");
XCTAssertNil(filesInArchive, @"List of files returned (no password given)");

URKArchive *archive = [URKArchive rarArchiveAtURL:testArchiveURL password:@"password"];
Expand All @@ -439,7 +439,7 @@ - (void)testListFileInfo_HeaderPassword
error = nil;
filesInArchive = [archive listFileInfo:&error];

XCTAssertNil(error, @"Error returned by unrarListFiles");
XCTAssertNil(error, @"Error returned by listFileInfo");
XCTAssertEqual(filesInArchive.count, expectedFileSet.count,
@"Incorrect number of files listed in archive");

Expand Down Expand Up @@ -677,8 +677,6 @@ - (void)testExtractData

NSArray *expectedFiles = [[expectedFileSet allObjects] sortedArrayUsingSelector:@selector(compare:)];

NSFileManager *fm = [NSFileManager defaultManager];

for (NSString *testArchiveName in testArchives) {

NSURL *testArchiveURL = self.testFileURLs[testArchiveName];
Expand All @@ -703,7 +701,7 @@ - (void)testExtractData
}
error:&error];

XCTAssertNil(error, @"Error in extractStream:error:");
XCTAssertNil(error, @"Error in extractData:error:");

NSData *expectedFileData = [NSData dataWithContentsOfURL:self.testFileURLs[expectedFilename]];

Expand Down Expand Up @@ -732,8 +730,6 @@ - (void)testExtractData_Unicode

NSArray *expectedFiles = [[expectedFileSet allObjects] sortedArrayUsingSelector:@selector(compare:)];

NSFileManager *fm = [NSFileManager defaultManager];

NSURL *testArchiveURL = self.unicodeFileURLs[@"Ⓣest Ⓐrchive.rar"];
URKArchive *archive = [URKArchive rarArchiveAtURL:testArchiveURL];

Expand All @@ -753,7 +749,7 @@ - (void)testExtractData_Unicode
}
error:&error];

XCTAssertNil(error, @"Error in extractStream:error:");
XCTAssertNil(error, @"Error in extractData:error:");

NSData *expectedFileData = [NSData dataWithContentsOfURL:self.unicodeFileURLs[expectedFilename]];

Expand Down Expand Up @@ -830,8 +826,6 @@ - (void)testPerformOnFiles

NSArray *expectedFiles = [[expectedFileSet allObjects] sortedArrayUsingSelector:@selector(compare:)];

NSFileManager *fm = [NSFileManager defaultManager];

for (NSString *testArchiveName in testArchives) {
NSURL *testArchiveURL = self.testFileURLs[testArchiveName];
NSString *password = ([testArchiveName rangeOfString:@"Password"].location != NSNotFound
Expand Down Expand Up @@ -861,8 +855,6 @@ - (void)testPerformOnFiles_Unicode

NSArray *expectedFiles = [[expectedFileSet allObjects] sortedArrayUsingSelector:@selector(compare:)];

NSFileManager *fm = [NSFileManager defaultManager];

NSURL *testArchiveURL = self.unicodeFileURLs[@"Ⓣest Ⓐrchive.rar"];
URKArchive *archive = [URKArchive rarArchiveAtURL:testArchiveURL];

Expand Down Expand Up @@ -895,8 +887,6 @@ - (void)testPerformOnData

NSArray *expectedFiles = [[expectedFileSet allObjects] sortedArrayUsingSelector:@selector(compare:)];

NSFileManager *fm = [NSFileManager defaultManager];

for (NSString *testArchiveName in testArchives) {
NSURL *testArchiveURL = self.testFileURLs[testArchiveName];
NSString *password = ([testArchiveName rangeOfString:@"Password"].location != NSNotFound
Expand Down Expand Up @@ -931,8 +921,6 @@ - (void)testPerformOnData_Unicode

NSArray *expectedFiles = [[expectedFileSet allObjects] sortedArrayUsingSelector:@selector(compare:)];

NSFileManager *fm = [NSFileManager defaultManager];

NSURL *testArchiveURL = self.unicodeFileURLs[@"Ⓣest Ⓐrchive.rar"];
URKArchive *archive = [URKArchive rarArchiveAtURL:testArchiveURL];

Expand Down Expand Up @@ -973,7 +961,7 @@ - (void)testPerformOnData_FileMoved
NSError *renameError = nil;
NSFileManager *fm = [NSFileManager defaultManager];
[fm moveItemAtURL:largeArchiveURL toURL:movedURL error:&renameError];
XCTAssertNil(error, @"Error renaming file: %@", renameError);
XCTAssertNil(renameError, @"Error renaming file: %@", renameError);
});

__block NSUInteger fileCount = 0;
Expand Down Expand Up @@ -1010,7 +998,7 @@ - (void)testPerformOnData_FileDeleted
NSError *removeError = nil;
NSFileManager *fm = [NSFileManager defaultManager];
[fm removeItemAtURL:largeArchiveURL error:&removeError];
XCTAssertNil(error, @"Error removing file: %@", removeError);
XCTAssertNil(removeError, @"Error removing file: %@", removeError);
});

__block NSUInteger fileCount = 0;
Expand Down Expand Up @@ -1046,7 +1034,7 @@ - (void)testPerformOnData_FileMovedBeforeBegin
NSError *renameError = nil;
NSFileManager *fm = [NSFileManager defaultManager];
[fm moveItemAtURL:largeArchiveURL toURL:movedURL error:&renameError];
XCTAssertNil(error, @"Error renaming file: %@", renameError);
XCTAssertNil(renameError, @"Error renaming file: %@", renameError);

__block NSUInteger fileCount = 0;

Expand Down Expand Up @@ -1098,7 +1086,7 @@ - (void)testExtractBufferedData
- (void)testExtractBufferedData_VeryLarge
{
DTSendSignalFlag("Begin creating text file", DT_START_SIGNAL, TRUE);
NSURL *largeTextFile = [self randomTextFieldOfLength:1000000]; // Increase for a more dramatic test
NSURL *largeTextFile = [self randomTextFileOfLength:1000000]; // Increase for a more dramatic test
XCTAssertNotNil(largeTextFile, @"No large text file URL returned");
DTSendSignalFlag("End creating text file", DT_END_SIGNAL, TRUE);

Expand All @@ -1116,7 +1104,8 @@ - (void)testExtractBufferedData_VeryLarge
NSError *handleError = nil;
NSFileHandle *deflated = [NSFileHandle fileHandleForWritingToURL:deflatedFileURL
error:&handleError];

XCTAssertNil(handleError, @"Error creating a file handle");

URKArchive *archive = [URKArchive rarArchiveAtURL:archiveURL];

DTSendSignalFlag("Begin extracting buffered data", DT_START_SIGNAL, TRUE);
Expand Down Expand Up @@ -1361,7 +1350,7 @@ - (NSInteger)numberOfOpenFileHandles {
return [lsofOutput componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]].count;
}

- (NSURL *)randomTextFieldOfLength:(NSUInteger)numberOfCharacters {
- (NSURL *)randomTextFileOfLength:(NSUInteger)numberOfCharacters {
NSString *letters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 .,?!\n";
NSUInteger letterCount = letters.length;

Expand Down

0 comments on commit aff1110

Please sign in to comment.