Skip to content

Commit

Permalink
Add volume archive test
Browse files Browse the repository at this point in the history
  • Loading branch information
mtgto committed Mar 6, 2021
1 parent a47cac1 commit 0b40b40
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
CHANGELOG
====
## v0.3.1 (2021-03-06)

### Changed

- Update unrar to v6.0.4
- Add tests for volume archive

## v0.3.0 (2021-02-07)

### Added
Expand Down
30 changes: 30 additions & 0 deletions Tests/UnrarTests/ArchiveTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,34 @@ final class ArchiveTests: XCTestCase {
XCTAssertEqual(data.count, 15)
}

func testVolume() throws {
guard let path = Bundle.module.path(forResource: "volumes.part1", ofType: "rar") else {
XCTFail()
return
}
let archive = try Archive(path: path)
XCTAssertNotNil(archive)
XCTAssertTrue(archive.isVolume)
XCTAssertTrue(archive.isFirstVolume)
let entries = try archive.entries()
var data: Data = Data()
try archive.extract(entries[0]) { receivedData, progress in
data.append(receivedData)
}
XCTAssertEqual(data.count, 179439)
}

func testVolumeNotFirst() throws {
guard let path = Bundle.module.path(forResource: "volumes.part2", ofType: "rar") else {
XCTFail()
return
}
let archive = try Archive(path: path)
XCTAssertNotNil(archive)
XCTAssertTrue(archive.isVolume)
XCTAssertFalse(archive.isFirstVolume)
}

static var allTests = [
("testOpenNotExistsArchive", testOpenNotExistsArchive),
("testEntries", testEntries),
Expand All @@ -221,5 +249,7 @@ final class ArchiveTests: XCTestCase {
("testExtractBadCRC", testExtractBadCRC),
("testBlake2Hash", testBlake2Hash),
("testExtractSfx", testExtractSfx),
("testVolume", testVolume),
("testVolumeNotFirst", testVolumeNotFirst),
]
}

0 comments on commit 0b40b40

Please sign in to comment.