Skip to content

Commit 939f08a

Browse files
committed
[Tests] Add a test for BZip2 truncated in the middle of a Huffman symbol
1 parent f539a53 commit 939f08a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Tests/BZip2Tests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ class BZip2Tests: XCTestCase {
6767
XCTAssertThrowsError(try BZip2.decompress(data: testData))
6868
}
6969

70+
func testBadFile_truncated() throws {
71+
// This tests that encountering data truncated in the middle of a Huffman symbol correctly throws an error
72+
// (and doesn't crash).
73+
let testData = try Constants.data(forTest: "test1", withType: BZip2Tests.testType)[0...40]
74+
XCTAssertThrowsError(try BZip2.decompress(data: testData))
75+
}
76+
7077
func testEmptyData() throws {
7178
XCTAssertThrowsError(try BZip2.decompress(data: Data()))
7279
}

0 commit comments

Comments
 (0)