Skip to content

Commit c5b7a19

Browse files
committed
Test Inserter trait
1 parent ed06007 commit c5b7a19

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

crates/duckdb/src/core/vector.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,35 @@ impl StructVector {
364364
}
365365
}
366366
}
367+
368+
#[cfg(test)]
369+
mod tests {
370+
use super::*;
371+
use crate::core::{DataChunkHandle, LogicalTypeId};
372+
use std::ffi::CString;
373+
374+
#[test]
375+
fn test_insert_string_values() {
376+
let chunk = DataChunkHandle::new(&[LogicalTypeId::Varchar.into()]);
377+
let vector = chunk.flat_vector(0);
378+
chunk.set_len(3);
379+
380+
vector.insert(0, "first");
381+
vector.insert(1, &String::from("second"));
382+
let cstring = CString::new("third").unwrap();
383+
vector.insert(2, cstring);
384+
}
385+
386+
#[test]
387+
fn test_insert_byte_values() {
388+
let chunk = DataChunkHandle::new(&[LogicalTypeId::Blob.into()]);
389+
let vector = chunk.flat_vector(0);
390+
chunk.set_len(2);
391+
392+
vector.insert(0, b"hello world".as_slice());
393+
vector.insert(
394+
1,
395+
&vec![0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64],
396+
);
397+
}
398+
}

0 commit comments

Comments
 (0)