use crate::brain::provider::custom_openai_compatible::Utf8Carry;
#[test]
fn ascii_passes_through_unchanged() {
let mut c = Utf8Carry::new();
assert_eq!(c.push(b"hello world"), "hello world");
assert_eq!(c.push(b"hello "), "hello ");
assert_eq!(c.push(b"world"), "world");
assert_eq!(c.push(b""), "");
}
#[test]
fn reassembles_two_byte_char_split_across_chunks() {
let mut c = Utf8Carry::new();
assert_eq!(c.push(b"resum"), "resum");
assert_eq!(c.push(&[0xC3]), "");
assert_eq!(c.push(&[0xAD]), "í");
}
#[test]
fn reassembles_three_byte_char_split_across_chunks() {
let mut c = Utf8Carry::new();
assert_eq!(c.push(&[0xE2]), "");
assert_eq!(c.push(&[0x94]), "");
assert_eq!(c.push(&[0x80]), "─");
}
#[test]
fn substitutes_genuinely_invalid_bytes_once() {
let mut c = Utf8Carry::new();
assert_eq!(c.push(&[0xFF, b'a']), "\u{FFFD}a");
}