fix(records): correct BGNSTR timestamp payload size
This commit is contained in:
parent
7ddfc0cd7f
commit
740cf9c693
1 changed files with 21 additions and 1 deletions
|
|
@ -137,7 +137,7 @@ impl Record<Empty> for ENDLIB {
|
||||||
pub struct BGNSTR;
|
pub struct BGNSTR;
|
||||||
impl Record<DateTimePair> for BGNSTR {
|
impl Record<DateTimePair> for BGNSTR {
|
||||||
fn tag() -> u16 { RTAG_BGNSTR }
|
fn tag() -> u16 { RTAG_BGNSTR }
|
||||||
fn expected_size() -> Option<u16> { Some(2 * 6) }
|
fn expected_size() -> Option<u16> { Some(2 * 6 * 2) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct STRNAME;
|
pub struct STRNAME;
|
||||||
|
|
@ -545,3 +545,23 @@ impl Record<Empty> for CONTACT {
|
||||||
fn tag() -> u16 { RTAG_CONTACT }
|
fn tag() -> u16 { RTAG_CONTACT }
|
||||||
fn expected_size() -> Option<u16> { Some(0) }
|
fn expected_size() -> Option<u16> { 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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue