Skip to content

Commit

Permalink
separated_list doc and test update (#1784)
Browse files Browse the repository at this point in the history
* separated_list doc update

* separated_list1_test: add empty_both
  • Loading branch information
SaltyKitkat authored Dec 8, 2024
1 parent f1a9967 commit fcc9f16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/multi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ where
/// [`cut`][crate::combinator::cut].
///
/// # Arguments
/// * `sep` Parses the separator between list elements. Must be consuming.
/// * `sep` Parses the separator between list elements.
/// * `f` Parses the elements of the list.
///
/// ```rust
Expand Down Expand Up @@ -457,7 +457,7 @@ where
/// [`cut`][crate::combinator::cut].
///
/// # Arguments
/// * `sep` Parses the separator between list elements. Must be consuming.
/// * `sep` Parses the separator between list elements.
/// * `f` Parses the elements of the list.
/// ```rust
/// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult, Parser};
Expand Down
7 changes: 7 additions & 0 deletions src/multi/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ fn separated_list1_test() {
fn multi_longsep(i: &[u8]) -> IResult<&[u8], Vec<&[u8]>> {
separated_list1(tag(".."), tag("abcd")).parse(i)
}
fn empty_both(i: &[u8]) -> IResult<&[u8], Vec<&[u8]>> {
separated_list0(tag(""), tag("")).parse(i)
}

let a = &b"abcdef"[..];
let b = &b"abcd,abcdef"[..];
Expand All @@ -100,6 +103,10 @@ fn separated_list1_test() {
multi(c),
Err(Err::Error(error_position!(c, ErrorKind::Tag)))
);
assert_eq!(
empty_both(f),
Err(Err::Error(error_position!(f, ErrorKind::SeparatedList)))
);
let res3 = vec![&b"abcd"[..], &b"abcd"[..]];
assert_eq!(multi(d), Ok((&b",ef"[..], res3)));

Expand Down

0 comments on commit fcc9f16

Please sign in to comment.