Add a test for footnote definition.
This commit is contained in:
		
							parent
							
								
									e5bc4cb14b
								
							
						
					
					
						commit
						6578ddc100
					
				| @ -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." | ||||
|         ); | ||||
|     } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander