diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 0e7518ff..0903d971 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -9,3 +9,19 @@ macro_rules! lines_vec { vec![$($line.to_string()),*] }; } + +/// Assert common wrapping expectations for list items. +/// +/// Verifies the number of lines, prefix on the first line, length of all lines, +/// and indentation of continuation lines. +pub fn assert_wrapped_list_item(output: &[String], prefix: &str, expected: usize) { + assert!(expected > 0, "expected line count must be positive"); + assert!(!output.is_empty(), "output slice is empty"); + assert_eq!(output.len(), expected); + assert!(output.first().is_some_and(|line| line.starts_with(prefix))); + assert!(output.iter().all(|l| l.len() <= 80)); + let indent = " ".repeat(prefix.len()); + for line in output.iter().skip(1) { + assert!(line.starts_with(&indent)); + } +} diff --git a/tests/integration.rs b/tests/integration.rs index bdbea78e..e03854ea 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -664,14 +664,21 @@ fn test_wrap_list_item() { .to_string(), ]; let output = process_stream(&input); - assert!(output.len() > 1); - assert!(output[0].starts_with("- ")); - for line in &output { - assert!(line.len() <= 80); - } - for line in output.iter().skip(1) { - assert!(line.starts_with(" ")); - } + common::assert_wrapped_list_item(&output, "- ", 2); +} + +#[rstest] +#[case("- ", 3)] +#[case("1. ", 3)] +#[case("10. ", 3)] +fn test_wrap_list_items_with_inline_code(#[case] prefix: &str, #[case] expected: usize) { + let input = vec![format!( + "{prefix}`script`: A multi-line script declared with the YAML `|` block style. The entire \ + block is passed to an interpreter. If the first line begins with `#!`, Netsuke executes \ + the script verbatim, respecting the shebang." + )]; + let output = process_stream(&input); + common::assert_wrapped_list_item(&output, prefix, expected); } #[test]