diff --git a/src/records.rs b/src/records.rs index 27f7eaf..3731c9f 100644 --- a/src/records.rs +++ b/src/records.rs @@ -137,7 +137,7 @@ impl Record for ENDLIB { pub struct BGNSTR; impl Record for BGNSTR { fn tag() -> u16 { RTAG_BGNSTR } - fn expected_size() -> Option { Some(2 * 6) } + fn expected_size() -> Option { Some(2 * 6 * 2) } } pub struct STRNAME; @@ -545,3 +545,23 @@ impl Record for CONTACT { fn tag() -> u16 { RTAG_CONTACT } fn expected_size() -> Option { Some(0) } } + + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn bgnstr_reads_both_timestamps() { + let mut bytes = vec![0, 28, 0x05, 0x02]; + for value in [126_i16, 11, 14, 12, 30, 0, 125, 10, 13, 9, 15, 1] { + bytes.extend_from_slice(&value.to_be_bytes()); + } + bytes.extend_from_slice(&[0, 4, 0x07, 0]); + + let (remaining, timestamps) = BGNSTR::read(&bytes).unwrap(); + + assert_eq!(timestamps, [[2026, 11, 14, 12, 30, 0], [2025, 10, 13, 9, 15, 1]]); + assert_eq!(remaining, &[0, 4, 0x07, 0]); + } +}