Skip to content

Commit

Permalink
Add unit test for tiledb_array_schema_load_with_config; Couple fixes …
Browse files Browse the repository at this point in the history
…after rebase.
  • Loading branch information
bekadavis9 committed Sep 5, 2024
1 parent ea859db commit 4838f6b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
1 change: 1 addition & 0 deletions test/src/unit-request-handlers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 1 addition & 4 deletions tiledb/api/c_api/array/array_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
36 changes: 36 additions & 0 deletions tiledb/api/c_api/array/test/unit_capi_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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{};
Expand Down

0 comments on commit 4838f6b

Please sign in to comment.