Update test to use elements to capture the trailing whitespace.

This commit is contained in:
Tom Alexander
2023-04-22 00:14:41 -04:00
parent 7b7779ee7e
commit 9b66929c14
2 changed files with 7 additions and 4 deletions

View File

@@ -57,9 +57,11 @@ fn paragraph_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st
#[cfg(test)]
mod tests {
use crate::parser::element_parser::paragraph_element;
use crate::parser::parser_context::ContextElement;
use crate::parser::parser_context::ContextTree;
use crate::parser::parser_with_context::parser_with_context;
use crate::parser::source::Source;
use super::*;
@@ -69,12 +71,12 @@ mod tests {
let initial_context: ContextTree<'_, '_> = ContextTree::new();
let document_context =
initial_context.with_additional_node(ContextElement::DocumentRoot(input));
let paragraph_matcher = parser_with_context!(paragraph)(&document_context);
let paragraph_matcher = parser_with_context!(paragraph_element)(&document_context);
let (remaining, first_paragraph) = paragraph_matcher(input).expect("Parse first paragraph");
let (remaining, second_paragraph) =
paragraph_matcher(remaining).expect("Parse second paragraph.");
assert_eq!(remaining, "");
assert_eq!(first_paragraph.source, "foo bar baz\n\n");
assert_eq!(second_paragraph.source, "lorem ipsum");
assert_eq!(first_paragraph.get_source(), "foo bar baz\n\n");
assert_eq!(second_paragraph.get_source(), "lorem ipsum");
}
}