use super::*;
#[test]
fn plain_line_is_lazy_continuation() {
assert!(is_lazy_continuation_line("beta"));
assert!(is_lazy_continuation_line(" beta"));
assert!(is_lazy_continuation_line("[ ] beta"));
}
#[test]
fn block_starts_are_not_lazy_continuations() {
for body in [
"# heading",
"> quote",
"```rust",
"~~~",
"---",
"***",
"<div>",
"- item",
"* item",
"+ item",
"1. item",
"1) item",
"",
" ",
] {
assert!(!is_lazy_continuation_line(body), "{body:?}");
}
}
#[test]
fn non_one_ordered_marker_cannot_interrupt_a_paragraph() {
assert!(is_lazy_continuation_line("2. item"));
assert!(is_lazy_continuation_line("7) item"));
}
#[test]
fn empty_list_marker_cannot_interrupt_a_paragraph() {
assert!(is_lazy_continuation_line("- "));
}
#[test]
fn indented_code_cannot_interrupt_a_paragraph() {
assert!(is_lazy_continuation_line(" - item"));
assert!(is_lazy_continuation_line("\t# not a heading here"));
}
#[test]
fn paragraph_content_is_continuable() {
for body in [
"alpha",
"- alpha",
"* alpha",
"1. alpha",
"> alpha",
"- [ ] alpha",
] {
assert!(is_paragraph_continuable_line(body), "{body:?}");
}
}
#[test]
fn leaf_and_empty_lines_are_not_continuable() {
for body in ["# heading", "```", "---", "<div>", "", " ", "- ", "> "] {
assert!(!is_paragraph_continuable_line(body), "{body:?}");
}
}
#[test]
fn container_kind_reads_the_leading_marker() {
assert_eq!(container_kind("- alpha"), Some(ContainerKind::ListItem));
assert_eq!(container_kind("1. alpha"), Some(ContainerKind::ListItem));
assert_eq!(container_kind(" + alpha"), Some(ContainerKind::ListItem));
assert_eq!(container_kind("> alpha"), Some(ContainerKind::BlockQuote));
assert_eq!(container_kind("[ ] alpha"), None);
assert_eq!(container_kind("alpha"), None);
}
#[test]
fn contiguous_runs_splits_on_gaps() {
let rewritten: Vec<(usize, String)> = [0usize, 1, 2, 5, 7, 8]
.iter()
.map(|line| (*line, String::new()))
.collect();
assert_eq!(contiguous_runs(&rewritten), vec![(0, 2), (5, 5), (7, 8)]);
}