Skip to content

Commit

Permalink
UTs and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ypatia committed Sep 27, 2024
1 parent be4a555 commit 6118738
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 37 deletions.
140 changes: 103 additions & 37 deletions test/src/unit-capi-group.cc
Original file line number Diff line number Diff line change
Expand Up @@ -592,18 +592,34 @@ TEST_CASE_METHOD(
rc = tiledb_group_open(ctx_, group2, TILEDB_WRITE);
REQUIRE(rc == TILEDB_OK);

rc =
tiledb_group_add_member(ctx_, group1, array1_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
rc =
tiledb_group_add_member(ctx_, group1, array2_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
rc =
tiledb_group_add_member(ctx_, group2, array3_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
rc =
tiledb_group_add_member(ctx_, group1, group2_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
bool add_by_type = GENERATE(true, false);
if (add_by_type) {
rc = tiledb_group_add_member_by_type(
ctx_, group1, array1_uri.c_str(), false, nullptr, TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_by_type(
ctx_, group1, array2_uri.c_str(), false, nullptr, TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_by_type(
ctx_, group2, array3_uri.c_str(), false, nullptr, TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_by_type(
ctx_, group1, group2_uri.c_str(), false, nullptr, TILEDB_GROUP);
REQUIRE(rc == TILEDB_OK);
} else {
rc = tiledb_group_add_member(
ctx_, group1, array1_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group1, array2_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group2, array3_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group1, group2_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
}

// Close group from write mode
rc = tiledb_group_close(ctx_, group1);
Expand Down Expand Up @@ -720,8 +736,16 @@ TEST_CASE_METHOD(
rc = tiledb_group_open(ctx_, group1, TILEDB_WRITE);
REQUIRE(rc == TILEDB_OK);

rc = tiledb_group_add_member(ctx_, group1, array1_uri.c_str(), false, "one");
REQUIRE(rc == TILEDB_OK);
bool add_by_type = GENERATE(true, false);
if (add_by_type) {
rc = tiledb_group_add_member_by_type(
ctx_, group1, array1_uri.c_str(), false, "one", TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
} else {
rc =
tiledb_group_add_member(ctx_, group1, array1_uri.c_str(), false, "one");
REQUIRE(rc == TILEDB_OK);
}

// Close group from write mode
rc = tiledb_group_close(ctx_, group1);
Expand Down Expand Up @@ -755,8 +779,15 @@ TEST_CASE_METHOD(
rc = tiledb_group_remove_member(ctx_, group1, "one");
REQUIRE(rc == TILEDB_OK);
// Add one back with different URI
rc = tiledb_group_add_member(ctx_, group1, array2_uri.c_str(), false, "one");
REQUIRE(rc == TILEDB_OK);
if (add_by_type) {
rc = tiledb_group_add_member_by_type(
ctx_, group1, array2_uri.c_str(), false, "one", TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
} else {
rc =
tiledb_group_add_member(ctx_, group1, array2_uri.c_str(), false, "one");
REQUIRE(rc == TILEDB_OK);
}

// Close group
rc = tiledb_group_close(ctx_, group1);
Expand Down Expand Up @@ -827,15 +858,34 @@ TEST_CASE_METHOD(
rc = tiledb_group_open(ctx_, group2, TILEDB_WRITE);
REQUIRE(rc == TILEDB_OK);

rc = tiledb_group_add_member(ctx_, group1, array1_uri.c_str(), false, "one");
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(ctx_, group1, array2_uri.c_str(), false, "two");
REQUIRE(rc == TILEDB_OK);
rc =
tiledb_group_add_member(ctx_, group2, array3_uri.c_str(), false, "three");
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(ctx_, group1, group2_uri.c_str(), false, "four");
REQUIRE(rc == TILEDB_OK);
bool add_by_type = GENERATE(true, false);
if (add_by_type) {
rc = tiledb_group_add_member_by_type(
ctx_, group1, array1_uri.c_str(), false, "one", TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_by_type(
ctx_, group1, array2_uri.c_str(), false, "two", TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_by_type(
ctx_, group2, array3_uri.c_str(), false, "three", TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_by_type(
ctx_, group1, group2_uri.c_str(), false, "four", TILEDB_GROUP);
REQUIRE(rc == TILEDB_OK);
} else {
rc =
tiledb_group_add_member(ctx_, group1, array1_uri.c_str(), false, "one");
REQUIRE(rc == TILEDB_OK);
rc =
tiledb_group_add_member(ctx_, group1, array2_uri.c_str(), false, "two");
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group2, array3_uri.c_str(), false, "three");
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group1, group2_uri.c_str(), false, "four");
REQUIRE(rc == TILEDB_OK);
}

// Close group from write mode
rc = tiledb_group_close(ctx_, group1);
Expand Down Expand Up @@ -1186,18 +1236,34 @@ TEST_CASE_METHOD(
rc = tiledb_group_open(ctx_, group2, TILEDB_WRITE);
REQUIRE(rc == TILEDB_OK);

rc = tiledb_group_add_member(
ctx_, group1, array1_relative_uri.c_str(), true, nullptr);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group1, array2_relative_uri.c_str(), true, nullptr);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group2, array3_relative_uri.c_str(), true, nullptr);
REQUIRE(rc == TILEDB_OK);
rc =
tiledb_group_add_member(ctx_, group1, group2_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
bool add_by_type = GENERATE(true, false);
if (add_by_type) {
rc = tiledb_group_add_member_by_type(
ctx_, group1, array1_relative_uri.c_str(), true, nullptr, TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_by_type(
ctx_, group1, array2_relative_uri.c_str(), true, nullptr, TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_by_type(
ctx_, group2, array3_relative_uri.c_str(), true, nullptr, TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_by_type(
ctx_, group1, group2_uri.c_str(), false, nullptr, TILEDB_GROUP);
REQUIRE(rc == TILEDB_OK);
} else {
rc = tiledb_group_add_member(
ctx_, group1, array1_relative_uri.c_str(), true, nullptr);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group1, array2_relative_uri.c_str(), true, nullptr);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group2, array3_relative_uri.c_str(), true, nullptr);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group1, group2_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
}

// Close group from write mode
rc = tiledb_group_close(ctx_, group1);
Expand Down
1 change: 1 addition & 0 deletions tiledb/api/c_api/group/group_api_external.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ TILEDB_EXPORT capi_return_t tiledb_group_add_member(
* @return `TILEDB_OK` for success and `TILEDB_ERR` for error.
*/
TILEDB_EXPORT capi_return_t tiledb_group_add_member_by_type(
tiledb_ctx_t* ctx,
tiledb_group_handle_t* group,
const char* group_uri,
const uint8_t relative,
Expand Down

0 comments on commit 6118738

Please sign in to comment.