Skip to content

Commit

Permalink
- Add test coverage for seeking indices on a medium sized file
Browse files Browse the repository at this point in the history
  • Loading branch information
traktion committed Apr 17, 2024
1 parent b85b8e3 commit 5adf858
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,39 @@ fn seek_indices() -> Result<(), Error> {
Ok(())
}

#[test]
fn seek_indices_on_medium_size_file() -> Result<(), Error> {
let file_size = 969_265;
let pos = 0;
let len = 131072;

let info = seek_info(file_size, pos, len);

assert_eq!(0, info.relative_pos);
assert_eq!(0, info.index_range.start);
assert_eq!(0, info.index_range.end);

let info = seek_info(file_size, 131072, len);

assert_eq!(131072, info.relative_pos);
assert_eq!(0, info.index_range.start);
assert_eq!(0, info.index_range.end);

let info = seek_info(file_size, 393216, len);

assert_eq!(70128, info.relative_pos);
assert_eq!(1, info.index_range.start);
assert_eq!(1, info.index_range.end);

let info = seek_info(file_size, 655360, len);

assert_eq!(9184, info.relative_pos);
assert_eq!(2, info.index_range.start);
assert_eq!(2, info.index_range.end);

Ok(())
}

#[test]
fn seek_and_join() -> Result<(), Error> {
for i in 1..15 {
Expand Down

0 comments on commit 5adf858

Please sign in to comment.