From 8080d90d91d8792b0f48338444d3a919a0b1f2b8 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Wed, 25 Sep 2024 17:30:05 -0400 Subject: [PATCH 1/2] [c++] Extend some unit-test cases --- libtiledbsoma/src/soma/soma_array.cc | 5 ----- libtiledbsoma/test/unit_soma_dataframe.cc | 18 ++++++++++++++---- libtiledbsoma/test/unit_soma_sparse_ndarray.cc | 9 +++++++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/libtiledbsoma/src/soma/soma_array.cc b/libtiledbsoma/src/soma/soma_array.cc index fdfdfa9308..ef6c3d3471 100644 --- a/libtiledbsoma/src/soma/soma_array.cc +++ b/libtiledbsoma/src/soma/soma_array.cc @@ -1422,11 +1422,6 @@ void SOMAArray::_set_current_domain_from_shape( // Variant-indexed dataframes must use a separate path _check_dims_are_int64(); - if (_get_current_domain().is_empty()) { - throw TileDBSOMAError( - "[SOMAArray::resize] array must already be sized"); - } - auto tctx = ctx_->tiledb_ctx(); ArraySchema schema = arr_->schema(); Domain domain = schema.domain(); diff --git a/libtiledbsoma/test/unit_soma_dataframe.cc b/libtiledbsoma/test/unit_soma_dataframe.cc index 2171bc50e6..beb815f50d 100644 --- a/libtiledbsoma/test/unit_soma_dataframe.cc +++ b/libtiledbsoma/test/unit_soma_dataframe.cc @@ -879,8 +879,7 @@ TEST_CASE_METHOD( VariouslyIndexedDataFrameFixture, "SOMADataFrame: variant-indexed dataframe dim-sjid-str attr-u32", "[SOMADataFrame]") { - // auto use_current_domain = GENERATE(false, true); - auto use_current_domain = GENERATE(false); + auto use_current_domain = GENERATE(false, true); std::ostringstream section; section << "- use_current_domain=" << use_current_domain; SECTION(section.str()) { @@ -979,7 +978,12 @@ TEST_CASE_METHOD( REQUIRE(dom_sjid == std::vector({0, 99})); REQUIRE(dom_str == std::vector({"", ""})); - REQUIRE(maxdom_sjid == std::vector({0, 99})); + if (!use_current_domain) { + REQUIRE(maxdom_sjid == std::vector({0, 99})); + } else { + REQUIRE(maxdom_sjid[0] == 0); + REQUIRE(maxdom_sjid[1] > 2000000000); + } REQUIRE(maxdom_str == std::vector({"", ""})); soma_dataframe->close(); @@ -1059,7 +1063,13 @@ TEST_CASE_METHOD( REQUIRE(dom_sjid == std::vector({0, 99})); REQUIRE(dom_str == std::vector({"", ""})); - REQUIRE(maxdom_sjid == std::vector({0, 99})); + if (!use_current_domain) { + REQUIRE(maxdom_sjid == std::vector({0, 99})); + } else { + REQUIRE(maxdom_sjid[0] == 0); + REQUIRE(maxdom_sjid[1] > 2000000000); + } + REQUIRE(maxdom_str == std::vector({"", ""})); REQUIRE(ned_str == std::vector({"", ""})); diff --git a/libtiledbsoma/test/unit_soma_sparse_ndarray.cc b/libtiledbsoma/test/unit_soma_sparse_ndarray.cc index c73ddef119..658fab60f7 100644 --- a/libtiledbsoma/test/unit_soma_sparse_ndarray.cc +++ b/libtiledbsoma/test/unit_soma_sparse_ndarray.cc @@ -39,8 +39,7 @@ TEST_CASE("SOMASparseNDArray: basic", "[SOMASparseNDArray]") { int64_t dim_max = 999; int64_t shape = 1000; - // auto use_current_domain = GENERATE(false, true); - auto use_current_domain = GENERATE(true); + auto use_current_domain = GENERATE(false, true); // TODO this could be formatted with fmt::format which is part of internal // header spd/log/fmt/fmt.h and should not be used. In C++20, this can be // replaced with std::format. @@ -148,6 +147,12 @@ TEST_CASE("SOMASparseNDArray: basic", "[SOMASparseNDArray]") { REQUIRE_THROWS(soma_sparse->resize(new_shape)); // Now set the shape soma_sparse->upgrade_shape(new_shape); + soma_sparse->close(); + + soma_sparse->open(OpenMode::read); + soma_sparse->close(); + + soma_sparse->open(OpenMode::write); REQUIRE(soma_sparse->has_current_domain()); // Should not fail since we're setting it to what it already is. soma_sparse->resize(new_shape); From a3bf7671dfc806e8dceb2eb47a1f9f06aaddff67 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Wed, 25 Sep 2024 19:31:21 -0400 Subject: [PATCH 2/2] code-review feedback --- libtiledbsoma/test/unit_soma_sparse_ndarray.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/libtiledbsoma/test/unit_soma_sparse_ndarray.cc b/libtiledbsoma/test/unit_soma_sparse_ndarray.cc index 658fab60f7..07e6cd34c7 100644 --- a/libtiledbsoma/test/unit_soma_sparse_ndarray.cc +++ b/libtiledbsoma/test/unit_soma_sparse_ndarray.cc @@ -150,6 +150,7 @@ TEST_CASE("SOMASparseNDArray: basic", "[SOMASparseNDArray]") { soma_sparse->close(); soma_sparse->open(OpenMode::read); + REQUIRE(soma_sparse->has_current_domain()); soma_sparse->close(); soma_sparse->open(OpenMode::write);