Minor code improvements.

This commit is contained in:
Timofey Solomko committed 2017-08-06 18:17:43 +03:00
1 parent a23b685008
commit b8eb63b834
4 files changed
+12 -10

No files matched your search

+4 -1
View File
@@ -60,7 +60,10 @@ class SevenZipFileInfo {
let names = bitReader.bytes(count: propertySize - 1)
var nextFile = 0
var nextName = 0
for i in stride(from: 0, to: names.count, by: 2) { // TODO: Understand what is going on here.
for i in stride(from: 0, to: names.count, by: 2) {
// End of file name is identified by two consequent NULL bytes.
// TODO: In Swift 4.0 we may try to convert dat to UTF16LE first,
// and then split it into strings?
if names[i] == 0 && names[i + 1] == 0 {
files[nextFile].name = String(data: Data(bytes: names[nextName..<i]),
encoding: .utf16LittleEndian)
+6 -7
View File
@@ -104,9 +104,9 @@ class SevenZipTests: XCTestCase {
let entries = try SevenZipContainer.info(container: testData)
XCTAssertEqual(entries.count, 6)
for entry in entries where entry.name == "test_create/test4.answer" {
XCTAssertEqual((entry as? SevenZipEntryInfo)?.isAnti, true)
XCTAssertEqual(entry.isAnti, true)
}
#endif
}
@@ -157,10 +157,10 @@ class SevenZipTests: XCTestCase {
XCTAssertEqual(entries.count, 6)
for entry in entries {
XCTAssertNotNil((entry as? SevenZipEntryInfo)?.creationTime)
XCTAssertNotNil((entry as? SevenZipEntryInfo)?.accessTime)
XCTAssertNotNil(entry.creationTime)
XCTAssertNotNil(entry.accessTime)
// Just in case...
XCTAssertNotNil((entry as? SevenZipEntryInfo)?.modificationTime)
XCTAssertNotNil(entry.modificationTime)
}
#endif
}
@@ -300,9 +300,8 @@ class SevenZipTests: XCTestCase {
let testData = try Data(contentsOf: testURL, options: .mappedIfSafe)
let entries = try SevenZipContainer.open(container: testData)
XCTAssertEqual(entries.isEmpty, true)
}
}
+1 -1
View File
@@ -161,7 +161,7 @@ class TarTests: XCTestCase {
let testData = try Data(contentsOf: testURL, options: .mappedIfSafe)
let entries = try TarContainer.open(container: testData)
XCTAssertEqual(entries.isEmpty, true)
}
+1 -1
View File
@@ -185,7 +185,7 @@ class ZipTests: XCTestCase {
let testData = try Data(contentsOf: testURL, options: .mappedIfSafe)
let entries = try ZipContainer.open(container: testData)
XCTAssertEqual(entries.isEmpty, true)
}