Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pd/sc 39775/remove qc set membership constraint #11

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ if (TILEDB_CPP_API)
src/unit-cppapi-nullable.cc
src/unit-cppapi-partial-attribute-write.cc
src/unit-cppapi-query.cc
#src/unit-cppapi-query-condition-enumerations.cc
src/unit-cppapi-query-condition-sets.cc
src/cpp-integration-query-condition.cc
src/unit-cppapi-schema.cc
Expand Down
71 changes: 61 additions & 10 deletions test/src/unit-cppapi-enumerations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ TEST_CASE_METHOD(

TEST_CASE_METHOD(
CPPEnumerationFx,
"CPP: Enumeration Query - Invalid Enumeration Value",
"CPP: Enumeration Query - Invalid Enumeration Value is Always False",
"[enumeration][query][basic]") {
create_array();

Expand All @@ -542,10 +542,64 @@ TEST_CASE_METHOD(
.set_data_buffer("attr1", attr1)
.set_condition(qc);

// Check that the error message is helpful to users.
auto matcher = Catch::Matchers::ContainsSubstring(
"Enumeration value not found for field 'attr1'");
REQUIRE_THROWS_WITH(query.submit(), matcher);
REQUIRE_NOTHROW(query.submit());

std::vector<int> dim_expect = {1, 2, 3, 4, 5};
std::vector<int> attr1_expect = {
INT32_MIN, INT32_MIN, INT32_MIN, INT32_MIN, INT32_MIN};

REQUIRE(dim == dim_expect);
REQUIRE(attr1 == attr1_expect);
}

TEST_CASE_METHOD(
CPPEnumerationFx,
"CPP: Enumeration Query - Invalid Enumeration Value Accepted by EQ",
"[enumeration][query][basic]") {
create_array();

// Attempt to query with an enumeration value that isn't in the Enumeration
QueryCondition qc(ctx_);
qc.init("attr1", "alf", 3, TILEDB_EQ);

// Execute the query condition against the array
std::vector<int> dim(5);
std::vector<int> attr1(5);

auto array = Array(ctx_, uri_, TILEDB_READ);
Query query(ctx_, array);
query.add_range("dim", 1, 5)
.set_layout(TILEDB_ROW_MAJOR)
.set_data_buffer("dim", dim)
.set_data_buffer("attr1", attr1)
.set_condition(qc);

CHECK_NOTHROW(query.submit());
}

TEST_CASE_METHOD(
CPPEnumerationFx,
"CPP: Enumeration Query - Invalid Enumeration Value Accepted by IN",
"[enumeration][query][basic]") {
create_array();

// Attempt to query with an enumeration value that isn't in the Enumeration
std::vector<std::string> vals = {"alf", "fred"};
auto qc = QueryConditionExperimental::create(ctx_, "attr1", vals, TILEDB_IN);

// Execute the query condition against the array
std::vector<int> dim(5);
std::vector<int> attr1(5);

auto array = Array(ctx_, uri_, TILEDB_READ);
Query query(ctx_, array);
query.add_range("dim", 1, 5)
.set_layout(TILEDB_ROW_MAJOR)
.set_data_buffer("dim", dim)
.set_data_buffer("attr1", attr1)
.set_condition(qc);

CHECK_NOTHROW(query.submit());
}

TEST_CASE_METHOD(
Expand All @@ -572,7 +626,7 @@ TEST_CASE_METHOD(
TEST_CASE_METHOD(
CPPEnumerationFx,
"CPP: Enumeration Query - Attempt to query on empty enumeration",
"[enumeration][query][error]") {
"[enumeration][query][empty-results]") {
create_array(true);

// Attempt to query with an enumeration value that isn't in the Enumeration
Expand All @@ -591,10 +645,7 @@ TEST_CASE_METHOD(
.set_data_buffer("attr3", attr3)
.set_condition(qc);

// Check that the error message is helpful to users.
auto matcher = Catch::Matchers::ContainsSubstring(
"Enumeration value not found for field 'attr3'");
REQUIRE_THROWS_WITH(query.submit(), matcher);
REQUIRE_NOTHROW(query.submit());
}

CPPEnumerationFx::CPPEnumerationFx()
Expand Down
Loading
Loading