Skip to content

Commit

Permalink
test(token): Add tag(char) test
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Feb 6, 2024
1 parent 6999216 commit aa6e0c8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/token/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,27 @@ fn complete_tag_fixed_size_array() {
fn test2(i: &[u8]) -> IResult<&[u8], &[u8]> {
tag(&[0x42]).parse_peek(i)
}

let input = &[0x42, 0x00][..];
assert_eq!(test(input), Ok((&b"\x00"[..], &b"\x42"[..])));
assert_eq!(test2(input), Ok((&b"\x00"[..], &b"\x42"[..])));
}

#[test]
fn complete_tag_char() {
fn test(i: &[u8]) -> IResult<&[u8], &[u8]> {
tag('B').parse_peek(i)
}
assert_eq!(test(&[0x42, 0x00][..]), Ok((&b"\x00"[..], &b"\x42"[..])));
assert_eq!(
test(&[b'A', b'\0'][..]),
Err(ErrMode::Backtrack(error_position!(
&&b"A\0"[..],
ErrorKind::Tag
)))
);
}

#[test]
fn partial_any_str() {
use super::any;
Expand Down

0 comments on commit aa6e0c8

Please sign in to comment.