Update tests to compile again.

This commit is contained in:
Tom Alexander
2023-08-24 17:15:24 -04:00
parent 3348807a05
commit e84e2b5147
8 changed files with 71 additions and 100 deletions

View File

@@ -69,22 +69,20 @@ fn paragraph_end<'r, 's>(
#[cfg(test)]
mod tests {
use crate::parser::element_parser::element;
use crate::parser::parser_context::ContextElement;
use crate::parser::org_source::OrgSource;
use crate::parser::parser_context::ContextTree;
use crate::parser::parser_with_context::parser_with_context;
use crate::parser::source::Source;
#[test]
fn two_paragraphs() {
let input = "foo bar baz\n\nlorem ipsum";
let input = OrgSource::new("foo bar baz\n\nlorem ipsum");
let initial_context: ContextTree<'_, '_> = ContextTree::new();
let document_context =
initial_context.with_additional_node(ContextElement::DocumentRoot(input));
let paragraph_matcher = parser_with_context!(element(true))(&document_context);
let paragraph_matcher = parser_with_context!(element(true))(&initial_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!(Into::<&str>::into(remaining), "");
assert_eq!(first_paragraph.get_source(), "foo bar baz\n\n");
assert_eq!(second_paragraph.get_source(), "lorem ipsum");
}