Skip to content

Commit

Permalink
Update tests to match expected JSON output
Browse files Browse the repository at this point in the history
  • Loading branch information
lfittl committed Apr 26, 2024
1 parent f62101c commit 673c360
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions test/parse_opts_tests.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const char* tests[] = {
"SELECT 1",
"0",
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"A_Const\":{\"ival\":{\"ival\":1},\"location\":7}},\"location\":7}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"A_Const\":{\"ival\":1,\"location\":7}},\"location\":7}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
"integer",
"1",
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"List\":{\"items\":[{\"String\":{\"sval\":\"pg_catalog\"}},{\"String\":{\"sval\":\"int4\"}}]}}}]}",
Expand All @@ -10,19 +10,19 @@ const char* tests[] = {
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"List\":{\"items\":[{\"String\":{\"sval\":\"pg_catalog\"}},{\"String\":{\"sval\":\"varchar\"}}]}}}]}",
"EXISTS(SELECT 1)",
"2",
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"SubLink\":{\"subLinkType\":\"EXISTS_SUBLINK\",\"subselect\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"A_Const\":{\"ival\":{\"ival\":1},\"location\":14}},\"location\":14}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}}}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"SubLink\":{\"subLinkType\":\"EXISTS_SUBLINK\",\"subselect\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"A_Const\":{\"ival\":1,\"location\":14}},\"location\":14}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}}}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
"v_version IS NULL",
"2",
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"NullTest\":{\"arg\":{\"ColumnRef\":{\"fields\":[{\"String\":{\"sval\":\"v_version\"}}]}},\"nulltesttype\":\"IS_NULL\",\"location\":10}}}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
"pos:= instr($1, $2, 1)",
"3",
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"PLAssignStmt\":{\"name\":\"pos\",\"nnames\":1,\"val\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"FuncCall\":{\"funcname\":[{\"String\":{\"sval\":\"instr\"}}],\"args\":[{\"ParamRef\":{\"number\":1,\"location\":12}},{\"ParamRef\":{\"number\":2,\"location\":16}},{\"A_Const\":{\"ival\":{\"ival\":1},\"location\":20}}],\"funcformat\":\"COERCE_EXPLICIT_CALL\",\"location\":6}},\"location\":6}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}}]}",
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"PLAssignStmt\":{\"name\":\"pos\",\"nnames\":1,\"val\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"FuncCall\":{\"funcname\":[{\"String\":{\"sval\":\"instr\"}}],\"args\":[{\"ParamRef\":{\"number\":1,\"location\":12}},{\"ParamRef\":{\"number\":2,\"location\":16}},{\"A_Const\":{\"ival\":1,\"location\":20}}],\"funcformat\":\"COERCE_EXPLICIT_CALL\",\"location\":6}},\"location\":6}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}}]}",
"temp_str := substring(string FROM beg_index)",
"3",
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"PLAssignStmt\":{\"name\":\"temp_str\",\"nnames\":1,\"val\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"FuncCall\":{\"funcname\":[{\"String\":{\"sval\":\"pg_catalog\"}},{\"String\":{\"sval\":\"substring\"}}],\"args\":[{\"ColumnRef\":{\"fields\":[{\"String\":{\"sval\":\"string\"}}],\"location\":22}},{\"ColumnRef\":{\"fields\":[{\"String\":{\"sval\":\"beg_index\"}}],\"location\":34}}],\"funcformat\":\"COERCE_SQL_SYNTAX\",\"location\":12}},\"location\":12}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}}]}",
"v3.c1 := 4",
"4",
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"PLAssignStmt\":{\"name\":\"v3\",\"indirection\":[{\"String\":{\"sval\":\"c1\"}}],\"nnames\":2,\"val\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"A_Const\":{\"ival\":{\"ival\":4},\"location\":9}},\"location\":9}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}}]}",
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"PLAssignStmt\":{\"name\":\"v3\",\"indirection\":[{\"String\":{\"sval\":\"c1\"}}],\"nnames\":2,\"val\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"A_Const\":{\"ival\":4,\"location\":9}},\"location\":9}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}}]}",
"NEW.name = upper(cleanString(NEW.name))",
"4",
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"PLAssignStmt\":{\"name\":\"new\",\"indirection\":[{\"String\":{\"sval\":\"name\"}}],\"nnames\":2,\"val\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"FuncCall\":{\"funcname\":[{\"String\":{\"sval\":\"upper\"}}],\"args\":[{\"FuncCall\":{\"funcname\":[{\"String\":{\"sval\":\"cleanstring\"}}],\"args\":[{\"ColumnRef\":{\"fields\":[{\"String\":{\"sval\":\"new\"}},{\"String\":{\"sval\":\"name\"}}],\"location\":29}}],\"funcformat\":\"COERCE_EXPLICIT_CALL\",\"location\":17}}],\"funcformat\":\"COERCE_EXPLICIT_CALL\",\"location\":11}},\"location\":11}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}}]}",
Expand All @@ -31,10 +31,10 @@ const char* tests[] = {
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"PLAssignStmt\":{\"name\":\"new\",\"indirection\":[{\"String\":{\"sval\":\"author\"}},{\"String\":{\"sval\":\"first_name\"}}],\"nnames\":3,\"val\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"FuncCall\":{\"funcname\":[{\"String\":{\"sval\":\"upper\"}}],\"args\":[{\"FuncCall\":{\"funcname\":[{\"String\":{\"sval\":\"cleanstring\"}}],\"args\":[{\"ColumnRef\":{\"fields\":[{\"String\":{\"sval\":\"new\"}},{\"String\":{\"sval\":\"author\"}},{\"String\":{\"sval\":\"first_name\"}}],\"location\":42}}],\"funcformat\":\"COERCE_EXPLICIT_CALL\",\"location\":30}}],\"funcformat\":\"COERCE_EXPLICIT_CALL\",\"location\":24}},\"location\":24}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}}]}",
"SELECT '\\''",
"96",
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"A_Const\":{\"sval\":{\"sval\":\"'\"},\"location\":7}},\"location\":7}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"A_Const\":{\"sval\":\"'\",\"location\":7}},\"location\":7}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
"v3.c1 := '\\''",
"100",
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"PLAssignStmt\":{\"name\":\"v3\",\"indirection\":[{\"String\":{\"sval\":\"c1\"}}],\"nnames\":2,\"val\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"A_Const\":{\"sval\":{\"sval\":\"'\"},\"location\":9}},\"location\":9}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}}]}",
"{\"version\":160001,\"stmts\":[{\"stmt\":{\"PLAssignStmt\":{\"name\":\"v3\",\"indirection\":[{\"String\":{\"sval\":\"c1\"}}],\"nnames\":2,\"val\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"A_Const\":{\"sval\":\"'\",\"location\":9}},\"location\":9}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}}]}",
};

size_t testsLength = __LINE__ - 4;
Loading

0 comments on commit 673c360

Please sign in to comment.