mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-06-23 14:56:41 +00:00
Fixed a problem with repeated strings in data.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user