use crate::brain::agent::service::truncation::join_continuation;
#[test]
fn the_observed_case_keeps_the_answer() {
let partial = "Ainda nao. Estado real: o motor existe mas nao esta ligado. \
The request was rejected because it was considered high risk";
let continuation = "The request was rejected because it was considered high risk";
let joined = join_continuation(partial, continuation);
assert!(
joined.contains("Estado real"),
"the answer was dropped again: {joined}"
);
assert_eq!(joined, partial, "nothing new to add, so keep the partial");
}
#[test]
fn a_genuine_continuation_is_appended() {
let partial = "The three failing tests are in the parser, the";
let continuation = " renderer and the scheduler.";
let joined = join_continuation(partial, continuation);
assert!(joined.starts_with("The three failing tests"));
assert!(joined.ends_with("scheduler."));
}
#[test]
fn a_mid_word_cut_is_not_corrupted_by_a_separator() {
let joined = join_continuation("the scheduler was reconfig", "ured last night");
assert!(
joined.contains("reconfigured"),
"the word was split: {joined}"
);
}
#[test]
fn a_restated_continuation_does_not_duplicate_the_partial() {
let partial = "Here are the three findings";
let continuation = "Here are the three findings, listed in full below.";
assert_eq!(join_continuation(partial, continuation), continuation);
}
#[test]
fn an_empty_continuation_keeps_the_partial() {
let partial = "A complete enough answer that simply lacked a full stop";
assert_eq!(join_continuation(partial, ""), partial);
assert_eq!(join_continuation(partial, " \n "), partial);
}
#[test]
fn an_empty_partial_keeps_the_continuation() {
assert_eq!(join_continuation("", "the answer"), "the answer");
assert_eq!(join_continuation(" ", "the answer"), "the answer");
}
#[test]
fn both_empty_yields_empty() {
assert_eq!(join_continuation("", ""), "");
}
#[test]
fn a_clause_boundary_gets_a_separator() {
let joined = join_continuation("First, the parser fails;", "second, the renderer does too.");
assert!(joined.contains("; second,"), "{joined}");
}
#[test]
fn existing_whitespace_is_not_doubled() {
let joined = join_continuation("the list is: ", " one, two, three");
assert!(
!joined.contains(" "),
"double space introduced: {joined:?}"
);
}