Skip to content

Commit

Permalink
add missing smallint functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Mause committed May 16, 2024
1 parent 10bf6ff commit 586530a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/main/capi/duckdb_value-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ duckdb_value duckdb_create_utinyint(uint8_t input) {
uint8_t duckdb_get_utinyint(duckdb_value val) {
return UnwrapValue(val).GetValue<uint8_t>();
}
duckdb_value duckdb_create_smallint(int16_t input) {
return WrapValue(new duckdb::Value(duckdb::Value::SMALLINT(input)));
}
int16_t duckdb_get_smallint(duckdb_value val) {
return UnwrapValue(val).GetValue<int16_t>();
}
duckdb_value duckdb_create_usmallint(uint16_t input) {
return WrapValue(new duckdb::Value(duckdb::Value::USMALLINT(input)));
}
uint16_t duckdb_get_usmallint(duckdb_value val) {
return UnwrapValue(val).GetValue<uint16_t>();
}
duckdb_value duckdb_create_integer(int32_t input) {
return WrapValue(new duckdb::Value(duckdb::Value::INTEGER(input)));
}
Expand Down
9 changes: 6 additions & 3 deletions test/api/capi/test_capi_complex_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,16 @@ TEST_CASE("duckdb_create_value", "[capi]") {
duckdb_destroy_value(&value); \
}

TEST_VALUE(duckdb_create_bigint(42), duckdb_get_bigint, 42);
TEST_VALUE(duckdb_create_bool(true), duckdb_get_bool, true);
TEST_VALUE(duckdb_create_integer(42), duckdb_get_integer, 42);

TEST_VALUE(duckdb_create_tinyint(42), duckdb_get_tinyint, 42);
TEST_VALUE(duckdb_create_utinyint(32), duckdb_get_utinyint, 32);
TEST_VALUE(duckdb_create_bigint(42), duckdb_get_bigint, 42);
TEST_VALUE(duckdb_create_smallint(42), duckdb_get_smallint, 42);
TEST_VALUE(duckdb_create_usmallint(42), duckdb_get_usmallint, 42);
TEST_VALUE(duckdb_create_integer(42), duckdb_get_integer, 42);
TEST_VALUE(duckdb_create_uinteger(42), duckdb_get_uinteger, 42);
TEST_VALUE(duckdb_create_bigint(42), duckdb_get_bigint, 42);
TEST_VALUE(duckdb_create_ubigint(42), duckdb_get_ubigint, 42);
TEST_VALUE(duckdb_create_float(42.0), duckdb_get_float, 42.0);
TEST_VALUE(duckdb_create_double(42.0), duckdb_get_double, 42.0);
/*
Expand Down

0 comments on commit 586530a

Please sign in to comment.