2017-03-07 02:01:00 +01:00
|
|
|
#include "thirdparty/microtest/microtest.h"
|
|
|
|
#include "sql_asserts.h"
|
|
|
|
#include "SQLParser.h"
|
|
|
|
#include "sqlhelper.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <fstream>
|
|
|
|
#include <streambuf>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using namespace hsql;
|
|
|
|
|
2017-03-07 15:30:54 +01:00
|
|
|
TEST(TPCHQueryGrammarTests) {
|
2017-03-07 02:01:00 +01:00
|
|
|
std::vector<std::string> files = {
|
|
|
|
"test/queries/tpc-h-01.sql",
|
|
|
|
"test/queries/tpc-h-02.sql",
|
|
|
|
"test/queries/tpc-h-03.sql",
|
|
|
|
"test/queries/tpc-h-04.sql",
|
|
|
|
"test/queries/tpc-h-05.sql",
|
|
|
|
"test/queries/tpc-h-06.sql",
|
|
|
|
"test/queries/tpc-h-07.sql",
|
|
|
|
"test/queries/tpc-h-08.sql",
|
|
|
|
"test/queries/tpc-h-09.sql",
|
2017-03-07 15:30:54 +01:00
|
|
|
"test/queries/tpc-h-10.sql",
|
|
|
|
"test/queries/tpc-h-11-15.sql",
|
|
|
|
"test/queries/tpc-h-16-22.sql"
|
2017-03-07 02:01:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
int testsFailed = 0;
|
|
|
|
for (const std::string& file_path : files) {
|
|
|
|
std::ifstream t(file_path.c_str());
|
|
|
|
std::string query((std::istreambuf_iterator<char>(t)),
|
2017-03-07 13:49:56 +01:00
|
|
|
std::istreambuf_iterator<char>());
|
|
|
|
|
2017-03-07 02:01:00 +01:00
|
|
|
SQLParserResult* result = SQLParser::parseSQLString(query.c_str());
|
|
|
|
if (!result->isValid()) {
|
|
|
|
mt::printFailed(file_path.c_str());
|
|
|
|
printf("%s %s (L%d:%d)%s\n", mt::red(), result->errorMsg(), result->errorLine(), result->errorColumn(), mt::def());
|
|
|
|
++testsFailed;
|
|
|
|
} else {
|
|
|
|
mt::printOk(file_path.c_str());
|
|
|
|
}
|
2017-03-07 15:09:39 +01:00
|
|
|
delete result;
|
2017-03-07 02:01:00 +01:00
|
|
|
}
|
|
|
|
ASSERT_EQ(testsFailed, 0);
|
|
|
|
}
|