70 lines
2.4 KiB
Objective-C
70 lines
2.4 KiB
Objective-C
//
|
|
// PerformOnFilesTests.m
|
|
// UnzipKit
|
|
//
|
|
// Created by Dov Frankel on 7/16/15.
|
|
// Copyright (c) 2015 Abbey Code. All rights reserved.
|
|
//
|
|
|
|
#import "UZKArchiveTestCase.h"
|
|
#import "UnzipKit.h"
|
|
|
|
@interface PerformOnFilesTests : UZKArchiveTestCase
|
|
@end
|
|
|
|
@implementation PerformOnFilesTests
|
|
|
|
|
|
- (void)testPerformOnFiles
|
|
{
|
|
NSArray *testArchives = @[@"Test Archive.zip",
|
|
@"Test Archive (Password).zip"];
|
|
|
|
NSSet *expectedFileSet = self.nonZipTestFilePaths;
|
|
NSArray *expectedFiles = [expectedFileSet.allObjects sortedArrayUsingSelector:@selector(compare:)];
|
|
|
|
for (NSString *testArchiveName in testArchives) {
|
|
NSURL *testArchiveURL = self.testFileURLs[testArchiveName];
|
|
NSString *password = ([testArchiveName rangeOfString:@"Password"].location != NSNotFound
|
|
? @"password"
|
|
: nil);
|
|
UZKArchive *archive = [[UZKArchive alloc] initWithURL:testArchiveURL password:password error:nil];
|
|
|
|
__block NSUInteger fileIndex = 0;
|
|
NSError *error = nil;
|
|
|
|
[archive performOnFilesInArchive:
|
|
^(UZKFileInfo *fileInfo, BOOL *stop) {
|
|
NSString *expectedFilename = expectedFiles[fileIndex++];
|
|
XCTAssertEqualObjects(fileInfo.filename, expectedFilename, @"Unexpected filename encountered");
|
|
} error:&error];
|
|
|
|
XCTAssertNil(error, @"Error iterating through files");
|
|
XCTAssertEqual(fileIndex, expectedFiles.count, @"Incorrect number of files encountered");
|
|
}
|
|
}
|
|
|
|
- (void)testPerformOnFiles_Unicode
|
|
{
|
|
NSSet *expectedFileSet = self.nonZipUnicodeFilePaths;
|
|
NSArray *expectedFiles = [expectedFileSet.allObjects sortedArrayUsingSelector:@selector(compare:)];
|
|
|
|
NSURL *testArchiveURL = self.unicodeFileURLs[@"Ⓣest Ⓐrchive.zip"];
|
|
UZKArchive *archive = [[UZKArchive alloc] initWithURL:testArchiveURL error:nil];
|
|
|
|
__block NSUInteger fileIndex = 0;
|
|
NSError *error = nil;
|
|
|
|
[archive performOnFilesInArchive:
|
|
^(UZKFileInfo *fileInfo, BOOL *stop) {
|
|
NSString *expectedFilename = expectedFiles[fileIndex++];
|
|
XCTAssertEqualObjects(fileInfo.filename, expectedFilename, @"Unexpected filename encountered");
|
|
} error:&error];
|
|
|
|
XCTAssertNil(error, @"Error iterating through files");
|
|
XCTAssertEqual(fileIndex, expectedFiles.count, @"Incorrect number of files encountered");
|
|
}
|
|
|
|
|
|
@end
|