Skip to content

Commit

Permalink
Add test for roundtripping u32 write/parse
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Beyer <[email protected]>
  • Loading branch information
matthiasbeyer committed Mar 22, 2024
1 parent 0b90438 commit d47e855
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mqtt-format/src/v5/integers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,19 @@ mod tests {
assert_eq!(writer.buffer, &[0x00, 0x00, 0x00, 0x01]);
}

#[tokio::test]
async fn test_write_u32() {
// step by some prime number
for i in (0..268_435_455).step_by(271) {
let mut writer = TestWriter { buffer: Vec::new() };

writer.write_u32(i).await.unwrap();

let out = parse_variable_u32(&mut Bytes::new(&writer.buffer)).unwrap();
assert_eq!(out, i);
}
}

#[tokio::test]
async fn test_write_variable_u32() {
// step by some prime number
Expand Down

0 comments on commit d47e855

Please sign in to comment.