Skip to content

Commit

Permalink
test(binary): Cover more cases
Browse files Browse the repository at this point in the history
Pulled from rust-bakery/nom#1769

I skipped the float ones because I didn't feel like adapting them to the
`binary` mod.
  • Loading branch information
epage committed Jul 18, 2024
1 parent 22766b1 commit 46a077d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/binary/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,22 @@ mod partial {
);
}

#[test]
fn le_u16_tests() {
assert_parse!(
le_u16.parse_peek(Partial::new(&[0x00, 0x03][..])),
Ok((Partial::new(&b""[..]), 0x0300))
);
assert_parse!(
le_u16.parse_peek(Partial::new(&[b'a', b'b'][..])),
Ok((Partial::new(&b""[..]), 0x6261))
);
assert_parse!(
le_u16.parse_peek(Partial::new(&[0x01][..])),
Err(ErrMode::Incomplete(Needed::new(1)))
);
}

#[test]
fn le_i8_tests() {
assert_parse!(
Expand Down Expand Up @@ -868,6 +884,22 @@ mod partial {
);
}

#[test]
fn le_u32_test() {
assert_parse!(
le_u32.parse_peek(Partial::new(&[0x00, 0x03, 0x05, 0x07][..])),
Ok((Partial::new(&b""[..]), 0x07050300))
);
assert_parse!(
le_u32.parse_peek(Partial::new(&[b'a', b'b', b'c', b'd'][..])),
Ok((Partial::new(&b""[..]), 0x64636261))
);
assert_parse!(
le_u32.parse_peek(Partial::new(&[0x01][..])),
Err(ErrMode::Incomplete(Needed::new(3)))
);
}

#[test]
fn le_i32_tests() {
assert_parse!(
Expand Down

0 comments on commit 46a077d

Please sign in to comment.