use astrogram::error::ParseError;
use astrogram::sfcht::parse_header;
#[test]
fn parses_minimal_header() {
let mut buf = vec![0u8; 86];
buf[0..2].copy_from_slice(&3u16.to_le_bytes());
let desc = b"TEST SPECIMEN";
buf[2..2 + desc.len()].copy_from_slice(desc);
for byte in &mut buf[2 + desc.len()..82] {
*byte = b' ';
}
buf[82..84].copy_from_slice(&7u16.to_le_bytes());
buf[84..86].copy_from_slice(&0u16.to_le_bytes());
let header = parse_header(&buf).expect("well-formed 86-byte input must parse");
assert_eq!(header.version, 3);
assert_eq!(header.record_count, 7);
assert_eq!(header.description, "TEST SPECIMEN");
}
#[test]
fn errors_on_short_input() {
let buf = vec![0u8; 50];
match parse_header(&buf) {
Err(ParseError::Truncated {
needed: 86,
got: 50,
}) => {}
other => panic!("expected ParseError::Truncated{{86,50}}, got {other:?}"),
}
}