Skip to content

Commit d150003

Browse files
mlafeldtMaxxen
authored andcommitted
Add test
1 parent 8a62eca commit d150003

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

crates/duckdb/src/types/value_ref.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,3 +369,46 @@ where
369369
}
370370
}
371371
}
372+
373+
#[cfg(test)]
374+
mod tests {
375+
use crate::types::Type;
376+
use crate::{Connection, Result};
377+
378+
#[test]
379+
fn test_list_types() -> Result<()> {
380+
let conn = Connection::open_in_memory()?;
381+
conn.execute(
382+
"CREATE TABLE test_table (float_list FLOAT[], double_list DOUBLE[], int_list INT[])",
383+
[],
384+
)?;
385+
conn.execute("INSERT INTO test_table VALUES ([1.5, 2.5], [3.5, 4.5], [1, 2])", [])?;
386+
387+
let mut stmt = conn.prepare("SELECT float_list, double_list, int_list FROM test_table")?;
388+
let mut rows = stmt.query([])?;
389+
let row = rows.next()?.unwrap();
390+
391+
let float_list = row.get_ref_unwrap(0);
392+
assert!(
393+
matches!(float_list.data_type(), Type::List(ref inner_type) if **inner_type == Type::Float),
394+
"Expected Type::List(Type::Float), got {:?}",
395+
float_list.data_type()
396+
);
397+
398+
let double_list = row.get_ref_unwrap(1);
399+
assert!(
400+
matches!(double_list.data_type(), Type::List(ref inner_type) if **inner_type == Type::Double),
401+
"Expected Type::List(Type::Double), got {:?}",
402+
double_list.data_type()
403+
);
404+
405+
let int_list = row.get_ref_unwrap(2);
406+
assert!(
407+
matches!(int_list.data_type(), Type::List(ref inner_type) if **inner_type == Type::Int),
408+
"Expected Type::List(Type::Int), got {:?}",
409+
int_list.data_type()
410+
);
411+
412+
Ok(())
413+
}
414+
}

0 commit comments

Comments
 (0)