Add a test for footnote definition.

This commit is contained in:
Tom Alexander 2023-04-10 11:54:05 -04:00
parent e5bc4cb14b
commit 6578ddc100
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 40 additions and 0 deletions

View File

@ -84,3 +84,43 @@ fn footnote_definition_end<'r, 's>(
))),
))(input)
}
#[cfg(test)]
mod tests {
use crate::parser::parser_context::ContextElement;
use crate::parser::parser_context::ContextTree;
use crate::parser::parser_with_context::parser_with_context;
use super::*;
#[test]
fn two_paragraphs() {
let input = "[fn:1] A footnote.
[fn:2] A multi-
line footnote.";
let initial_context: ContextTree<'_, '_> = ContextTree::new();
let document_context =
initial_context.with_additional_node(ContextElement::DocumentRoot(input));
let footnote_definition_matcher =
parser_with_context!(footnote_definition)(&document_context);
let (remaining, first_footnote_definition) =
footnote_definition_matcher(input).expect("Parse first footnote_definition");
let (remaining, second_footnote_definition) =
footnote_definition_matcher(remaining).expect("Parse second footnote_definition.");
assert_eq!(remaining, "");
assert_eq!(
first_footnote_definition.source,
"[fn:1] A footnote.
"
);
assert_eq!(
second_footnote_definition.source,
"[fn:2] A multi-
line footnote."
);
}
}