[Tests] Correctly check for error type in Deflate truncation testing

This commit is contained in:
Timofey Solomko
2022-10-21 19:28:13 +03:00
parent df55c2e4e2
commit 0c80ccedf2
+12 -6
View File
@@ -290,8 +290,10 @@ class GzipTests: XCTestCase {
var thrownError: Error? = nil
XCTAssertThrowsError(try GzipArchive.unarchive(archive: testData[..<truncationIndex]),
"No error thrown, test9, truncationIndex=\(truncationIndex)") { thrownError = $0 }
XCTAssertTrue(thrownError is DeflateError, "Unexpected error type: \(type(of: thrownError)), " +
"test9, truncationIndex=\(truncationIndex)")
if let error = thrownError {
XCTAssertTrue(error is DeflateError, "Unexpected error type: \(type(of: thrownError)), " +
"test9, truncationIndex=\(truncationIndex)")
}
}
// This test file contains static Huffman Deflate block.
@@ -301,8 +303,10 @@ class GzipTests: XCTestCase {
var thrownError: Error? = nil
XCTAssertThrowsError(try GzipArchive.unarchive(archive: testData[..<truncationIndex]),
"No error thrown, test8, truncationIndex=\(truncationIndex)") { thrownError = $0 }
XCTAssertTrue(thrownError is DeflateError, "Unexpected error type: \(type(of: thrownError)), " +
"test8, truncationIndex=\(truncationIndex)")
if let error = thrownError {
XCTAssertTrue(error is DeflateError, "Unexpected error type: \(type(of: thrownError)), " +
"test8, truncationIndex=\(truncationIndex)")
}
}
// This test file contains dynamic Huffman Deflate block.
@@ -312,8 +316,10 @@ class GzipTests: XCTestCase {
var thrownError: Error? = nil
XCTAssertThrowsError(try GzipArchive.unarchive(archive: testData[..<truncationIndex]),
"No error thrown, test6, truncationIndex=\(truncationIndex)") { thrownError = $0 }
XCTAssertTrue(thrownError is DeflateError, "Unexpected error type: \(type(of: thrownError)), " +
"test6, truncationIndex=\(truncationIndex)")
if let error = thrownError {
XCTAssertTrue(error is DeflateError, "Unexpected error type: \(type(of: thrownError)), " +
"test6, truncationIndex=\(truncationIndex)")
}
}
}