From 848a0682bbdbf48c62a640471a2612224b4cbced Mon Sep 17 00:00:00 2001 From: Elliana May Date: Sun, 14 Apr 2024 00:39:27 +0800 Subject: [PATCH] add enum to test_all_types --- src/test_all_types.rs | 18 +++++++++++++++--- src/types/value_ref.rs | 3 ++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/test_all_types.rs b/src/test_all_types.rs index 5499aab4..893088ac 100644 --- a/src/test_all_types.rs +++ b/src/test_all_types.rs @@ -18,9 +18,6 @@ fn test_all_types() -> crate::Result<()> { // union is currently blocked by https://github.com/duckdb/duckdb/pull/11326 "union", // these remaining types are not yet supported by duckdb-rs - "small_enum", - "medium_enum", - "large_enum", "struct", "struct_of_arrays", "array_of_structs", @@ -349,6 +346,21 @@ fn test_single(idx: &mut i32, column: String, value: ValueRef) { ), _ => assert_eq!(value, ValueRef::Null), }, + "small_enum" => match idx { + 0 => assert_eq!(value.to_owned(), Value::Enum("DUCK_DUCK_ENUM".to_string())), + 1 => assert_eq!(value.to_owned(), Value::Enum("GOOSE".to_string())), + _ => assert_eq!(value, ValueRef::Null), + }, + "medium_enum" => match idx { + 0 => assert_eq!(value.to_owned(), Value::Enum("enum_0".to_string())), + 1 => assert_eq!(value.to_owned(), Value::Enum("enum_1".to_string())), + _ => assert_eq!(value, ValueRef::Null), + }, + "large_enum" => match idx { + 0 => assert_eq!(value.to_owned(), Value::Enum("enum_0".to_string())), + 1 => assert_eq!(value.to_owned(), Value::Enum("enum_69999".to_string())), + _ => assert_eq!(value, ValueRef::Null), + }, _ => todo!("{column:?}"), } } diff --git a/src/types/value_ref.rs b/src/types/value_ref.rs index f1e2d4cd..d520f8f1 100644 --- a/src/types/value_ref.rs +++ b/src/types/value_ref.rs @@ -194,7 +194,8 @@ impl From> for Value { EnumType::UInt16(res) => res.values(), EnumType::UInt32(res) => res.values(), }, - ).to_owned(); + ) + .to_owned(); if let Value::Text(s) = value { Value::Enum(s)