[pack/unpack] Get the functional tests working again.

There's some hard coded version numbers in the tests, but I'm
leaving for now since I'll rewrite in Rust to avoid too much
of a proliferation of languages.
This commit is contained in:
Joe Thornber
2020-06-09 13:03:39 +01:00
parent db5a71a53c
commit 409a660082
6 changed files with 77 additions and 35 deletions

View File

@@ -168,12 +168,26 @@ fn read_header<R>(mut r: R) -> io::Result<u64>
where
R: byteorder::ReadBytesExt,
{
use std::process::exit;
let magic = r.read_u64::<LittleEndian>()?;
assert_eq!(magic, MAGIC);
if magic != MAGIC {
eprintln!("Not a pack file.");
exit(1);
}
let version = r.read_u64::<LittleEndian>()?;
assert_eq!(version, PACK_VERSION);
if version != PACK_VERSION {
eprintln!("unsupported pack file version ({}).", PACK_VERSION);
exit(1);
}
let block_size = r.read_u64::<LittleEndian>()?;
assert_eq!(block_size, 4096);
if block_size != BLOCK_SIZE {
eprintln!("block size is not {}", BLOCK_SIZE);
exit(1);
}
r.read_u64::<LittleEndian>()
}