update tpch tests to use new interface

This commit is contained in:
Pedro Flemming 2017-04-07 16:28:33 +02:00
parent cfe69a44de
commit d318ef0de4
1 changed files with 10 additions and 11 deletions

View File

@ -39,15 +39,15 @@ TEST(TPCHQueryGrammarTests) {
for (const std::string& file_path : files) { for (const std::string& file_path : files) {
std::string query = readFileContents(file_path); std::string query = readFileContents(file_path);
SQLParserResult* result = SQLParser::parseSQLString(query.c_str()); SQLParserResult result;
if (!result->isValid()) { SQLParser::parseSQLString(query.c_str(), &result);
if (!result.isValid()) {
mt::printFailed(file_path.c_str()); mt::printFailed(file_path.c_str());
printf("%s %s (L%d:%d)%s\n", mt::red(), result->errorMsg(), result->errorLine(), result->errorColumn(), mt::def()); printf("%s %s (L%d:%d)%s\n", mt::red(), result.errorMsg(), result.errorLine(), result.errorColumn(), mt::def());
++testsFailed; ++testsFailed;
} else { } else {
mt::printOk(file_path.c_str()); mt::printOk(file_path.c_str());
} }
delete result;
} }
ASSERT_EQ(testsFailed, 0); ASSERT_EQ(testsFailed, 0);
} }
@ -55,11 +55,12 @@ TEST(TPCHQueryGrammarTests) {
TEST(TPCHQueryDetailTest) { TEST(TPCHQueryDetailTest) {
std::string query = readFileContents("test/queries/tpc-h-16-22.sql"); std::string query = readFileContents("test/queries/tpc-h-16-22.sql");
SQLParserResult* result = SQLParser::parseSQLString(query.c_str()); SQLParserResult result;
ASSERT(result->isValid()); SQLParser::parseSQLString(query.c_str(), &result);
ASSERT_EQ(result->size(), 7); ASSERT(result.isValid());
ASSERT_EQ(result.size(), 7);
const SQLStatement* stmt20 = result->getStatement(4); const SQLStatement* stmt20 = result.getStatement(4);
ASSERT_EQ(stmt20->type(), kStmtSelect); ASSERT_EQ(stmt20->type(), kStmtSelect);
const SelectStatement* select20 = (const SelectStatement*) stmt20; const SelectStatement* select20 = (const SelectStatement*) stmt20;
@ -95,6 +96,4 @@ TEST(TPCHQueryDetailTest) {
ASSERT_EQ(select20->order->size(), 1); ASSERT_EQ(select20->order->size(), 1);
ASSERT(select20->order->at(0)->expr->isType(kExprColumnRef)); ASSERT(select20->order->at(0)->expr->isType(kExprColumnRef));
ASSERT_STREQ(select20->order->at(0)->expr->getName(), "S_NAME"); ASSERT_STREQ(select20->order->at(0)->expr->getName(), "S_NAME");
}
delete result;
}