From: Sebastian Harl Date: Fri, 27 Feb 2015 18:32:55 +0000 (+0100) Subject: parser_test: Add testcases covering operand type checks. X-Git-Tag: sysdb-0.8.0~159 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4800fc6648d30ecbe2586114545a041ecdf540af;p=sysdb.git parser_test: Add testcases covering operand type checks. --- diff --git a/t/unit/frontend/parser_test.c b/t/unit/frontend/parser_test.c index 43d10dd..4926f76 100644 --- a/t/unit/frontend/parser_test.c +++ b/t/unit/frontend/parser_test.c @@ -250,6 +250,24 @@ START_TEST(test_parse) { "LOOKUP hosts MATCHING " "backend = ['a','b']", -1, 1, SDB_CONNECTION_LOOKUP }, + /* valid operand types */ + { "LOOKUP hosts MATCHING " + "age * 1 > 0s", -1, 1, SDB_CONNECTION_LOOKUP }, + { "LOOKUP hosts MATCHING " + "age / 1 > 0s", -1, 1, SDB_CONNECTION_LOOKUP }, + { "LOOKUP hosts MATCHING " + "name > ''", -1, 1, SDB_CONNECTION_LOOKUP }, + { "LOOKUP hosts MATCHING " + "name >= ''", -1, 1, SDB_CONNECTION_LOOKUP }, + { "LOOKUP hosts MATCHING " + "name != ''", -1, 1, SDB_CONNECTION_LOOKUP }, + { "LOOKUP hosts MATCHING " + "name = ''", -1, 1, SDB_CONNECTION_LOOKUP }, + { "LOOKUP hosts MATCHING " + "name <= ''", -1, 1, SDB_CONNECTION_LOOKUP }, + { "LOOKUP hosts MATCHING " + "name < ''", -1, 1, SDB_CONNECTION_LOOKUP }, + /* NULL */ { "LOOKUP hosts MATCHING " "attribute['foo'] " @@ -290,6 +308,37 @@ START_TEST(test_parse) { "LOOKUP hosts MATCHING " "attr['foo'] IS NULL", -1, -1, 0 }, + /* type mismatches */ + { "LOOKUP hosts MATCHING " + "age > 0", -1, -1, 0 }, + { "LOOKUP hosts MATCHING " + "age >= 0", -1, -1, 0 }, + { "LOOKUP hosts MATCHING " + "age = 0", -1, -1, 0 }, + { "LOOKUP hosts MATCHING " + "age != 0", -1, -1, 0 }, + { "LOOKUP hosts MATCHING " + "age <= 0", -1, -1, 0 }, + { "LOOKUP hosts MATCHING " + "age < 0", -1, -1, 0 }, + { "LOOKUP hosts MATCHING " + "age + 1 > 0s", -1, -1, 0 }, + { "LOOKUP hosts MATCHING " + "age - 1 > 0s", -1, -1, 0 }, + /* datetime integer is allowed */ + { "LOOKUP hosts MATCHING " + "age || 1 > 0s", -1, -1, 0 }, + { "LOOKUP hosts MATCHING " + "name + 1 = ''", -1, -1, 0 }, + { "LOOKUP hosts MATCHING " + "name - 1 = ''", -1, -1, 0 }, + { "LOOKUP hosts MATCHING " + "name * 1 = ''", -1, -1, 0 }, + { "LOOKUP hosts MATCHING " + "name / 1 = ''", -1, -1, 0 }, + { "LOOKUP hosts MATCHING " + "name % 1 = ''", -1, -1, 0 }, + /* comments */ { "/* some comment */", -1, 0, 0 }, { "-- another comment", -1, 0, 0 },