use tinyquant_io::compressed_vector::HEADER_SIZE;
#[test]
fn header_size_is_seventy() {
assert_eq!(HEADER_SIZE, 70, "header must be exactly 70 bytes");
}
#[test]
fn header_constants_add_up() {
let computed = 1usize + 64 + 4 + 1;
assert_eq!(computed, HEADER_SIZE);
}
#[test]
fn encode_produces_correct_offset_content() {
use std::sync::Arc;
use tinyquant_core::codec::CompressedVector;
use tinyquant_io::compressed_vector::to_bytes;
let indices = vec![0u8; 4];
let cv = CompressedVector::new(
indices.into_boxed_slice(),
None,
Arc::from("testhash"),
4,
8,
)
.unwrap();
let bytes = to_bytes(&cv);
assert_eq!(bytes[0], 0x01, "version byte must be 0x01");
let hash_bytes = &bytes[1..65];
let trimmed: Vec<u8> = hash_bytes.iter().copied().filter(|&b| b != 0).collect();
assert_eq!(trimmed, b"testhash");
let dim = u32::from_le_bytes([bytes[65], bytes[66], bytes[67], bytes[68]]);
assert_eq!(dim, 4);
assert_eq!(bytes[69], 8);
}