bool tests

This commit is contained in:
Ari Lazier 2015-11-17 17:17:54 -08:00
parent fdf1fbd12b
commit aeb1e7ecb3
2 changed files with 5 additions and 0 deletions

View File

@ -220,6 +220,9 @@ struct ValueGetter<bool, TableGetter> {
if (value.type == parser::Expression::Type::Argument) {
return args.bool_for_argument(std::stoi(value.s));
}
if (value.type != parser::Expression::Type::True && value.type != parser::Expression::Type::False) {
throw std::runtime_error("Attempting to compare bool property to a non-bool value");
}
return value.type == parser::Expression::Type::True;
}
};

View File

@ -74,6 +74,7 @@ static std::vector<std::string> valid_queries = {
"a==a OR a==a",
"and=='AND'&&'or'=='||'",
"and == or && ORE > GRAND",
"a=1AND NOTb=2",
};
static std::vector<std::string> invalid_queries = {
@ -124,6 +125,7 @@ static std::vector<std::string> invalid_queries = {
"a==a &| a==a",
"a==a && OR a==a",
"a==aORa==a",
"a=1ANDNOT b=2",
"truepredicate &&",
"truepredicate & truepredicate",