This commit is contained in:
Pere Diaz Bou
2025-03-27 13:24:34 +01:00
parent 4ee60348f2
commit bf37fd3314
21 changed files with 438 additions and 197 deletions

View File

@@ -63,23 +63,23 @@ fn test_statement_bind() -> anyhow::Result<()> {
match stmt.step()? {
StepResult::Row => {
let row = stmt.row().unwrap();
if let limbo_core::OwnedValue::Text(s) = row.get_value(0) {
if let limbo_core::RefValue::Text(s) = row.get_value(0) {
assert_eq!(s.as_str(), "hello")
}
if let limbo_core::OwnedValue::Text(s) = row.get_value(1) {
if let limbo_core::RefValue::Text(s) = row.get_value(1) {
assert_eq!(s.as_str(), "hello")
}
if let limbo_core::OwnedValue::Integer(i) = row.get_value(2) {
if let limbo_core::RefValue::Integer(i) = row.get_value(2) {
assert_eq!(*i, 42)
}
if let limbo_core::OwnedValue::Blob(v) = row.get_value(3) {
assert_eq!(v.as_ref(), &vec![0x1 as u8, 0x2, 0x3])
if let limbo_core::RefValue::Blob(v) = row.get_value(3) {
assert_eq!(v.to_slice(), &vec![0x1 as u8, 0x2, 0x3])
}
if let limbo_core::OwnedValue::Float(f) = row.get_value(4) {
if let limbo_core::RefValue::Float(f) = row.get_value(4) {
assert_eq!(*f, 0.5)
}
}

View File

@@ -1,6 +1,6 @@
use crate::common::{self, maybe_setup_tracing};
use crate::common::{compare_string, do_flush, TempDatabase};
use limbo_core::{Connection, StepResult};
use limbo_core::{Connection, RefValue, StepResult};
use log::debug;
use std::rc::Rc;
@@ -47,12 +47,12 @@ fn test_simple_overflow_page() -> anyhow::Result<()> {
let first_value = row.get_value(0);
let text = row.get_value(1);
let id = match first_value {
limbo_core::OwnedValue::Integer(i) => *i as i32,
limbo_core::OwnedValue::Float(f) => *f as i32,
limbo_core::RefValue::Integer(i) => *i as i32,
limbo_core::RefValue::Float(f) => *f as i32,
_ => unreachable!(),
};
let text = match text {
limbo_core::OwnedValue::Text(t) => t.as_str(),
limbo_core::RefValue::Text(t) => t.as_str(),
_ => unreachable!(),
};
assert_eq!(1, id);
@@ -123,12 +123,12 @@ fn test_sequential_overflow_page() -> anyhow::Result<()> {
let first_value = row.get_value(0);
let text = row.get_value(1);
let id = match first_value {
limbo_core::OwnedValue::Integer(i) => *i as i32,
limbo_core::OwnedValue::Float(f) => *f as i32,
limbo_core::RefValue::Integer(i) => *i as i32,
limbo_core::RefValue::Float(f) => *f as i32,
_ => unreachable!(),
};
let text = match text {
limbo_core::OwnedValue::Text(t) => t.as_str(),
limbo_core::RefValue::Text(t) => t.as_str(),
_ => unreachable!(),
};
let huge_text = &huge_texts[current_index];
@@ -194,8 +194,8 @@ fn test_sequential_write() -> anyhow::Result<()> {
let row = rows.row().unwrap();
let first_value = row.get_values().first().expect("missing id");
let id = match first_value {
limbo_core::OwnedValue::Integer(i) => *i as i32,
limbo_core::OwnedValue::Float(f) => *f as i32,
limbo_core::RefValue::Integer(i) => *i as i32,
limbo_core::RefValue::Float(f) => *f as i32,
_ => unreachable!(),
};
assert_eq!(current_read_index, id);
@@ -260,7 +260,7 @@ fn test_regression_multi_row_insert() -> anyhow::Result<()> {
let row = rows.row().unwrap();
let first_value = row.get_values().first().expect("missing id");
let id = match first_value {
limbo_core::OwnedValue::Float(f) => *f as i32,
RefValue::Float(f) => *f as i32,
_ => panic!("expected float"),
};
actual_ids.push(id);
@@ -370,8 +370,8 @@ fn test_wal_checkpoint() -> anyhow::Result<()> {
let row = rows.row().unwrap();
let first_value = row.get_value(0);
let id = match first_value {
limbo_core::OwnedValue::Integer(i) => *i as i32,
limbo_core::OwnedValue::Float(f) => *f as i32,
RefValue::Integer(i) => *i as i32,
RefValue::Float(f) => *f as i32,
_ => unreachable!(),
};
assert_eq!(current_index, id as usize);
@@ -434,7 +434,7 @@ fn test_wal_restart() -> anyhow::Result<()> {
let row = rows.row().unwrap();
let first_value = row.get_value(0);
let count = match first_value {
limbo_core::OwnedValue::Integer(i) => i,
RefValue::Integer(i) => i,
_ => unreachable!(),
};
debug!("counted {}", count);