#![allow(clippy::unwrap_used, clippy::expect_used)]
use sqlite_core::{Database, Value};
const DB: &[u8] = include_bytes!("../../tests/data/overflow.db");
const NOTES_ROOT: u32 = 2;
const NOTES_COLS: usize = 2;
#[test]
fn large_text_row_decodes_fully_via_overflow() {
let db = Database::open(DB.to_vec()).expect("open overflow.db");
let rows = db.read_table(NOTES_ROOT, NOTES_COLS).expect("walk notes");
assert_eq!(rows.len(), 2, "two rows");
let body = match &rows[0].values[1] {
Value::Text(s) => s,
other => panic!("expected Text body, got {other:?}"),
};
assert_eq!(
body.len(),
12017,
"overflow chain must reassemble the full payload"
);
assert!(
body.starts_with("OVERFLOW_PAYLOAD_"),
"payload prefix preserved"
);
assert!(body.ends_with("ABCDEFGHIJ"), "payload tail preserved");
assert_eq!(rows[1].values[1], Value::Text("small row".into()));
}