[core] Implement has/!has filters (#4952)

This commit is contained in:
John Firebaugh
2016-05-05 14:30:37 -07:00
parent a66901ed07
commit 59a7fbf8e4
4 changed files with 67 additions and 2 deletions

View File

@@ -114,3 +114,25 @@ TEST(Filter, None) {
ASSERT_FALSE(evaluate(parse("[\"none\", [\"==\", \"foo\", 0], [\"==\", \"foo\", 1]]"),
{{ std::string("foo"), int64_t(1) }}));
}
TEST(Filter, Has) {
ASSERT_TRUE(evaluate(parse("[\"has\", \"foo\"]"),
{{ std::string("foo"), int64_t(1) }}));
ASSERT_TRUE(evaluate(parse("[\"has\", \"foo\"]"),
{{ std::string("foo"), int64_t(0) }}));
ASSERT_TRUE(evaluate(parse("[\"has\", \"foo\"]"),
{{ std::string("foo"), false }}));
ASSERT_FALSE(evaluate(parse("[\"has\", \"foo\"]"),
{{}}));
}
TEST(Filter, NotHas) {
ASSERT_FALSE(evaluate(parse("[\"!has\", \"foo\"]"),
{{ std::string("foo"), int64_t(1) }}));
ASSERT_FALSE(evaluate(parse("[\"!has\", \"foo\"]"),
{{ std::string("foo"), int64_t(0) }}));
ASSERT_FALSE(evaluate(parse("[\"!has\", \"foo\"]"),
{{ std::string("foo"), false }}));
ASSERT_TRUE(evaluate(parse("[\"!has\", \"foo\"]"),
{{}}));
}