Skip to content

Commit

Permalink
add operator precedence unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
unitmatrix committed Sep 14, 2024
1 parent b50a45a commit 50766fe
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/internal/include/sp_cb_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,26 @@ static void cb_record_not_contains(int id, struct task_check *check,
TEST_CHECK(ret == 0);
}

static void cb_select_and_or_precedence(int id, struct task_check *check,
char *buf, size_t size)
{
int ret;

/* Expect all 11 rows */
ret = mp_count_rows(buf, size);
TEST_CHECK_(ret == 11, "expected 11 rows but got %d", ret);
}

static void cb_select_not_precedence(int id, struct task_check *check,
char *buf, size_t size)
{
int ret;

/* Expect all 11 rows */
ret = mp_count_rows(buf, size);
TEST_CHECK_(ret == 11, "expected 11 rows but got %d", ret);
}

/* Callback functions to perform checks over results */
static void cb_select_sub_blue(int id, struct task_check *check,
char *buf, size_t size)
Expand Down
14 changes: 14 additions & 0 deletions tests/internal/include/sp_select_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ struct task_check select_keys_checks[] = {
"SELECT id FROM TAG:'samples' WHERE @record.contains(x);",
cb_record_not_contains,
},

/* Operator precedence */
{
18, 0, 0, 0,
"and_or_precedence",
"SELECT id FROM STREAM:FLB WHERE false AND true OR true;",
cb_select_and_or_precedence,
},
{
19, 0, 0, 0,
"not_precedence",
"SELECT id FROM STREAM:FLB WHERE NOT true OR true;",
cb_select_not_precedence,
},
};

#endif

0 comments on commit 50766fe

Please sign in to comment.