This commit is contained in:
Pere Diaz Bou
2025-03-29 21:47:35 +01:00
parent 4a9c4cff02
commit d9f5cd870d
13 changed files with 47 additions and 92 deletions

View File

@@ -30,7 +30,7 @@ fn test_last_insert_rowid_basic() -> anyhow::Result<()> {
match rows.step()? {
StepResult::Row => {
let row = rows.row().unwrap();
if let limbo_core::RefValue::Integer(id) = row.get_value(0) {
if let limbo_core::OwnedValue::Integer(id) = row.get_value(0) {
assert_eq!(*id, 1, "First insert should have rowid 1");
}
}
@@ -66,7 +66,7 @@ fn test_last_insert_rowid_basic() -> anyhow::Result<()> {
match rows.step()? {
StepResult::Row => {
let row = rows.row().unwrap();
if let limbo_core::RefValue::Integer(id) = row.get_value(0) {
if let limbo_core::OwnedValue::Integer(id) = row.get_value(0) {
last_id = *id;
}
}
@@ -112,7 +112,7 @@ fn test_integer_primary_key() -> anyhow::Result<()> {
match select_query.step()? {
StepResult::Row => {
let row = select_query.row().unwrap();
if let limbo_core::RefValue::Integer(id) = row.get_value(0) {
if let limbo_core::OwnedValue::Integer(id) = row.get_value(0) {
rowids.push(*id);
}
}

View File

@@ -15,7 +15,10 @@ fn test_statement_reset_bind() -> anyhow::Result<()> {
match stmt.step()? {
StepResult::Row => {
let row = stmt.row().unwrap();
assert_eq!(*row.get_value(0), limbo_core::OwnedValue::Integer(1));
assert_eq!(
*row.get::<&OwnedValue>(0).unwrap(),
limbo_core::OwnedValue::Integer(1)
);
}
StepResult::IO => tmp_db.io.run_once()?,
_ => break,
@@ -30,7 +33,10 @@ fn test_statement_reset_bind() -> anyhow::Result<()> {
match stmt.step()? {
StepResult::Row => {
let row = stmt.row().unwrap();
assert_eq!(*row.get_value(0), limbo_core::OwnedValue::Integer(2));
assert_eq!(
*row.get::<&OwnedValue>(0).unwrap(),
limbo_core::OwnedValue::Integer(2)
);
}
StepResult::IO => tmp_db.io.run_once()?,
_ => break,
@@ -63,23 +69,23 @@ fn test_statement_bind() -> anyhow::Result<()> {
match stmt.step()? {
StepResult::Row => {
let row = stmt.row().unwrap();
if let limbo_core::RefValue::Text(s) = row.get_value(0) {
if let limbo_core::OwnedValue::Text(s) = row.get::<&OwnedValue>(0).unwrap() {
assert_eq!(s.as_str(), "hello")
}
if let limbo_core::RefValue::Text(s) = row.get_value(1) {
if let limbo_core::OwnedValue::Text(s) = row.get::<&OwnedValue>(1).unwrap() {
assert_eq!(s.as_str(), "hello")
}
if let limbo_core::RefValue::Integer(i) = row.get_value(2) {
if let limbo_core::OwnedValue::Integer(i) = row.get::<&OwnedValue>(2).unwrap() {
assert_eq!(*i, 42)
}
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::Blob(v) = row.get::<&OwnedValue>(3).unwrap() {
assert_eq!(v.as_slice(), &vec![0x1 as u8, 0x2, 0x3])
}
if let limbo_core::RefValue::Float(f) = row.get_value(4) {
if let limbo_core::OwnedValue::Float(f) = row.get::<&OwnedValue>(4).unwrap() {
assert_eq!(*f, 0.5)
}
}

View File

@@ -44,17 +44,8 @@ fn test_simple_overflow_page() -> anyhow::Result<()> {
match rows.step()? {
StepResult::Row => {
let row = rows.row().unwrap();
let first_value = row.get_value(0);
let text = row.get_value(1);
let id = match first_value {
limbo_core::RefValue::Integer(i) => *i as i32,
limbo_core::RefValue::Float(f) => *f as i32,
_ => unreachable!(),
};
let text = match text {
limbo_core::RefValue::Text(t) => t.as_str(),
_ => unreachable!(),
};
let id = row.get::<i64>(0).unwrap();
let text = row.get::<&str>(0).unwrap();
assert_eq!(1, id);
compare_string(&huge_text, text);
}
@@ -120,17 +111,8 @@ fn test_sequential_overflow_page() -> anyhow::Result<()> {
match rows.step()? {
StepResult::Row => {
let row = rows.row().unwrap();
let first_value = row.get_value(0);
let text = row.get_value(1);
let id = match first_value {
limbo_core::RefValue::Integer(i) => *i as i32,
limbo_core::RefValue::Float(f) => *f as i32,
_ => unreachable!(),
};
let text = match text {
limbo_core::RefValue::Text(t) => t.as_str(),
_ => unreachable!(),
};
let id = row.get::<i64>(0).unwrap();
let text = row.get::<String>(1).unwrap();
let huge_text = &huge_texts[current_index];
compare_string(huge_text, text);
assert_eq!(current_index, id as usize);
@@ -305,7 +287,7 @@ fn test_statement_reset() -> anyhow::Result<()> {
StepResult::Row => {
let row = stmt.row().unwrap();
assert_eq!(
*row.get::<&OwnedValue>(0),
*row.get::<&OwnedValue>(0).unwrap(),
limbo_core::OwnedValue::Integer(1)
);
break;
@@ -322,7 +304,7 @@ fn test_statement_reset() -> anyhow::Result<()> {
StepResult::Row => {
let row = stmt.row().unwrap();
assert_eq!(
*row.get::<&OwnedValue>(0),
*row.get::<&OwnedValue>(0).unwrap(),
limbo_core::OwnedValue::Integer(1)
);
break;
@@ -374,12 +356,7 @@ fn test_wal_checkpoint() -> anyhow::Result<()> {
match rows.step()? {
StepResult::Row => {
let row = rows.row().unwrap();
let first_value = row.get_value(0);
let id = match first_value {
RefValue::Integer(i) => *i as i32,
RefValue::Float(f) => *f as i32,
_ => unreachable!(),
};
let id = row.get::<i64>(0).unwrap();
assert_eq!(current_index, id as usize);
current_index += 1;
}
@@ -438,13 +415,9 @@ fn test_wal_restart() -> anyhow::Result<()> {
match rows.step()? {
StepResult::Row => {
let row = rows.row().unwrap();
let first_value = row.get_value(0);
let count = match first_value {
RefValue::Integer(i) => i,
_ => unreachable!(),
};
let count = row.get::<i64>(0).unwrap();
debug!("counted {}", count);
return Ok(*count as usize);
return Ok(count as usize);
}
StepResult::IO => {
tmp_db.io.run_once()?;

View File

@@ -81,11 +81,7 @@ fn test_wal_1_writer_1_reader() -> Result<()> {
match rows.step().unwrap() {
StepResult::Row => {
let row = rows.row().unwrap();
let first_value = row.get_value(0);
let id = match first_value {
RefValue::Integer(i) => *i as i32,
_ => unreachable!(),
};
let id = row.get::<i64>(0).unwrap();
assert_eq!(id, i);
i += 1;
}