Files
alpha-id/tests/segment_tests.rs
T
Brummel f047cd1b5b refactor: input contract — one extracted phrase per line (spec §1a)
split_segments now treats each non-empty trimmed line as one retrieval
unit; blank lines are skipped, not paragraph delimiters. Name/signature
retained (minimal-churn decision). Full suite 45/0. End-to-end: feeding
the GP dictation as extracted phrases recovers I10.90 (rank 4) which was
entirely missing in both modes under the paragraph contract, and largely
dissolves the cross-segment diabetes crowding.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 23:30:05 +02:00

31 lines
923 B
Rust

use alpha_id::segment::split_segments;
#[test]
fn one_unit_per_nonempty_line() {
let input = "arterielle Hypertonie\nTyp-2-Diabetes mit Polyneuropathie\ngemischte Hyperlipidämie";
assert_eq!(split_segments(input), vec![
"arterielle Hypertonie".to_string(),
"Typ-2-Diabetes mit Polyneuropathie".to_string(),
"gemischte Hyperlipidämie".to_string(),
]);
}
#[test]
fn blank_and_whitespace_lines_are_skipped_and_each_line_trimmed() {
let input = " \n\n Kreuzschmerz \n \nGonarthrose rechts\n\n";
assert_eq!(split_segments(input), vec![
"Kreuzschmerz".to_string(),
"Gonarthrose rechts".to_string(),
]);
}
#[test]
fn single_phrase_is_one_unit() {
assert_eq!(split_segments("nur eine Diagnose"), vec!["nur eine Diagnose".to_string()]);
}
#[test]
fn empty_or_whitespace_only_input_yields_no_units() {
assert!(split_segments(" \n\n").is_empty());
}