Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
jedelbo committed Sep 6, 2022
1 parent 284bdcd commit 38dabaa
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions test/test_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ TEST(Parser_StringOperations)
TableRef t = g.add_table("person");
ColKey name_col = t->add_column(type_String, "name", true);
ColKey link_col = t->add_column(*t, "father");
std::vector<std::string> names = {"Billy", "Bob", "Joe", "Jake", "Joel"};
std::vector<std::string> names = {"Billy", "Bob", "Joe", "Jake", "Joel", "Unicorn🦄"};
std::vector<ObjKey> people_keys;
t->create_objects(names.size(), people_keys);
for (size_t i = 0; i < t->size(); ++i) {
Expand All @@ -834,16 +834,17 @@ TEST(Parser_StringOperations)
}
t->create_object(); // null
t->get_object(people_keys[4]).set_null(link_col);
size_t nb_names = names.size();

verify_query(test_context, t, "name == 'Bob'", 1);
verify_query(test_context, t, "father.name == 'Bob'", 1);
verify_query(test_context, t, "name ==[c] 'Bob'", 1);
verify_query(test_context, t, "father.name ==[c] 'Bob'", 1);

verify_query(test_context, t, "name != 'Bob'", 5);
verify_query(test_context, t, "father.name != 'Bob'", 5);
verify_query(test_context, t, "name !=[c] 'bOB'", 5);
verify_query(test_context, t, "father.name !=[c] 'bOB'", 5);
verify_query(test_context, t, "name != 'Bob'", nb_names);
verify_query(test_context, t, "father.name != 'Bob'", nb_names);
verify_query(test_context, t, "name !=[c] 'bOB'", nb_names);
verify_query(test_context, t, "father.name !=[c] 'bOB'", nb_names);

verify_query(test_context, t, "name contains \"oe\"", 2);
verify_query(test_context, t, "father.name contains \"oe\"", 2);
Expand All @@ -865,23 +866,25 @@ TEST(Parser_StringOperations)
verify_query(test_context, t, "name like[c] \"?O?\"", 2);
verify_query(test_context, t, "father.name like[c] \"?O?\"", 2);

verify_query(test_context, t, "name ==[c] 'unicorn🦄'", 1);

verify_query(test_context, t, "name == NULL", 1);
verify_query(test_context, t, "name == nil", 1);
verify_query(test_context, t, "NULL == name", 1);
verify_query(test_context, t, "name != NULL", 5);
verify_query(test_context, t, "NULL != name", 5);
verify_query(test_context, t, "name != NULL", nb_names);
verify_query(test_context, t, "NULL != name", nb_names);
verify_query(test_context, t, "name ==[c] NULL", 1);
verify_query(test_context, t, "NULL ==[c] name", 1);
verify_query(test_context, t, "name !=[c] NULL", 5);
verify_query(test_context, t, "NULL !=[c] name", 5);
verify_query(test_context, t, "name !=[c] NULL", nb_names);
verify_query(test_context, t, "NULL !=[c] name", nb_names);

// for strings 'NULL' is also a synonym for the null string
verify_query(test_context, t, "name CONTAINS NULL", 6);
verify_query(test_context, t, "name CONTAINS[c] NULL", 6);
verify_query(test_context, t, "name BEGINSWITH NULL", 6);
verify_query(test_context, t, "name BEGINSWITH[c] NULL", 6);
verify_query(test_context, t, "name ENDSWITH NULL", 6);
verify_query(test_context, t, "name ENDSWITH[c] NULL", 6);
verify_query(test_context, t, "name CONTAINS NULL", t->size());
verify_query(test_context, t, "name CONTAINS[c] NULL", t->size());
verify_query(test_context, t, "name BEGINSWITH NULL", t->size());
verify_query(test_context, t, "name BEGINSWITH[c] NULL", t->size());
verify_query(test_context, t, "name ENDSWITH NULL", t->size());
verify_query(test_context, t, "name ENDSWITH[c] NULL", t->size());
verify_query(test_context, t, "name LIKE NULL", 1);
verify_query(test_context, t, "name LIKE[c] NULL", 1);

Expand Down Expand Up @@ -4113,16 +4116,6 @@ TEST(Parser_Object)
}


TEST(Parser_Contains)
{
Group g;
TableRef table = g.add_table("table");
auto str_col_key = table->add_column(type_String, "str", true);
table->create_object().set(str_col_key, "Here is a Unicorn 🦄 today");
verify_query(test_context, table, "str CONTAINS 'unicorn 🦄 today'", 0);
verify_query(test_context, table, "str CONTAINS[c] 'unicorn 🦄 today'", 1);
}

TEST(Parser_OddColumnNames)
{
Group g;
Expand Down

0 comments on commit 38dabaa

Please sign in to comment.