From d318ef0de457cdf90cabd13b6bf600886ad0752c Mon Sep 17 00:00:00 2001 From: Pedro Flemming Date: Fri, 7 Apr 2017 16:28:33 +0200 Subject: [PATCH] update tpch tests to use new interface --- test/tpc_h_tests.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/test/tpc_h_tests.cpp b/test/tpc_h_tests.cpp index 288802a..310972d 100644 --- a/test/tpc_h_tests.cpp +++ b/test/tpc_h_tests.cpp @@ -39,15 +39,15 @@ TEST(TPCHQueryGrammarTests) { for (const std::string& file_path : files) { std::string query = readFileContents(file_path); - SQLParserResult* result = SQLParser::parseSQLString(query.c_str()); - if (!result->isValid()) { + SQLParserResult result; + SQLParser::parseSQLString(query.c_str(), &result); + 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()); + 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()); } - delete result; } ASSERT_EQ(testsFailed, 0); } @@ -55,11 +55,12 @@ TEST(TPCHQueryGrammarTests) { TEST(TPCHQueryDetailTest) { std::string query = readFileContents("test/queries/tpc-h-16-22.sql"); - SQLParserResult* result = SQLParser::parseSQLString(query.c_str()); - ASSERT(result->isValid()); - ASSERT_EQ(result->size(), 7); + SQLParserResult result; + SQLParser::parseSQLString(query.c_str(), &result); + 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); const SelectStatement* select20 = (const SelectStatement*) stmt20; @@ -95,6 +96,4 @@ TEST(TPCHQueryDetailTest) { ASSERT_EQ(select20->order->size(), 1); ASSERT(select20->order->at(0)->expr->isType(kExprColumnRef)); ASSERT_STREQ(select20->order->at(0)->expr->getName(), "S_NAME"); - - delete result; -} \ No newline at end of file +}