[Tests] Add a test for the minimal GZip file and other edge cases

This commit is contained in:
Timofey Solomko
2022-05-17 13:31:58 +03:00
parent bf0a48f78f
commit d63fb86f49
3 changed files with 24 additions and 1 deletions
+4
View File
@@ -222,6 +222,7 @@
E60CBA8A26AF379200A20130 /* test_only_dir_header.tar in Resources */ = {isa = PBXBuildFile; fileRef = E60CBA8926AF379200A20130 /* test_only_dir_header.tar */; };
E631055927084D5D006EACC3 /* LZ4+Compress.swift in Sources */ = {isa = PBXBuildFile; fileRef = E631055827084D5D006EACC3 /* LZ4+Compress.swift */; };
E6421E8F271B54C6000359B6 /* test_7z_lz4.7z in Resources */ = {isa = PBXBuildFile; fileRef = E6421E8E271B54C6000359B6 /* test_7z_lz4.7z */; };
E644E11E2833AB2400EEFBAD /* minimal.gz in Resources */ = {isa = PBXBuildFile; fileRef = E644E11D2833AB2400EEFBAD /* minimal.gz */; };
E648151D26A889B8009261F0 /* TarHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = E648151C26A889B8009261F0 /* TarHeader.swift */; };
E64F71BC26AAFD6A008BB308 /* Data+Tar.swift in Sources */ = {isa = PBXBuildFile; fileRef = E64F71BB26AAFD6A008BB308 /* Data+Tar.swift */; };
E6522FB42789AF9600026B56 /* TarReaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6522FB32789AF9600026B56 /* TarReaderTests.swift */; };
@@ -506,6 +507,7 @@
E631055827084D5D006EACC3 /* LZ4+Compress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LZ4+Compress.swift"; sourceTree = "<group>"; };
E631055A27086132006EACC3 /* SWCompression.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = SWCompression.xctestplan; path = SWCompression.xcodeproj/SWCompression.xctestplan; sourceTree = SOURCE_ROOT; };
E6421E8E271B54C6000359B6 /* test_7z_lz4.7z */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_7z_lz4.7z; sourceTree = "<group>"; };
E644E11D2833AB2400EEFBAD /* minimal.gz */ = {isa = PBXFileReference; lastKnownFileType = archive.gzip; path = minimal.gz; sourceTree = "<group>"; };
E648151C26A889B8009261F0 /* TarHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TarHeader.swift; sourceTree = "<group>"; };
E64F71BB26AAFD6A008BB308 /* Data+Tar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+Tar.swift"; sourceTree = "<group>"; };
E6522FB32789AF9600026B56 /* TarReaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TarReaderTests.swift; sourceTree = "<group>"; };
@@ -868,6 +870,7 @@
06F065B81FFB763300312A82 /* GZip */ = {
isa = PBXGroup;
children = (
E644E11D2833AB2400EEFBAD /* minimal.gz */,
06F065BA1FFB763300312A82 /* test1.gz */,
06F065BF1FFB763300312A82 /* test2.gz */,
06F065BC1FFB763300312A82 /* test3.gz */,
@@ -1283,6 +1286,7 @@
069864CA21403CE700755D9B /* test_sha256.xz in Resources */,
E652D8F3263D670900FC229B /* test_nonstandard_runlength.bz2 in Resources */,
06F0663D1FFB763400312A82 /* test2.xz in Resources */,
E644E11E2833AB2400EEFBAD /* minimal.gz in Resources */,
06F066351FFB763400312A82 /* test5.xz in Resources */,
06F066631FFB763400312A82 /* test_complicated_coding_scheme.7z in Resources */,
E652FECE27007E79006BC312 /* test8.lz4 in Resources */,
+19
View File
@@ -195,4 +195,23 @@ class GzipTests: XCTestCase {
}
}
func testMinimal() throws {
// In this test we test several things:
// - that the archive consisting only of the minimal header is successfully processed,
// - that the mtime field with the value 0 correctly results in a `GzipHeader.modificationTime == nil`,
// - that the `GzipArchive.multiUnarchive(archive:)` works on a single member archive.
let testData = try Constants.data(forTest: "minimal", withType: GzipTests.testType)
let members = try GzipArchive.multiUnarchive(archive: testData)
XCTAssertEqual(members.count, 1)
if let member = members.first {
XCTAssertEqual(member.header.compressionMethod, .deflate)
XCTAssertNil(member.header.modificationTime)
XCTAssertEqual(member.header.osType, .unix)
XCTAssertNil(member.header.fileName)
XCTAssertNil(member.header.comment)
XCTAssertFalse(member.header.isTextFile)
XCTAssertEqual(member.data, Data())
}
}
}