mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-06-23 14:56:41 +00:00
[Tests] Add test for tar container with file with negative mtime
In this case base-256 encoding is also used
This commit is contained in:
@@ -63,6 +63,7 @@
|
||||
06955E491F65C761004D5D79 /* BZip2+Lengths.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06955E481F65C761004D5D79 /* BZip2+Lengths.swift */; };
|
||||
0698B10B2104E11200A7C551 /* test_gnu_inc_format.tar in Resources */ = {isa = PBXBuildFile; fileRef = 0698B10A2104E11200A7C551 /* test_gnu_inc_format.tar */; };
|
||||
0698B10D2106136500A7C551 /* test_big_num_field.tar in Resources */ = {isa = PBXBuildFile; fileRef = 0698B10C2106136500A7C551 /* test_big_num_field.tar */; };
|
||||
0698B10F2106344200A7C551 /* test_negative_mtime.tar in Resources */ = {isa = PBXBuildFile; fileRef = 0698B10E2106344200A7C551 /* test_negative_mtime.tar */; };
|
||||
069AC20D1E02DB1D0041AC13 /* LZMA.swift in Sources */ = {isa = PBXBuildFile; fileRef = 069AC20C1E02DB1D0041AC13 /* LZMA.swift */; };
|
||||
069D0FF01E0D6CB600D8AA87 /* LZMARangeDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 069D0FEF1E0D6CB600D8AA87 /* LZMARangeDecoder.swift */; };
|
||||
069D0FF51E0D6CD000D8AA87 /* LZMABitTreeDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 069D0FF41E0D6CD000D8AA87 /* LZMABitTreeDecoder.swift */; };
|
||||
@@ -273,6 +274,7 @@
|
||||
06955E481F65C761004D5D79 /* BZip2+Lengths.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "BZip2+Lengths.swift"; sourceTree = "<group>"; };
|
||||
0698B10A2104E11200A7C551 /* test_gnu_inc_format.tar */ = {isa = PBXFileReference; lastKnownFileType = archive.tar; path = test_gnu_inc_format.tar; sourceTree = "<group>"; };
|
||||
0698B10C2106136500A7C551 /* test_big_num_field.tar */ = {isa = PBXFileReference; lastKnownFileType = archive.tar; path = test_big_num_field.tar; sourceTree = "<group>"; };
|
||||
0698B10E2106344200A7C551 /* test_negative_mtime.tar */ = {isa = PBXFileReference; lastKnownFileType = archive.tar; path = test_negative_mtime.tar; sourceTree = "<group>"; };
|
||||
069AC20C1E02DB1D0041AC13 /* LZMA.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LZMA.swift; path = Sources/LZMA/LZMA.swift; sourceTree = SOURCE_ROOT; };
|
||||
069D0FEF1E0D6CB600D8AA87 /* LZMARangeDecoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LZMARangeDecoder.swift; sourceTree = "<group>"; };
|
||||
069D0FF41E0D6CD000D8AA87 /* LZMABitTreeDecoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LZMABitTreeDecoder.swift; sourceTree = "<group>"; };
|
||||
@@ -762,6 +764,7 @@
|
||||
064D01AA20FD077D00CAE058 /* test_unicode_ustar.tar */,
|
||||
0698B10A2104E11200A7C551 /* test_gnu_inc_format.tar */,
|
||||
0698B10C2106136500A7C551 /* test_big_num_field.tar */,
|
||||
0698B10E2106344200A7C551 /* test_negative_mtime.tar */,
|
||||
);
|
||||
path = TAR;
|
||||
sourceTree = "<group>";
|
||||
@@ -991,6 +994,7 @@
|
||||
06F066401FFB763400312A82 /* test_zip_bzip2.zip in Resources */,
|
||||
06F066461FFB763400312A82 /* test_empty_file.zip in Resources */,
|
||||
06F066331FFB763400312A82 /* random_file.zlib in Resources */,
|
||||
0698B10F2106344200A7C551 /* test_negative_mtime.tar in Resources */,
|
||||
06F066561FFB763400312A82 /* SWCompressionSourceCode.tar in Resources */,
|
||||
06F0663D1FFB763400312A82 /* test2.xz in Resources */,
|
||||
06F066351FFB763400312A82 /* test5.xz in Resources */,
|
||||
|
||||
@@ -333,4 +333,28 @@ class TarTests: XCTestCase {
|
||||
XCTAssertNil(entries[0].comment)
|
||||
}
|
||||
|
||||
func testNegativeMtime() throws {
|
||||
guard let testData = Constants.data(forTest: "test_negative_mtime", withType: TarTests.testType) else {
|
||||
XCTFail("Unable to get test data.")
|
||||
return
|
||||
}
|
||||
|
||||
XCTAssertEqual(try TarContainer.formatOf(container: testData), .gnu)
|
||||
|
||||
let entries = try TarContainer.open(container: testData)
|
||||
|
||||
XCTAssertEqual(entries.count, 1)
|
||||
XCTAssertEqual(entries[0].info.name, "file")
|
||||
XCTAssertEqual(entries[0].info.type, .regular)
|
||||
XCTAssertEqual(entries[0].info.size, 27)
|
||||
XCTAssertEqual(entries[0].info.ownerID, 501)
|
||||
XCTAssertEqual(entries[0].info.groupID, 20)
|
||||
XCTAssertEqual(entries[0].info.ownerUserName, "timofeysolomko")
|
||||
XCTAssertEqual(entries[0].info.ownerGroupName, "staff")
|
||||
XCTAssertEqual(entries[0].info.permissions, Permissions(rawValue: 420))
|
||||
XCTAssertEqual(entries[0].info.modificationTime, Date(timeIntervalSince1970: -313006414))
|
||||
XCTAssertNil(entries[0].info.comment)
|
||||
XCTAssertEqual(entries[0].data, "File with negative mtime.\n\n".data(using: .utf8))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
Submodule Tests/Test Files updated: c1331d1c93...884353269c
Reference in New Issue
Block a user