diff --git a/zipzap.xcodeproj/project.pbxproj b/zipzap.xcodeproj/project.pbxproj index fef3d6d6..365dd375 100644 --- a/zipzap.xcodeproj/project.pbxproj +++ b/zipzap.xcodeproj/project.pbxproj @@ -33,7 +33,6 @@ D88E8E09163816FD002207B3 /* ZZOldArchiveEntry.mm in Sources */ = {isa = PBXBuildFile; fileRef = D88E8E06163816FD002207B3 /* ZZOldArchiveEntry.mm */; }; D88E8E0A16394A24002207B3 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D899CF8A162C5EC100112F49 /* Foundation.framework */; }; D88E8E0C16394B49002207B3 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D88E8E0B16394B49002207B3 /* ApplicationServices.framework */; }; - D899CF98162C5EC100112F49 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D899CF97162C5EC100112F49 /* SenTestingKit.framework */; }; D899CF9C162C5EC100112F49 /* libzipzap.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D899CF82162C5EC100112F49 /* libzipzap.a */; }; D899CFA2162C5EC100112F49 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = D899CFA0162C5EC100112F49 /* InfoPlist.strings */; }; D899CFEA162C608300112F49 /* ZZArchiveEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = D899CFD8162C608300112F49 /* ZZArchiveEntry.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -74,6 +73,7 @@ D8B0FD661640A77F00727A70 /* zipzap.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = D8B0FD611640A6B000727A70 /* zipzap.h */; }; D8B0FD671640A77F00727A70 /* ZZArchive.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = D899CFDA162C608300112F49 /* ZZArchive.h */; }; D8B0FD681640A77F00727A70 /* ZZArchiveEntry.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = D899CFD8162C608300112F49 /* ZZArchiveEntry.h */; }; + D8E3C26A17E6FF0E007D0020 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8E3C26917E6FF0E007D0020 /* XCTest.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -124,7 +124,7 @@ D899CF82162C5EC100112F49 /* libzipzap.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libzipzap.a; sourceTree = BUILT_PRODUCTS_DIR; }; D899CF8A162C5EC100112F49 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; D899CF8D162C5EC100112F49 /* zipzap-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "zipzap-Prefix.pch"; sourceTree = ""; }; - D899CF96162C5EC100112F49 /* zipzapTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = zipzapTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; + D899CF96162C5EC100112F49 /* zipzapTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = zipzapTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; D899CF97162C5EC100112F49 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; D899CF9F162C5EC100112F49 /* zipzapTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "zipzapTests-Info.plist"; sourceTree = ""; }; D899CFA1162C5EC100112F49 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -161,6 +161,7 @@ D8A32627163BFF3D008606AC /* README.markdown */ = {isa = PBXFileReference; lastKnownFileType = text; path = README.markdown; sourceTree = ""; }; D8A32673163C2240008606AC /* LICENSE.text */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE.text; sourceTree = ""; }; D8B0FD611640A6B000727A70 /* zipzap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zipzap.h; sourceTree = ""; }; + D8E3C26917E6FF0E007D0020 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -178,8 +179,8 @@ D899D01E162CD57700112F49 /* libc++.dylib in Frameworks */, D899D01C162CD51A00112F49 /* libz.dylib in Frameworks */, D88E8E0C16394B49002207B3 /* ApplicationServices.framework in Frameworks */, - D899CF98162C5EC100112F49 /* SenTestingKit.framework in Frameworks */, D88E8E0A16394A24002207B3 /* Foundation.framework in Frameworks */, + D8E3C26A17E6FF0E007D0020 /* XCTest.framework in Frameworks */, D899CF9C162C5EC100112F49 /* libzipzap.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -260,7 +261,7 @@ isa = PBXGroup; children = ( D899CF82162C5EC100112F49 /* libzipzap.a */, - D899CF96162C5EC100112F49 /* zipzapTests.octest */, + D899CF96162C5EC100112F49 /* zipzapTests.xctest */, D899CFB0162C5EEB00112F49 /* libzipzap.a */, ); name = Products; @@ -269,6 +270,7 @@ D899CF84162C5EC100112F49 /* Frameworks */ = { isa = PBXGroup; children = ( + D8E3C26917E6FF0E007D0020 /* XCTest.framework */, D899D01D162CD57700112F49 /* libc++.dylib */, D899D01B162CD51A00112F49 /* libz.dylib */, D88E8E0B16394B49002207B3 /* ApplicationServices.framework */, @@ -390,7 +392,7 @@ ); name = zipzapTests; productName = zipzapTests; - productReference = D899CF96162C5EC100112F49 /* zipzapTests.octest */; + productReference = D899CF96162C5EC100112F49 /* zipzapTests.xctest */; productType = "com.apple.product-type.bundle"; }; D899CFAF162C5EEB00112F49 /* zipzap (iOS) */ = { @@ -639,10 +641,17 @@ CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - FRAMEWORK_SEARCH_PATHS = "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\""; + FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_FRAMEWORKS_DIR)"; GCC_C_LANGUAGE_STANDARD = c99; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; @@ -655,8 +664,10 @@ ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ../zipzap; INFOPLIST_FILE = "zipzapTests/zipzapTests-Info.plist"; @@ -664,7 +675,7 @@ ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = zipzapTests; SDKROOT = macosx; - WRAPPER_EXTENSION = octest; + WRAPPER_EXTENSION = xctest; }; name = Debug; }; @@ -675,25 +686,35 @@ CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - FRAMEWORK_SEARCH_PATHS = "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\""; + ENABLE_NS_ASSERTIONS = NO; + FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_FRAMEWORKS_DIR)"; GCC_C_LANGUAGE_STANDARD = c99; GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "zipzap/zipzap-Prefix.pch"; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ../zipzap; INFOPLIST_FILE = "zipzapTests/zipzapTests-Info.plist"; MACOSX_DEPLOYMENT_TARGET = 10.7; PRODUCT_NAME = zipzapTests; SDKROOT = macosx; - WRAPPER_EXTENSION = octest; + WRAPPER_EXTENSION = xctest; }; name = Release; }; diff --git a/zipzapTests/ZZUnzipTests.h b/zipzapTests/ZZUnzipTests.h index 8a7290ae..56ec1744 100644 --- a/zipzapTests/ZZUnzipTests.h +++ b/zipzapTests/ZZUnzipTests.h @@ -6,9 +6,9 @@ // // -#import +#import -@interface ZZUnzipTests : SenTestCase +@interface ZZUnzipTests : XCTestCase - (void)setUp; - (void)tearDown; diff --git a/zipzapTests/ZZUnzipTests.m b/zipzapTests/ZZUnzipTests.m index efc8e846..ea75c04a 100644 --- a/zipzapTests/ZZUnzipTests.m +++ b/zipzapTests/ZZUnzipTests.m @@ -83,10 +83,10 @@ - (void)checkExtractingZipEntryStreamWithChunkSize:(NSUInteger)chunkSize [stream close]; - STAssertEqualObjects(streamData, + XCTAssertEqualObjects(streamData, [self dataAtFilePath:nextEntryFilePath], - @"[zipFile.entries[%d] stream] streamed data must match the original file data.", - index); + @"[zipFile.entries[%lu] stream] streamed data must match the original file data.", + (unsigned long)index); } } @@ -95,7 +95,7 @@ - (void)testZipEntryMetadata { NSArray* zipInfo = [ZZTasks zipInfoAtPath:_zipFileURL.path]; - STAssertEquals(_zipFile.entries.count, + XCTAssertEqual(_zipFile.entries.count, zipInfo.count, @"zipFile.entries.count must match the actual zip entry count."); @@ -104,65 +104,67 @@ - (void)testZipEntryMetadata ZZArchiveEntry* nextEntry = _zipFile.entries[index]; NSArray* nextInfo = zipInfo[index]; - STAssertTrue([nextEntry check:nil], @"zipFile.entries[%d] should check correctly.", index); + XCTAssertTrue([nextEntry check:nil], @"zipFile.entries[%lu] should check correctly.", (unsigned long)index); NSDateComponents* dateComponents = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] components: NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit fromDate:nextEntry.lastModified]; - STAssertEquals(dateComponents.year, + XCTAssertEqual(dateComponents.year, [[nextInfo[7] substringWithRange:NSMakeRange(0, 4)] integerValue], - @"zipFile.entries[%d].lastModified year must match the actual zip entry last modified year.", - index); - STAssertEquals(dateComponents.month, + @"zipFile.entries[%lu].lastModified year must match the actual zip entry last modified year.", + (unsigned long)index); + XCTAssertEqual(dateComponents.month, [[nextInfo[7] substringWithRange:NSMakeRange(4, 2)] integerValue], - @"zipFile.entries[%d].lastModified month must match the actual zip entry last modified month.", - index); - STAssertEquals(dateComponents.day, + @"zipFile.entries[%lu].lastModified month must match the actual zip entry last modified month.", + (unsigned long)index); + XCTAssertEqual(dateComponents.day, [[nextInfo[7] substringWithRange:NSMakeRange(6, 2)] integerValue], - @"zipFile.entries[%d].lastModified day must match the actual zip entry last modified day.", - index); - STAssertEquals(dateComponents.hour, + @"zipFile.entries[%lu].lastModified day must match the actual zip entry last modified day.", + (unsigned long)index); + XCTAssertEqual(dateComponents.hour, [[nextInfo[7] substringWithRange:NSMakeRange(9, 2)] integerValue], - @"zipFile.entries[%d].lastModified hour must match the actual zip entry last modified hour.", - index); - STAssertEquals(dateComponents.minute, + @"zipFile.entries[%lu].lastModified hour must match the actual zip entry last modified hour.", + (unsigned long)index); + XCTAssertEqual(dateComponents.minute, [[nextInfo[7] substringWithRange:NSMakeRange(11, 2)] integerValue], - @"zipFile.entries[%d].lastModified minute must match the actual zip entry last modified minute.", - index); - STAssertEqualsWithAccuracy(dateComponents.second, + @"zipFile.entries[%lu].lastModified minute must match the actual zip entry last modified minute.", + (unsigned long)index); + XCTAssertEqualWithAccuracy(dateComponents.second, [[nextInfo[7] substringWithRange:NSMakeRange(13, 2)] integerValue], 1, - @"zipFile.entries[%d].lastModified second must match the actual zip entry last modified second.", - index); + @"zipFile.entries[%lu].lastModified second must match the actual zip entry last modified second.", + (unsigned long)index); char nextModeString[12]; strmode(nextEntry.fileMode, nextModeString); nextModeString[10] = '\0'; // only want the first 10 chars of the parsed mode - STAssertEqualObjects([NSString stringWithUTF8String:nextModeString], + XCTAssertEqualObjects([NSString stringWithUTF8String:nextModeString], nextInfo[0], - @"zipFile.entries[%d].fileMode must match the actual zip entry file mode.", - index); + @"zipFile.entries[%lu].fileMode must match the actual zip entry file mode.", + (unsigned long)index); - STAssertEquals(nextEntry.uncompressedSize, + XCTAssertEqual(nextEntry.uncompressedSize, (NSUInteger)[nextInfo[3] integerValue], - @"zipFile.entries[%d].uncompressedSize must match the actual zip entry uncompressed size."); + @"zipFile.entries[%lu].uncompressedSize must match the actual zip entry uncompressed size.", + (unsigned long)index); - STAssertEquals(nextEntry.compressedSize, + XCTAssertEqual(nextEntry.compressedSize, (NSUInteger)[nextInfo[5] integerValue], - @"zipFile.entries[%d].compressedSize must match the actual zip entry compressed size."); + @"zipFile.entries[%lu].compressedSize must match the actual zip entry compressed size.", + (unsigned long)index); - STAssertEqualObjects(nextEntry.fileName, + XCTAssertEqualObjects(nextEntry.fileName, nextInfo[8], - @"zipFile.entries[%d].fileName must match the actual zip entry file name.", - index); + @"zipFile.entries[%lu].fileName must match the actual zip entry file name.", + (unsigned long)index); } } - (void)testZipEntryConsistentWithOriginalFile { - STAssertEquals(_zipFile.entries.count, + XCTAssertEqual(_zipFile.entries.count, _entryFilePaths.count, @"zipFile.entries.count must match the original file count."); @@ -171,21 +173,21 @@ - (void)testZipEntryConsistentWithOriginalFile ZZArchiveEntry* nextEntry = _zipFile.entries[index]; NSString* nextEntryFilePath = _entryFilePaths[index]; - STAssertEqualObjects(nextEntry.fileName, + XCTAssertEqualObjects(nextEntry.fileName, nextEntryFilePath, - @"zipFile.entries[%d].fileName must match the original file name.", - index); + @"zipFile.entries[%lu].fileName must match the original file name.", + (unsigned long)index); NSData* fileData = [self dataAtFilePath:nextEntryFilePath]; - STAssertEquals(nextEntry.crc32, + XCTAssertEqual(nextEntry.crc32, crc32(0, (const Bytef*)fileData.bytes, (uInt)fileData.length), - @"zipFile.entries[%d].crc32 must match the original file crc.", - index); + @"zipFile.entries[%lu].crc32 must match the original file crc.", + (unsigned long) (unsigned long)index); - STAssertEquals(nextEntry.uncompressedSize, + XCTAssertEqual(nextEntry.uncompressedSize, fileData.length, - @"zipFile.entries[%d].uncompressedSize must match the original file size.", - index); + @"zipFile.entries[%lu].uncompressedSize must match the original file size.", + (unsigned long) (unsigned long)index); } } @@ -195,7 +197,7 @@ - (void)testZipFromDataConsistentWithZipFromURL NSData* rawData = [NSData dataWithContentsOfURL:_zipFileURL]; ZZArchive* zipFileFromData = [[ZZArchive alloc] initWithData:rawData encoding:NSUTF8StringEncoding]; - STAssertEquals(_zipFile.entries.count, + XCTAssertEqual(_zipFile.entries.count, zipFileFromData.entries.count, @"zipFileFromData.entries.count must match the original file count."); @@ -204,19 +206,19 @@ - (void)testZipFromDataConsistentWithZipFromURL ZZArchiveEntry* zipEntry = _zipFile.entries[index]; ZZArchiveEntry* zipFromDataEntry = zipFileFromData.entries[index]; - STAssertEquals(zipEntry.compressed, zipFromDataEntry.compressed, @"zipFromDataEntry.entries[%s].compressed must match the reference entry.", index); + XCTAssertEqual(zipEntry.compressed, zipFromDataEntry.compressed, @"zipFromDataEntry.entries[%lu].compressed must match the reference entry.", (unsigned long)index); - STAssertEquals(zipEntry.crc32, zipFromDataEntry.crc32, @"zipFromDataEntry.entries[%s].crc32 must match the reference entry.", index); + XCTAssertEqual(zipEntry.crc32, zipFromDataEntry.crc32, @"zipFromDataEntry.entries[%lu].crc32 must match the reference entry.", (unsigned long)index); - STAssertEqualObjects(zipEntry.data, zipFromDataEntry.data, @"zipFromDataEntry.entries[%s].data must match the reference entry.", index); + XCTAssertEqualObjects(zipEntry.data, zipFromDataEntry.data, @"zipFromDataEntry.entries[%lu].data must match the reference entry.", (unsigned long)index); - STAssertEquals(zipEntry.fileMode, zipFromDataEntry.fileMode, @"zipFromDataEntry.entries[%s].fileMode must match the reference entry.", index); + XCTAssertEqual(zipEntry.fileMode, zipFromDataEntry.fileMode, @"zipFromDataEntry.entries[%lu].fileMode must match the reference entry.", (unsigned long)index); - STAssertEqualObjects(zipEntry.fileName, zipFromDataEntry.fileName, @"zipFromDataEntry.entries[%s].fileName must match the reference entry.", index); + XCTAssertEqualObjects(zipEntry.fileName, zipFromDataEntry.fileName, @"zipFromDataEntry.entries[%lu].fileName must match the reference entry.", (unsigned long)index); - STAssertEquals(zipEntry.compressedSize, zipFromDataEntry.compressedSize, @"zipFromDataEntry.entries[%s].compressedSize must match the reference entry.", index); + XCTAssertEqual(zipEntry.compressedSize, zipFromDataEntry.compressedSize, @"zipFromDataEntry.entries[%lu].compressedSize must match the reference entry.", (unsigned long)index); - STAssertEquals(zipEntry.uncompressedSize, zipFromDataEntry.uncompressedSize, @"zipFromDataEntry.entries[%s].uncompressedSize must match the reference entry.", index); + XCTAssertEqual(zipEntry.uncompressedSize, zipFromDataEntry.uncompressedSize, @"zipFromDataEntry.entries[%lu].uncompressedSize must match the reference entry.", (unsigned long)index); } } @@ -227,10 +229,10 @@ - (void)testExtractingZipEntryData ZZArchiveEntry* nextEntry = _zipFile.entries[index]; NSString* nextEntryFilePath = _entryFilePaths[index]; - STAssertEqualObjects(nextEntry.data, + XCTAssertEqualObjects(nextEntry.data, [self dataAtFilePath:nextEntryFilePath], - @"zipFile.entries[%d].data must match the original file data.", - index); + @"zipFile.entries[%lu].data must match the original file data.", + (unsigned long)index); } } @@ -253,10 +255,10 @@ - (void)testExtractingZipEntryDataProvider CGDataProviderRef dataProvider = [nextEntry newDataProvider]; CFDataRef providerData = CGDataProviderCopyData(dataProvider); - STAssertEqualObjects((__bridge NSData*)providerData, + XCTAssertEqualObjects((__bridge NSData*)providerData, [self dataAtFilePath:nextEntryFilePath], - @"[zipFile.entries[%d] newDataProvider] provided data must match the original file data.", - index); + @"[zipFile.entries[%lu] newDataProvider] provided data must match the original file data.", + (unsigned long)index); if (providerData) CFRelease(providerData); CGDataProviderRelease(dataProvider); @@ -282,10 +284,10 @@ - (void)testExtractingZipEntryDataProviderImage NULL); CGImageRef fileImage = CGImageSourceCreateImageAtIndex(fileImageSource, 0, NULL); - STAssertEqualObjects((__bridge_transfer NSData*)CGDataProviderCopyData(CGImageGetDataProvider(dataProviderImage)), + XCTAssertEqualObjects((__bridge_transfer NSData*)CGDataProviderCopyData(CGImageGetDataProvider(dataProviderImage)), (__bridge_transfer NSData*)CGDataProviderCopyData(CGImageGetDataProvider(fileImage)), - @"[zipFile.entries[%d] newDataProvider] image data must match the original image data.", - index); + @"[zipFile.entries[%lu] newDataProvider] image data must match the original image data.", + (unsigned long)index); CGImageRelease(fileImage); if (fileImageSource) diff --git a/zipzapTests/ZZZipTests.h b/zipzapTests/ZZZipTests.h index a06b3063..78dd1136 100644 --- a/zipzapTests/ZZZipTests.h +++ b/zipzapTests/ZZZipTests.h @@ -6,9 +6,9 @@ // // -#import +#import -@interface ZZZipTests : SenTestCase +@interface ZZZipTests : XCTestCase - (void)setUp; - (void)tearDown; diff --git a/zipzapTests/ZZZipTests.m b/zipzapTests/ZZZipTests.m index 053bc8b1..d818a211 100644 --- a/zipzapTests/ZZZipTests.m +++ b/zipzapTests/ZZZipTests.m @@ -126,7 +126,7 @@ - (void)checkZipEntryRecords:(NSArray*)newEntryRecords NSArray* zipInfo = [ZZTasks zipInfoAtPath:_zipFileURL.path]; - STAssertEquals(zipInfo.count, + XCTAssertEqual(zipInfo.count, newEntryRecords.count, @"Zip entry count must match new entry count."); @@ -138,66 +138,66 @@ - (void)checkZipEntryRecords:(NSArray*)newEntryRecords char nextModeString[12]; strmode([nextNewEntry[@"fileMode"] unsignedShortValue], nextModeString); nextModeString[10] = '\0'; // only want the first 10 chars of the parsed mode - STAssertEqualObjects([NSString stringWithUTF8String:nextModeString], + XCTAssertEqualObjects([NSString stringWithUTF8String:nextModeString], nextZipInfo[0], - @"Zip entry #%d file mode must match new entry file mode.", - index); + @"Zip entry #%lu file mode must match new entry file mode.", + (unsigned long)index); - STAssertEqualObjects(nextZipInfo[1], + XCTAssertEqualObjects(nextZipInfo[1], @"3.0", - @"Zip entry #%d version made by should be 3.0.", - index); - STAssertEqualObjects(nextZipInfo[2], + @"Zip entry #%lu version made by should be 3.0.", + (unsigned long)index); + XCTAssertEqualObjects(nextZipInfo[2], @"unx", - @"Zip entry #%d file attribute should be unix.", - index); + @"Zip entry #%lu file attribute should be unix.", + (unsigned long)index); if (![nextNewEntry[@"compressed"] boolValue]) - STAssertEqualObjects(nextZipInfo[3], + XCTAssertEqualObjects(nextZipInfo[3], nextZipInfo[5], - @"Zip entry #%d compressed size must match uncompressed size if uncompressed.", - index); + @"Zip entry #%lu compressed size must match uncompressed size if uncompressed.", + (unsigned long)index); - STAssertEqualObjects(nextZipInfo[6], + XCTAssertEqualObjects(nextZipInfo[6], [nextNewEntry[@"compressed"] boolValue]? @"defN" : @"stor", - @"Zip entry #%d compression method must match new entry compressed.", - index); + @"Zip entry #%lu compression method must match new entry compressed.", + (unsigned long)index); NSDateComponents* dateComponents = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] components: NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit fromDate:nextNewEntry[@"lastModified"]]; - STAssertEquals(dateComponents.year, + XCTAssertEqual(dateComponents.year, [[nextZipInfo[7] substringWithRange:NSMakeRange(0, 4)] integerValue], - @"Zip entry #%d last modified year must match the new entry last modified year.", - index); - STAssertEquals(dateComponents.month, + @"Zip entry #%lu last modified year must match the new entry last modified year.", + (unsigned long)index); + XCTAssertEqual(dateComponents.month, [[nextZipInfo[7] substringWithRange:NSMakeRange(4, 2)] integerValue], - @"Zip entry #%d last modified month must match the new entry last modified month.", - index); - STAssertEquals(dateComponents.day, + @"Zip entry #%lu last modified month must match the new entry last modified month.", + (unsigned long)index); + XCTAssertEqual(dateComponents.day, [[nextZipInfo[7] substringWithRange:NSMakeRange(6, 2)] integerValue], - @"Zip entry #%d last modified day must match the new entry last modified day.", - index); - STAssertEquals(dateComponents.hour, + @"Zip entry #%lu last modified day must match the new entry last modified day.", + (unsigned long)index); + XCTAssertEqual(dateComponents.hour, [[nextZipInfo[7] substringWithRange:NSMakeRange(9, 2)] integerValue], - @"Zip entry #%d last modified hour must match the new entry last modified hour.", - index); - STAssertEquals(dateComponents.minute, + @"Zip entry #%lu last modified hour must match the new entry last modified hour.", + (unsigned long)index); + XCTAssertEqual(dateComponents.minute, [[nextZipInfo[7] substringWithRange:NSMakeRange(11, 2)] integerValue], - @"Zip entry #%d last modified minute must match the new entry last modified minute.", - index); - STAssertEqualsWithAccuracy(dateComponents.second, + @"Zip entry #%lu last modified minute must match the new entry last modified minute.", + (unsigned long)index); + XCTAssertEqualWithAccuracy(dateComponents.second, [[nextZipInfo[7] substringWithRange:NSMakeRange(13, 2)] integerValue], 1, - @"Zip entry #%d last modified second must match the new entry last modified second.", - index); + @"Zip entry #%lu last modified second must match the new entry last modified second.", + (unsigned long)index); - STAssertEqualObjects(nextZipInfo[8], + XCTAssertEqualObjects(nextZipInfo[8], nextNewEntry[@"fileName"], - @"Zip entry #%d file name must match new entry file name.", - index); + @"Zip entry #%lu file name must match new entry file name.", + (unsigned long)index); if (checkerBlock) @@ -205,27 +205,27 @@ - (void)checkZipEntryRecords:(NSArray*)newEntryRecords NSData* fileData = checkerBlock(nextNewEntry[@"fileName"]); NSString* fileDataLength = [NSString stringWithFormat:@"%lu", fileData.length]; - STAssertEqualObjects(nextZipInfo[3], + XCTAssertEqualObjects(nextZipInfo[3], fileDataLength, - @"Zip entry #%d uncompressed size must match original file length.", - index); + @"Zip entry #%lu uncompressed size must match original file length.", + (unsigned long)index); NSData* zipData = [ZZTasks unzipFile:nextNewEntry[@"fileName"] fromPath:_zipFileURL.path]; - STAssertEqualObjects(zipData, + XCTAssertEqualObjects(zipData, fileData, - @"Zip entry #%d file data must match original file data.", - index); + @"Zip entry #%lu file data must match original file data.", + (unsigned long)index); } } - STAssertTrue([ZZTasks testZipAtPath:_zipFileURL.path], @"zipFile must pass unzip test."); + XCTAssertTrue([ZZTasks testZipAtPath:_zipFileURL.path], @"zipFile must pass unzip test."); } - (void)checkCreatingZipEntriesWithNoCheckEntries:(NSArray*)entries { - STAssertTrue([_zipFile updateEntries:entries error:nil], @"Updating entries should succeed."); + XCTAssertTrue([_zipFile updateEntries:entries error:nil], @"Updating entries should succeed."); [self checkZipEntryRecords:[self recordsForZipEntries:entries] checkerBlock:nil]; @@ -239,7 +239,7 @@ - (void)checkCreatingZipEntriesWithDataCompressed:(BOOL)compressed compress:compressed dataBlock:^(NSError** error){ return [self dataAtFilePath:entryFilePath]; }]]; - STAssertTrue([_zipFile updateEntries:newEntries error:nil], @"Updating entries should succeed."); + XCTAssertTrue([_zipFile updateEntries:newEntries error:nil], @"Updating entries should succeed."); [self checkZipEntryRecords:[self recordsForZipEntries:newEntries] checkerBlock:^(NSString* fileName){ return [self dataAtFilePath:fileName]; }]; } @@ -272,7 +272,7 @@ - (void)checkCreatingZipEntriesWithStreamCompressed:(BOOL)compressed chunkSize:( return YES; }]]; - STAssertTrue([_zipFile updateEntries:newEntries error:nil], @"Updating entries should succeed."); + XCTAssertTrue([_zipFile updateEntries:newEntries error:nil], @"Updating entries should succeed."); [self checkZipEntryRecords:[self recordsForZipEntries:newEntries] checkerBlock:^(NSString* fileName){ return [self dataAtFilePath:fileName]; }]; } @@ -339,7 +339,7 @@ - (void)checkCreatingZipEntriesWithImageCompressed:(BOOL)compressed }]]; } - STAssertTrue([_zipFile updateEntries:newEntries error:nil], @"Updating entries should succeed."); + XCTAssertTrue([_zipFile updateEntries:newEntries error:nil], @"Updating entries should succeed."); [self checkZipEntryRecords:[self recordsForZipEntries:newEntries] checkerBlock:^(NSString* fileName){ return fileNameCheck[fileName]; }]; } @@ -355,7 +355,7 @@ - (void)checkUpdatingZipEntriesWithFile:(NSString*)file // since entries contains existing entries from the zip file, we need to take a record first before applying it NSArray* records = [self recordsForZipEntries:entries]; - STAssertTrue([_zipFile updateEntries:entries error:nil], @"Updating entries should succeed."); + XCTAssertTrue([_zipFile updateEntries:entries error:nil], @"Updating entries should succeed."); [self checkZipEntryRecords:records checkerBlock:^(NSString* fileName){ return [self dataAtFilePath:fileName]; }]; } @@ -370,7 +370,7 @@ - (void)checkCreatingZipEntriesToUpdate:(BOOL)update withBadEntry:(ZZArchiveEntr if (update) { - STAssertTrue([_zipFile updateEntries:newEntries error:nil], @"Updating entries should succeed."); + XCTAssertTrue([_zipFile updateEntries:newEntries error:nil], @"Updating entries should succeed."); newEntries = [NSMutableArray arrayWithArray:_zipFile.entries]; } @@ -378,20 +378,20 @@ - (void)checkCreatingZipEntriesToUpdate:(BOOL)update withBadEntry:(ZZArchiveEntr [newEntries insertObject:badEntry atIndex:insertIndex]; NSError* __autoreleasing error; - STAssertFalse([_zipFile updateEntries:newEntries error:&error], + XCTAssertFalse([_zipFile updateEntries:newEntries error:&error], @"Updating entries with bad entry should fail."); - STAssertNotNil(error, + XCTAssertNotNil(error, @"Error object should be set."); - STAssertEqualObjects(error.domain, + XCTAssertEqualObjects(error.domain, ZZErrorDomain, @"Error domain should be in zipzap."); - STAssertEquals((ZZErrorCode)error.code, + XCTAssertEqual((ZZErrorCode)error.code, ZZLocalFileWriteErrorCode, @"Error code should be bad local file write."); - STAssertEquals([error.userInfo[ZZEntryIndexKey] unsignedIntegerValue], + XCTAssertEqual([error.userInfo[ZZEntryIndexKey] unsignedIntegerValue], insertIndex, @"Error entry index should be bad entry index."); - STAssertEqualObjects(error.userInfo[NSUnderlyingErrorKey], + XCTAssertEqualObjects(error.userInfo[NSUnderlyingErrorKey], [self someError], @"Error underlying error should be same as passed-in error."); @@ -400,7 +400,7 @@ - (void)checkCreatingZipEntriesToUpdate:(BOOL)update withBadEntry:(ZZArchiveEntr if (!_zipFile.URL) // archive is a data archive, need to save it before we can check [_zipFile.contents writeToURL:_zipFileURL atomically:YES]; - STAssertTrue([ZZTasks testZipAtPath:_zipFileURL.path], @"zipFile must pass unzip test."); + XCTAssertTrue([ZZTasks testZipAtPath:_zipFileURL.path], @"zipFile must pass unzip test."); } }