Skip to content

Commit

Permalink
Added test for select operator
Browse files Browse the repository at this point in the history
  • Loading branch information
Griezn committed Nov 11, 2024
1 parent 2760987 commit 1366e8e
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/queryTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,60 @@ TEST_F(QueryTestFixture, test_query_join)
}


TEST_F(QueryTestFixture, test_query_select)
{
filter_check_t conditions1[1] = {check_filter};
filter_check_t conditions2[1] = {check_filter3};
join_check_t conditions3[1] = {check_join};
uint8_t predicates[1] = {PREDICATE_HAS_SKILL};

operator_t filter_has_skill = {
.type = FILTER,
.left = nullptr,
.right = nullptr,
.params = {.filter = {.size = 1, .checks = conditions1}}
};

operator_t filter_req_skill = {
.type = FILTER,
.left = nullptr,
.right = nullptr,
.params = {.filter = {.size = 1, .checks = conditions2}}
};

operator_t join_op = {
.type = JOIN,
.left = &filter_has_skill,
.right = &filter_req_skill,
.params = {.join = {.size = 1, .checks = conditions3}}
};

operator_t select_op = {
.type = SELECT,
.left = &join_op,
.right = nullptr,
.params = {.select = {.size = 1, .colums = predicates}}
};

query_t query = {.root = &select_op};

execute_query(&query, gsource, gsink);

triple_t expected[5] = {
{SUBJECT_ALICE, PREDICATE_HAS_SKILL, OBJECT_PROGRAMMING},

{SUBJECT_BOB, PREDICATE_HAS_SKILL, OBJECT_DATA_ANALYSIS},

{SUBJECT_CHARLIE, PREDICATE_HAS_SKILL, OBJECT_PROGRAMMING},

{SUBJECT_DAVID, PREDICATE_HAS_SKILL, OBJECT_PROGRAMMING},

{SUBJECT_EMILY, PREDICATE_HAS_SKILL, OBJECT_PROGRAMMING},
};
ASSERT_TRUE(ARR_EQ(gsink->buffer.data, expected, 5));
}


bool check_filter4(const triple_t in)
{
return in.predicate == PREDICATE_HAS_AGE;
Expand Down

0 comments on commit 1366e8e

Please sign in to comment.