implement test for failing grammar in sql_grammar_test.cpp
This commit is contained in:
parent
5041dccf70
commit
043e34b70c
|
@ -37,3 +37,10 @@ PREPARE prep2 { INSERT INTO test VALUES (?, 0, 0); INSERT INTO test VALUES (0, ?
|
||||||
EXECUTE prep_inst(1, 2, 3);
|
EXECUTE prep_inst(1, 2, 3);
|
||||||
EXECUTE prep;
|
EXECUTE prep;
|
||||||
DEALLOCATE PREPARE prep;
|
DEALLOCATE PREPARE prep;
|
||||||
|
# Error expeced
|
||||||
|
!
|
||||||
|
!1
|
||||||
|
!gibberish;
|
||||||
|
!SELECT abc;
|
||||||
|
!CREATE TABLE "table" FROM TBL FILE 'students.tbl';SELECT 1
|
||||||
|
!CREATE TABLE "table" FROM TBL FILE 'students.tbl';1
|
|
@ -36,14 +36,14 @@ int main(int argc, char *argv[]) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool expectFalse = false;
|
bool globalExpectFalse = false;
|
||||||
bool useFile = false;
|
bool useFile = false;
|
||||||
std::string filePath = "";
|
std::string filePath = "";
|
||||||
|
|
||||||
// Parse command line arguments
|
// Parse command line arguments
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (; i < argc; ++i) {
|
for (; i < argc; ++i) {
|
||||||
if (STREQ(argv[i], "--false")) expectFalse = true;
|
if (STREQ(argv[i], "--false")) globalExpectFalse = true;
|
||||||
else if (STREQ(argv[i], "-f")) {
|
else if (STREQ(argv[i], "-f")) {
|
||||||
useFile = true;
|
useFile = true;
|
||||||
filePath = argv[++i];
|
filePath = argv[++i];
|
||||||
|
@ -65,6 +65,12 @@ int main(int argc, char *argv[]) {
|
||||||
// Execute queries
|
// Execute queries
|
||||||
int numFailed = 0;
|
int numFailed = 0;
|
||||||
for (std::string sql : queries) {
|
for (std::string sql : queries) {
|
||||||
|
bool expectFalse = globalExpectFalse;
|
||||||
|
if (sql.at(0) == '!') {
|
||||||
|
expectFalse = !expectFalse;
|
||||||
|
sql = sql.substr(1);
|
||||||
|
}
|
||||||
|
|
||||||
// Measuring the parsing time
|
// Measuring the parsing time
|
||||||
std::chrono::time_point<std::chrono::system_clock> start, end;
|
std::chrono::time_point<std::chrono::system_clock> start, end;
|
||||||
start = std::chrono::system_clock::now();
|
start = std::chrono::system_clock::now();
|
||||||
|
|
Loading…
Reference in New Issue