Skip to content

Commit

Permalink
[Tests] Add a test for BZip2 truncated in the middle of a Huffman symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
tsolomko committed Jan 20, 2022
1 parent f539a53 commit 939f08a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Tests/BZip2Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ class BZip2Tests: XCTestCase {
XCTAssertThrowsError(try BZip2.decompress(data: testData))
}

func testBadFile_truncated() throws {
// This tests that encountering data truncated in the middle of a Huffman symbol correctly throws an error
// (and doesn't crash).
let testData = try Constants.data(forTest: "test1", withType: BZip2Tests.testType)[0...40]
XCTAssertThrowsError(try BZip2.decompress(data: testData))
}

func testEmptyData() throws {
XCTAssertThrowsError(try BZip2.decompress(data: Data()))
}
Expand Down

0 comments on commit 939f08a

Please sign in to comment.