add unit test for utf8array
@@ -13,11 +13,13 @@ use crate::UInt8Type;
use common_arrow::arrow::buffer::Buffer;
#[test]
-fn test_primitive_array_as_ref() -> Result<()> {
+fn test_array_as_ref() -> Result<()> {
+ // Test DFUint16Array
let df_uint16_array = DFUInt16Array::new_from_iter(1u16..4u16);
let arrow_uint16_array : &PrimitiveArray<UInt16Type> = df_uint16_array.as_ref();
assert_eq!(&[1u16, 2, 3], &arrow_uint16_array.values());
+ // Test DFBooleanArray
let mut boolean_builder = BooleanArrayBuilder::new(3);
boolean_builder.append_value(true);
boolean_builder.append_value(false);
@@ -27,5 +29,14 @@ fn test_primitive_array_as_ref() -> Result<()> {
// 5 means 0b_101
assert_eq!(&[5], &arrow_boolean_array.values().as_slice());
+ // Test DFUtf8Array
+ let mut utf8_builder = Utf8ArrayBuilder::new(3, 2);
+ utf8_builder.append_value("1a");
+ utf8_builder.append_value("2b");
+ utf8_builder.append_value("3c");
+ let df_utf8_array = utf8_builder.finish();
+ let arrow_string_array = df_utf8_array.as_ref();
+ assert_eq!(&"1a2b3c".as_bytes(), &arrow_string_array.value_data().as_slice());
+
Ok(())
}
