Fixed a problem with repeated strings in data.

This commit is contained in:
Timofey Solomko
2016-10-29 17:46:46 +03:00
parent 5f9c0cefcc
commit dc6dffbb77
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -254,7 +254,7 @@ public class Deflate {
if length == distance {
out.append(contentsOf: Array(out[out.count - distance..<out.count]))
} else {
out.append(contentsOf: Array(out[out.count - length - distance..<out.count - distance]))
out.append(contentsOf: Array(out[out.count - distance..<out.count + length - distance]))
}
} else {
throw DeflateError.HuffmanTableError
+2 -1
View File
@@ -19,7 +19,7 @@ class SWCompressionTests: XCTestCase {
guard decompressedData != nil else { return }
let decompressedString = String(data: decompressedData!, encoding: .utf8)
XCTAssertNotNil(decompressedString, "Failed to convert decompressed data to string")
print("decompressed string: \(decompressedString!)")
// print("decompressed string: \(decompressedString!)")
XCTAssertEqual(decompressedString!, "Hello, World!\n", "Decompression was incorrect")
}
@@ -31,6 +31,7 @@ class SWCompressionTests: XCTestCase {
guard decompressedData != nil else { return }
let decompressedString = String(data: decompressedData!, encoding: .utf8)
XCTAssertNotNil(decompressedString, "Failed to convert decompressed data to string")
// print("decompressed string: \(decompressedString!)")
XCTAssertEqual(decompressedString!, try! String(contentsOf: Constants.secondTestAnswerPath, encoding: .utf8), "Decompression was incorrect")
}