diff --git a/test/src/unit-request-handlers.cc b/test/src/unit-request-handlers.cc index 5480e86b0f43..a7f890d2988e 100644 --- a/test/src/unit-request-handlers.cc +++ b/test/src/unit-request-handlers.cc @@ -35,6 +35,7 @@ #include "test/support/src/helpers.h" #include "test/support/src/mem_helpers.h" #include "test/support/tdb_catch.h" +#include "tiledb/api/c_api/array_schema_evolution/array_schema_evolution_api_internal.h" #include "tiledb/api/c_api/buffer/buffer_api_internal.h" #include "tiledb/api/c_api/context/context_api_internal.h" #include "tiledb/api/c_api/string/string_api_internal.h" diff --git a/tiledb/api/c_api/array/array_api.cc b/tiledb/api/c_api/array/array_api.cc index 653acf844759..8796ddb2c681 100644 --- a/tiledb/api/c_api/array/array_api.cc +++ b/tiledb/api/c_api/array/array_api.cc @@ -71,8 +71,6 @@ capi_return_t tiledb_array_schema_load( tiledb_ctx_t* ctx, const char* array_uri, tiledb_array_schema_t** array_schema) { - // Create array schema - ensure_context_is_valid(ctx); ensure_output_pointer_is_valid(array_schema); // Use a default constructed config to load the schema with default options. @@ -87,8 +85,7 @@ capi_return_t tiledb_array_schema_load_with_config( tiledb_config_t* config, const char* array_uri, tiledb_array_schema_t** array_schema) { - ensure_context_is_valid(ctx); - ensure_config_is_valid(config); + ensure_config_is_valid_if_present(config); ensure_output_pointer_is_valid(array_schema); // Use passed config or context config to load the schema with set options. diff --git a/tiledb/api/c_api/array/test/unit_capi_array.cc b/tiledb/api/c_api/array/test/unit_capi_array.cc index 82e241fee398..c335ab86379b 100644 --- a/tiledb/api/c_api/array/test/unit_capi_array.cc +++ b/tiledb/api/c_api/array/test/unit_capi_array.cc @@ -66,6 +66,42 @@ TEST_CASE( CHECK(schema == nullptr); } +TEST_CASE( + "C API: tiledb_array_schema_load_with_config argument validation", + "[capi][array]") { + capi_return_t rc; + ordinary_context ctx{}; + tiledb_config_t* config{}; + tiledb_array_schema_t* schema{}; + /* + * No "success" section here; too much overhead to set up. + */ + SECTION("null context") { + rc = tiledb_array_schema_load_with_config( + nullptr, config, TEST_URI, &schema); + REQUIRE(tiledb_status(rc) == TILEDB_INVALID_CONTEXT); + } + SECTION("null config") { + // Note: a null config is actually valid and will use the context's config. + // This test case merely fails without the proper overhead setup. + rc = tiledb_array_schema_load_with_config( + ctx.context, nullptr, TEST_URI, &schema); + REQUIRE(tiledb_status(rc) == TILEDB_ERR); + } + SECTION("null uri") { + rc = tiledb_array_schema_load_with_config( + ctx.context, config, nullptr, &schema); + REQUIRE(tiledb_status(rc) == TILEDB_ERR); + } + SECTION("null schema") { + rc = tiledb_array_schema_load_with_config( + ctx.context, config, TEST_URI, nullptr); + REQUIRE(tiledb_status(rc) == TILEDB_ERR); + } + REQUIRE_NOTHROW(tiledb_array_schema_free(&schema)); + CHECK(schema == nullptr); +} + TEST_CASE("C API: tiledb_array_alloc argument validation", "[capi][array]") { capi_return_t rc; ordinary_context ctx{};