From fc9d131740fd9a56ed2889e40182e10014d02fd0 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 25 Mar 2023 14:28:48 -0400 Subject: [PATCH] Add basic test for plain list item. --- src/parser/plain_list.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/parser/plain_list.rs b/src/parser/plain_list.rs index 085e152..d3177c6 100644 --- a/src/parser/plain_list.rs +++ b/src/parser/plain_list.rs @@ -20,11 +20,17 @@ use crate::parser::util::start_of_line; use super::error::CustomError; use super::error::MyError; use super::error::Res; +use super::greater_element::PlainList; use super::greater_element::PlainListItem; use super::parser_with_context::parser_with_context; use super::util::non_whitespace_character; use super::Context; +#[allow(dead_code)] +pub fn plain_list<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, PlainList<'s>> { + todo!() +} + #[allow(dead_code)] pub fn plain_list_item<'r, 's>( context: Context<'r, 's>, @@ -105,3 +111,24 @@ fn get_context_item_indent<'r, 's>(context: Context<'r, 's>) -> Option<&'r usize } None } + +#[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 plain_list_item_empty() { + let input = "1."; + let initial_context: ContextTree<'_, '_> = ContextTree::new(); + let document_context = + initial_context.with_additional_node(ContextElement::DocumentRoot(input)); + let plain_list_item_matcher = parser_with_context!(plain_list_item)(&document_context); + let (remaining, result) = plain_list_item_matcher(input).unwrap(); + assert_eq!(remaining, ""); + assert_eq!(result.source, "1."); + } +}