use mem_core::parse_gate_response;
#[test]
fn a1_wellformed_yes_continue() {
let response = r#"This is useful
yes
New memory text here
continue"#;
let result = parse_gate_response(response).expect("Should parse");
assert_eq!(result.think, "This is useful");
assert!(result.update_gate);
assert_eq!(result.candidate, "New memory text here");
assert!(!result.exit_gate);
}
#[test]
fn a2_wellformed_no_end() {
let response = r#"Not relevant
no
Memory stays same
end"#;
let result = parse_gate_response(response).expect("Should parse");
assert_eq!(result.think, "Not relevant");
assert!(!result.update_gate);
assert_eq!(result.candidate, "Memory stays same");
assert!(result.exit_gate);
}
#[test]
fn a3_missing_check_errors() {
let response = r#"Thinking
Memory text
continue"#;
let err = parse_gate_response(response).expect_err("Should error");
assert_eq!(err.tag, "check");
}
#[test]
fn a4_invalid_check_value() {
let response = r#"Thinking
maybe
Memory text
continue"#;
let err = parse_gate_response(response).expect_err("Should error");
assert_eq!(err.tag, "check");
assert!(err.message.contains("yes") || err.message.contains("no"));
}
#[test]
fn a5_invalid_next_value() {
let response = r#"Thinking
yes
Memory text
maybe"#;
let err = parse_gate_response(response).expect_err("Should error");
assert_eq!(err.tag, "next");
}
#[test]
fn a6_missing_update_errors() {
let response = r#"Thinking
yes
continue"#;
let err = parse_gate_response(response).expect_err("Should error");
assert_eq!(err.tag, "update");
}
#[test]
fn a7_nested_think_uses_last() {
let response = r#"First thought
Second thought that matters
yes
Memory text
continue"#;
let result = parse_gate_response(response).expect("Should parse");
assert_eq!(result.think, "Second thought that matters");
}
#[test]
fn a8_duplicate_check_errors() {
let response = r#"Thinking
yes
no
Memory text
continue"#;
let err = parse_gate_response(response).expect_err("Should error");
assert_eq!(err.tag, "check");
assert!(err.message.contains("appears"));
}
#[test]
fn a9_unclosed_tag_errors() {
let response = r#"Thinking
yes
Memory text
continue"#;
let err = parse_gate_response(response).expect_err("Should error");
assert_eq!(err.tag, "think");
}