-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
impl find index of oid in pack index
- Loading branch information
1 parent
a43fd16
commit c8a8e08
Showing
3 changed files
with
83 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,36 @@ | ||
use super::*; | ||
use std::io::Cursor; | ||
use std::str::FromStr; | ||
|
||
// got this number by inspecting last entry of the fanout table | ||
const PACK_LEN: usize = 11076; | ||
|
||
#[test] | ||
fn test_deserialize_pack_idx() -> BitResult<()> { | ||
fn test_deserialize_pack_idx_is_ok() -> BitResult<()> { | ||
let bytes = include_bytes!("../../tests/files/pack.idx") as &[u8]; | ||
let pack_idx = PackIndex::deserialize_unbuffered(bytes)?; | ||
// dbg!(pack_idx); | ||
let _pack_idx = PackIndex::deserialize_unbuffered(bytes)?; | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn test_pack_idx_find_oid_start() -> BitResult<()> { | ||
let mut cursor = Cursor::new(include_bytes!("../../tests/files/pack.idx")); | ||
let pack_idx = PackIndex::find_oid_index( | ||
&mut cursor, | ||
// this hash is the first oid in sorted list | ||
BitHash::from_str("0004a3cf85dbcbfbef916599145a0c370bb78cf5").unwrap(), | ||
)?; | ||
assert_eq!(pack_idx, 0); | ||
Ok(()) | ||
} | ||
#[test] | ||
fn test_pack_idx_find_oid_end() -> BitResult<()> { | ||
let mut cursor = Cursor::new(include_bytes!("../../tests/files/pack.idx")); | ||
let pack_idx = PackIndex::find_oid_index( | ||
&mut cursor, | ||
// this hash is the last oid in sorted list | ||
BitHash::from_str("fffc6e8cf5f6798732a6031ebf24d2f6aaa60e47").unwrap(), | ||
)?; | ||
assert_eq!(pack_idx, PACK_LEN - 1); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters