[Tests] Add tests for different format minor versions of 7-Zip

This commit is contained in:
Timofey Solomko
2021-09-19 17:19:05 +03:00
parent aefacf3e16
commit 33cb74cdeb
3 changed files with 74 additions and 1 deletions
+12
View File
@@ -220,6 +220,9 @@
E652D8F5263D678000FC229B /* test_nonstandard_runlength.answer in Resources */ = {isa = PBXBuildFile; fileRef = E652D8F4263D678000FC229B /* test_nonstandard_runlength.answer */; };
E66F36242538726E00076A6E /* test_empty.lzma in Resources */ = {isa = PBXBuildFile; fileRef = E66F36232538726E00076A6E /* test_empty.lzma */; };
E66F362C2538E2B700076A6E /* test_empty.zlib in Resources */ = {isa = PBXBuildFile; fileRef = E66F362B2538E2B700076A6E /* test_empty.zlib */; };
E6EDD6A826F7767F00884532 /* test_minor_version_3.7z in Resources */ = {isa = PBXBuildFile; fileRef = E6EDD6A626F7767E00884532 /* test_minor_version_3.7z */; };
E6EDD6A926F7767F00884532 /* test_minor_version_4.7z in Resources */ = {isa = PBXBuildFile; fileRef = E6EDD6A726F7767E00884532 /* test_minor_version_4.7z */; };
E6EDD6AC26F77C0E00884532 /* test_minor_version_2.7z in Resources */ = {isa = PBXBuildFile; fileRef = E6EDD6AB26F77C0E00884532 /* test_minor_version_2.7z */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -447,6 +450,9 @@
E652D8F4263D678000FC229B /* test_nonstandard_runlength.answer */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_nonstandard_runlength.answer; sourceTree = "<group>"; };
E66F36232538726E00076A6E /* test_empty.lzma */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_empty.lzma; sourceTree = "<group>"; };
E66F362B2538E2B700076A6E /* test_empty.zlib */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_empty.zlib; sourceTree = "<group>"; };
E6EDD6A626F7767E00884532 /* test_minor_version_3.7z */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_minor_version_3.7z; sourceTree = "<group>"; };
E6EDD6A726F7767E00884532 /* test_minor_version_4.7z */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_minor_version_4.7z; sourceTree = "<group>"; };
E6EDD6AB26F77C0E00884532 /* test_minor_version_2.7z */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_minor_version_2.7z; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -883,6 +889,9 @@
06F066061FFB763300312A82 /* test_win.7z */,
0627A4D220FE521B0023987C /* test_unicode.7z */,
068D070321368617002A6C3B /* test_delta_filter.7z */,
E6EDD6AB26F77C0E00884532 /* test_minor_version_2.7z */,
E6EDD6A626F7767E00884532 /* test_minor_version_3.7z */,
E6EDD6A726F7767E00884532 /* test_minor_version_4.7z */,
06F066071FFB763300312A82 /* SWCompressionSourceCode.7z */,
);
path = 7z;
@@ -991,6 +1000,7 @@
06F066201FFB763300312A82 /* test1.answer in Resources */,
06F0664E1FFB763400312A82 /* test_v7.tar in Resources */,
06F0662E1FFB763400312A82 /* test2.gz in Resources */,
E6EDD6AC26F77C0E00884532 /* test_minor_version_2.7z in Resources */,
06F0665C1FFB763400312A82 /* test9.lzma in Resources */,
06F066661FFB763400312A82 /* test3.7z in Resources */,
06F0664B1FFB763400312A82 /* test.tar in Resources */,
@@ -1073,6 +1083,7 @@
06F066351FFB763400312A82 /* test5.xz in Resources */,
06F066631FFB763400312A82 /* test_complicated_coding_scheme.7z in Resources */,
06F066641FFB763400312A82 /* test_anti_file.7z in Resources */,
E6EDD6A826F7767F00884532 /* test_minor_version_3.7z in Resources */,
064D01AD20FD077D00CAE058 /* test_unicode_pax.tar in Resources */,
06F0665E1FFB763400312A82 /* test_empty_cont.7z in Resources */,
06F066731FFB763400312A82 /* test3.bz2 in Resources */,
@@ -1083,6 +1094,7 @@
06F066571FFB763400312A82 /* test_empty_file.tar in Resources */,
06F066441FFB763400312A82 /* test_data_descriptor.zip in Resources */,
06F066581FFB763400312A82 /* full_test.tar in Resources */,
E6EDD6A926F7767F00884532 /* test_minor_version_4.7z in Resources */,
06F0662B1FFB763400312A82 /* test3.gz in Resources */,
06F0664C1FFB763400312A82 /* test_pax.tar in Resources */,
06F0663A1FFB763400312A82 /* test_multi.xz in Resources */,
+61
View File
@@ -393,4 +393,65 @@ class SevenZipTests: XCTestCase {
XCTAssertEqual(entries[0].data, answerData)
}
func testFormatMinorVersions() throws {
let answerData = try Constants.data(forAnswer: "test2")
var testData = try Constants.data(forTest: "test_minor_version_2", withType: SevenZipTests.testType)
var entries = try SevenZipContainer.open(container: testData)
XCTAssertEqual(entries.count, 1)
XCTAssertEqual(entries[0].info.name, "test2.answer")
XCTAssertEqual(entries[0].info.type, .regular)
XCTAssertEqual(entries[0].info.size, answerData.count)
XCTAssertEqual(entries[0].info.permissions, Permissions(rawValue: 0))
XCTAssertEqual(entries[0].info.dosAttributes, DosAttributes(rawValue: 0x20))
// Checking times' values is a bit difficult since they are extremely precise.
XCTAssertNotNil(entries[0].info.modificationTime)
XCTAssertNil(entries[0].info.accessTime)
XCTAssertNil(entries[0].info.creationTime)
XCTAssertEqual(entries[0].info.hasStream, true)
XCTAssertEqual(entries[0].info.isEmpty, false)
XCTAssertEqual(entries[0].info.isAnti, false)
XCTAssertEqual(entries[0].info.crc, 4168830779)
XCTAssertEqual(entries[0].data, answerData)
testData = try Constants.data(forTest: "test_minor_version_3", withType: SevenZipTests.testType)
entries = try SevenZipContainer.open(container: testData)
XCTAssertEqual(entries.count, 1)
XCTAssertEqual(entries[0].info.name, "test2.answer")
XCTAssertEqual(entries[0].info.type, .regular)
XCTAssertEqual(entries[0].info.size, answerData.count)
XCTAssertEqual(entries[0].info.permissions, Permissions(rawValue: 420))
XCTAssertEqual(entries[0].info.dosAttributes, DosAttributes(rawValue: 0x20))
// Checking times' values is a bit difficult since they are extremely precise.
XCTAssertNotNil(entries[0].info.modificationTime)
XCTAssertNotNil(entries[0].info.accessTime)
XCTAssertNotNil(entries[0].info.creationTime)
XCTAssertEqual(entries[0].info.hasStream, true)
XCTAssertEqual(entries[0].info.isEmpty, false)
XCTAssertEqual(entries[0].info.isAnti, false)
XCTAssertEqual(entries[0].info.crc, 4168830779)
XCTAssertEqual(entries[0].data, answerData)
testData = try Constants.data(forTest: "test_minor_version_4", withType: SevenZipTests.testType)
entries = try SevenZipContainer.open(container: testData)
XCTAssertEqual(entries.count, 1)
XCTAssertEqual(entries[0].info.name, "test2.answer")
XCTAssertEqual(entries[0].info.type, .regular)
XCTAssertEqual(entries[0].info.size, answerData.count)
XCTAssertEqual(entries[0].info.permissions, Permissions(rawValue: 420))
XCTAssertEqual(entries[0].info.dosAttributes, DosAttributes(rawValue: 0x20))
// Checking times' values is a bit difficult since they are extremely precise.
XCTAssertNotNil(entries[0].info.modificationTime)
XCTAssertNotNil(entries[0].info.accessTime)
XCTAssertNotNil(entries[0].info.creationTime)
XCTAssertEqual(entries[0].info.hasStream, true)
XCTAssertEqual(entries[0].info.isEmpty, false)
XCTAssertEqual(entries[0].info.isAnti, false)
XCTAssertEqual(entries[0].info.crc, 4168830779)
XCTAssertEqual(entries[0].data, answerData)
}
}