Skip to content

Commit 6453497

Browse files
committed
Macrofy end of data PDU tests
1 parent a64ece6 commit 6453497

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

src/rtr/pdu.rs

+28-21
Original file line numberDiff line numberDiff line change
@@ -1879,33 +1879,40 @@ mod test {
18791879
);
18801880
}
18811881

1882-
#[tokio::test]
1883-
async fn end_of_data_versions() {
1884-
for (version, raw) in [
1885-
(0,
1886-
vec![0, 7, 0x12, 0x34, 0, 0, 0, 12, 0xde, 0xad, 0xbe, 0xef]
1887-
),
1888-
(1,
1889-
vec![0x01, 0x07, 0x8e, 0xef, 0x00, 0x00, 0x00, 0x18,
1890-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x8f,
1891-
0x00, 0x00, 0x02, 0x58, 0x00, 0x00, 0x1c, 0x20
1892-
]
1893-
),
1894-
(2,
1895-
vec![0x02, 0x07, 0x8e, 0xef, 0x00, 0x00, 0x00, 0x18,
1896-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x8f,
1897-
0x00, 0x00, 0x02, 0x58, 0x00, 0x00, 0x1c, 0x20
1898-
]
1899-
)
1900-
] {
1901-
if let Err(eod) = Payload::read(&mut raw.as_slice()).await.unwrap() {
1902-
assert_eq!(version, eod.version());
1882+
macro_rules! test_eod_pdu_version {
1883+
($version:expr, $raw:expr) => {
1884+
if let Err(eod) = Payload::read(&mut $raw.as_slice()).await.unwrap() {
1885+
assert_eq!($version, eod.version());
19031886
} else {
19041887
panic!("expected End of Data PDU");
19051888
}
19061889
}
19071890
}
19081891

1892+
#[tokio::test]
1893+
async fn end_of_data_versions() {
1894+
test_eod_pdu_version!(
1895+
0,
1896+
vec![0, 7, 0x12, 0x34, 0, 0, 0, 12, 0xde, 0xad, 0xbe, 0xef]
1897+
);
1898+
test_eod_pdu_version!(
1899+
1,
1900+
vec![
1901+
0x01, 0x07, 0x8e, 0xef, 0x00, 0x00, 0x00, 0x18,
1902+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x8f,
1903+
0x00, 0x00, 0x02, 0x58, 0x00, 0x00, 0x1c, 0x20
1904+
]
1905+
);
1906+
test_eod_pdu_version!(
1907+
2,
1908+
vec![
1909+
0x02, 0x07, 0x8e, 0xef, 0x00, 0x00, 0x00, 0x18,
1910+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x8f,
1911+
0x00, 0x00, 0x02, 0x58, 0x00, 0x00, 0x1c, 0x20
1912+
]
1913+
);
1914+
}
1915+
19091916
#[tokio::test]
19101917
async fn read_write_cache_reset() {
19111918
read_write!(

0 commit comments

Comments
 (0)