Skip to content

Commit 33cb74c

Browse files
committed
[Tests] Add tests for different format minor versions of 7-Zip
1 parent aefacf3 commit 33cb74c

3 files changed

Lines changed: 74 additions & 1 deletion

File tree

SWCompression.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@
220220
E652D8F5263D678000FC229B /* test_nonstandard_runlength.answer in Resources */ = {isa = PBXBuildFile; fileRef = E652D8F4263D678000FC229B /* test_nonstandard_runlength.answer */; };
221221
E66F36242538726E00076A6E /* test_empty.lzma in Resources */ = {isa = PBXBuildFile; fileRef = E66F36232538726E00076A6E /* test_empty.lzma */; };
222222
E66F362C2538E2B700076A6E /* test_empty.zlib in Resources */ = {isa = PBXBuildFile; fileRef = E66F362B2538E2B700076A6E /* test_empty.zlib */; };
223+
E6EDD6A826F7767F00884532 /* test_minor_version_3.7z in Resources */ = {isa = PBXBuildFile; fileRef = E6EDD6A626F7767E00884532 /* test_minor_version_3.7z */; };
224+
E6EDD6A926F7767F00884532 /* test_minor_version_4.7z in Resources */ = {isa = PBXBuildFile; fileRef = E6EDD6A726F7767E00884532 /* test_minor_version_4.7z */; };
225+
E6EDD6AC26F77C0E00884532 /* test_minor_version_2.7z in Resources */ = {isa = PBXBuildFile; fileRef = E6EDD6AB26F77C0E00884532 /* test_minor_version_2.7z */; };
223226
/* End PBXBuildFile section */
224227

225228
/* Begin PBXContainerItemProxy section */
@@ -447,6 +450,9 @@
447450
E652D8F4263D678000FC229B /* test_nonstandard_runlength.answer */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_nonstandard_runlength.answer; sourceTree = "<group>"; };
448451
E66F36232538726E00076A6E /* test_empty.lzma */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_empty.lzma; sourceTree = "<group>"; };
449452
E66F362B2538E2B700076A6E /* test_empty.zlib */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_empty.zlib; sourceTree = "<group>"; };
453+
E6EDD6A626F7767E00884532 /* test_minor_version_3.7z */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_minor_version_3.7z; sourceTree = "<group>"; };
454+
E6EDD6A726F7767E00884532 /* test_minor_version_4.7z */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_minor_version_4.7z; sourceTree = "<group>"; };
455+
E6EDD6AB26F77C0E00884532 /* test_minor_version_2.7z */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_minor_version_2.7z; sourceTree = "<group>"; };
450456
/* End PBXFileReference section */
451457

452458
/* Begin PBXFrameworksBuildPhase section */
@@ -883,6 +889,9 @@
883889
06F066061FFB763300312A82 /* test_win.7z */,
884890
0627A4D220FE521B0023987C /* test_unicode.7z */,
885891
068D070321368617002A6C3B /* test_delta_filter.7z */,
892+
E6EDD6AB26F77C0E00884532 /* test_minor_version_2.7z */,
893+
E6EDD6A626F7767E00884532 /* test_minor_version_3.7z */,
894+
E6EDD6A726F7767E00884532 /* test_minor_version_4.7z */,
886895
06F066071FFB763300312A82 /* SWCompressionSourceCode.7z */,
887896
);
888897
path = 7z;
@@ -991,6 +1000,7 @@
9911000
06F066201FFB763300312A82 /* test1.answer in Resources */,
9921001
06F0664E1FFB763400312A82 /* test_v7.tar in Resources */,
9931002
06F0662E1FFB763400312A82 /* test2.gz in Resources */,
1003+
E6EDD6AC26F77C0E00884532 /* test_minor_version_2.7z in Resources */,
9941004
06F0665C1FFB763400312A82 /* test9.lzma in Resources */,
9951005
06F066661FFB763400312A82 /* test3.7z in Resources */,
9961006
06F0664B1FFB763400312A82 /* test.tar in Resources */,
@@ -1073,6 +1083,7 @@
10731083
06F066351FFB763400312A82 /* test5.xz in Resources */,
10741084
06F066631FFB763400312A82 /* test_complicated_coding_scheme.7z in Resources */,
10751085
06F066641FFB763400312A82 /* test_anti_file.7z in Resources */,
1086+
E6EDD6A826F7767F00884532 /* test_minor_version_3.7z in Resources */,
10761087
064D01AD20FD077D00CAE058 /* test_unicode_pax.tar in Resources */,
10771088
06F0665E1FFB763400312A82 /* test_empty_cont.7z in Resources */,
10781089
06F066731FFB763400312A82 /* test3.bz2 in Resources */,
@@ -1083,6 +1094,7 @@
10831094
06F066571FFB763400312A82 /* test_empty_file.tar in Resources */,
10841095
06F066441FFB763400312A82 /* test_data_descriptor.zip in Resources */,
10851096
06F066581FFB763400312A82 /* full_test.tar in Resources */,
1097+
E6EDD6A926F7767F00884532 /* test_minor_version_4.7z in Resources */,
10861098
06F0662B1FFB763400312A82 /* test3.gz in Resources */,
10871099
06F0664C1FFB763400312A82 /* test_pax.tar in Resources */,
10881100
06F0663A1FFB763400312A82 /* test_multi.xz in Resources */,

Tests/SevenZipTests.swift

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,4 +393,65 @@ class SevenZipTests: XCTestCase {
393393
XCTAssertEqual(entries[0].data, answerData)
394394
}
395395

396+
func testFormatMinorVersions() throws {
397+
let answerData = try Constants.data(forAnswer: "test2")
398+
399+
var testData = try Constants.data(forTest: "test_minor_version_2", withType: SevenZipTests.testType)
400+
var entries = try SevenZipContainer.open(container: testData)
401+
402+
XCTAssertEqual(entries.count, 1)
403+
XCTAssertEqual(entries[0].info.name, "test2.answer")
404+
XCTAssertEqual(entries[0].info.type, .regular)
405+
XCTAssertEqual(entries[0].info.size, answerData.count)
406+
XCTAssertEqual(entries[0].info.permissions, Permissions(rawValue: 0))
407+
XCTAssertEqual(entries[0].info.dosAttributes, DosAttributes(rawValue: 0x20))
408+
// Checking times' values is a bit difficult since they are extremely precise.
409+
XCTAssertNotNil(entries[0].info.modificationTime)
410+
XCTAssertNil(entries[0].info.accessTime)
411+
XCTAssertNil(entries[0].info.creationTime)
412+
XCTAssertEqual(entries[0].info.hasStream, true)
413+
XCTAssertEqual(entries[0].info.isEmpty, false)
414+
XCTAssertEqual(entries[0].info.isAnti, false)
415+
XCTAssertEqual(entries[0].info.crc, 4168830779)
416+
XCTAssertEqual(entries[0].data, answerData)
417+
418+
testData = try Constants.data(forTest: "test_minor_version_3", withType: SevenZipTests.testType)
419+
entries = try SevenZipContainer.open(container: testData)
420+
421+
XCTAssertEqual(entries.count, 1)
422+
XCTAssertEqual(entries[0].info.name, "test2.answer")
423+
XCTAssertEqual(entries[0].info.type, .regular)
424+
XCTAssertEqual(entries[0].info.size, answerData.count)
425+
XCTAssertEqual(entries[0].info.permissions, Permissions(rawValue: 420))
426+
XCTAssertEqual(entries[0].info.dosAttributes, DosAttributes(rawValue: 0x20))
427+
// Checking times' values is a bit difficult since they are extremely precise.
428+
XCTAssertNotNil(entries[0].info.modificationTime)
429+
XCTAssertNotNil(entries[0].info.accessTime)
430+
XCTAssertNotNil(entries[0].info.creationTime)
431+
XCTAssertEqual(entries[0].info.hasStream, true)
432+
XCTAssertEqual(entries[0].info.isEmpty, false)
433+
XCTAssertEqual(entries[0].info.isAnti, false)
434+
XCTAssertEqual(entries[0].info.crc, 4168830779)
435+
XCTAssertEqual(entries[0].data, answerData)
436+
437+
testData = try Constants.data(forTest: "test_minor_version_4", withType: SevenZipTests.testType)
438+
entries = try SevenZipContainer.open(container: testData)
439+
440+
XCTAssertEqual(entries.count, 1)
441+
XCTAssertEqual(entries[0].info.name, "test2.answer")
442+
XCTAssertEqual(entries[0].info.type, .regular)
443+
XCTAssertEqual(entries[0].info.size, answerData.count)
444+
XCTAssertEqual(entries[0].info.permissions, Permissions(rawValue: 420))
445+
XCTAssertEqual(entries[0].info.dosAttributes, DosAttributes(rawValue: 0x20))
446+
// Checking times' values is a bit difficult since they are extremely precise.
447+
XCTAssertNotNil(entries[0].info.modificationTime)
448+
XCTAssertNotNil(entries[0].info.accessTime)
449+
XCTAssertNotNil(entries[0].info.creationTime)
450+
XCTAssertEqual(entries[0].info.hasStream, true)
451+
XCTAssertEqual(entries[0].info.isEmpty, false)
452+
XCTAssertEqual(entries[0].info.isAnti, false)
453+
XCTAssertEqual(entries[0].info.crc, 4168830779)
454+
XCTAssertEqual(entries[0].data, answerData)
455+
}
456+
396457
}

0 commit comments

Comments
 (0)