Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
jedelbo committed Jan 25, 2024
1 parent 68fd450 commit 333d5af
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions test/test_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4813,6 +4813,7 @@ TEST(Parser_TypeOfValue)
std::string bin_data("String2Binary");
table->get_object(15).set(col_any, Mixed());
table->get_object(17).set_collection(col_any, CollectionType::Dictionary);
table->get_object(19).set<Mixed>(col_any, table->begin()->get_link());
table->get_object(75).set(col_any, Mixed(75.));
table->get_object(28).set(col_any, Mixed(BinaryData(bin_data)));
nb_strings--;
Expand All @@ -4838,7 +4839,8 @@ TEST(Parser_TypeOfValue)
++it;
}
}
size_t nb_ints = 70;
size_t nb_ints = 69;
size_t nb_numerics = nb_ints + 3;
verify_query(test_context, table, "mixed.@type == 'string'", nb_strings);
verify_query(test_context, table, "mixed.@type == 'double'", 2);
verify_query(test_context, table, "mixed.@type == 'float'", 0);
Expand All @@ -4863,25 +4865,27 @@ TEST(Parser_TypeOfValue)
verify_query(test_context, table, "mixed.@type == 'timestamp'", 0);
verify_query(test_context, table, "mixed.@type == 'datetimeoffset'", 0);
verify_query(test_context, table, "mixed.@type == 'object'", 1);
verify_query(test_context, table, "mixed.@type == 'objectlink'", 1);

verify_query(test_context, table,
"mixed.@type == 'binary' || mixed.@type == 'DECIMAL' || mixed.@type == 'Double'", 4);
verify_query(test_context, table, "mixed.@type == 'null'", 1);
verify_query(test_context, table, "mixed.@type == 'numeric'", table->size() - nb_strings - 2);
verify_query(
test_context, table,
"mixed.@type == 'numeric' || mixed.@type == 'string' || mixed.@type == 'binary' || mixed.@type == 'null'",
table->size());
verify_query(test_context, table, "mixed.@type == 'numeric'", nb_numerics);
verify_query(test_context, table,
"mixed.@type == 'numeric' || mixed.@type == 'string' || mixed.@type == 'objectlink' || mixed.@type "
"== 'binary' || mixed.@type == "
"'object' || mixed.@type == 'null'",
table->size());
verify_query(test_context, table, "mixed.@type == mixed.@type", table->size());
verify_query(test_context, origin, "link.mixed.@type == 'numeric' || link.mixed.@type == 'string'",
origin->size());
verify_query(test_context, origin, "links.mixed.@type == 'numeric' || links.mixed.@type == 'string'",
origin->size());
verify_query(test_context, origin, "ANY links.mixed.@type IN ANY {'numeric', 'string'}", origin->size());

verify_query(test_context, table, "mixed.@type == int.@type", table->size() - nb_strings - 5);
verify_query(test_context, table, "mixed.@type == int.@type", nb_ints);
verify_query(test_context, origin, "link.@type == link.mixed.@type", 0);
verify_query(test_context, origin, "links.@type == links.mixed.@type", 0);
verify_query(test_context, origin, "links.@type == links.mixed.@type", 1); // Object 19

verify_query(test_context, table, "mixed > 50", int_over_50);
verify_query(test_context, table, "mixed > 50 && mixed.@type == 'double'", 1);
Expand Down Expand Up @@ -4935,10 +4939,11 @@ TEST(Parser_TypeOfValue)
CHECK_THROW_EX(verify_query(test_context, table, "int.@type == 'int'", 1), query_parser::InvalidQueryError,
std::string(e.what()).find("Comparison between two constants is not supported") !=
std::string::npos);
CHECK_THROW_EX(verify_query(test_context, origin, "link.@type == 'object'", 1), query_parser::InvalidQueryError,
CHECK(std::string(e.what()).find(
"Comparison between two constants is not supported ('\"object\"' and '\"object\"')") !=
std::string::npos));
CHECK_THROW_EX(
verify_query(test_context, origin, "link.@type == 'objectlink'", 1), query_parser::InvalidQueryError,
CHECK(std::string(e.what()).find(
"Comparison between two constants is not supported ('\"objectlink\"' and '\"objectlink\"')") !=
std::string::npos));
CHECK_THROW_EX(verify_query(test_context, table, "mixed.@type =[c] 'string'", 1), query_parser::InvalidQueryError,
CHECK_EQUAL(std::string(e.what()), "Unsupported comparison operator '=[c]' against type '@type', "
"right side must be a string or binary type"));
Expand Down

0 comments on commit 333d5af

Please sign in to comment.