From 8a0455c2fe626c6480d2cc7841c38b886b56ddfc Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Wed, 3 May 2017 15:46:02 +0300 Subject: [PATCH] MXS-1196: Allow delimiters to be multi-character In some new test files, the delimiter is 2 characters. --- query_classifier/test/testreader.cc | 15 ++++++++++----- query_classifier/test/testreader.hh | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/query_classifier/test/testreader.cc b/query_classifier/test/testreader.cc index b7aadc057..49fba60a7 100644 --- a/query_classifier/test/testreader.cc +++ b/query_classifier/test/testreader.cc @@ -193,7 +193,7 @@ TestReader::TestReader(istream& in, size_t line) : m_in(in) , m_line(line) - , m_delimiter(';') + , m_delimiter(";") { init(); } @@ -244,7 +244,7 @@ TestReader::result_t TestReader::get_statement(std::string& stmt) trim(line); if (line.length() > 0) { - m_delimiter = line.at(0); + m_delimiter = line; } continue; @@ -268,15 +268,20 @@ TestReader::result_t TestReader::get_statement(std::string& stmt) stmt += line; - char c = line.at(line.length() - 1); + string c; + + if (line.length() >= m_delimiter.length()) + { + c = line.substr(line.length() - m_delimiter.length()); + } if (c == m_delimiter) { - if (c != ';') + if (c != ";") { // If the delimiter was something else but ';' we need to // remove that before giving the line to the classifiers. - stmt.erase(stmt.length() - 1); + stmt.erase(stmt.length() - m_delimiter.length()); } if (!skip) diff --git a/query_classifier/test/testreader.hh b/query_classifier/test/testreader.hh index 68b930a5c..224f92260 100644 --- a/query_classifier/test/testreader.hh +++ b/query_classifier/test/testreader.hh @@ -76,7 +76,7 @@ private: private: std::istream& m_in; /*< The stream we are using. */ size_t m_line; /*< The current line. */ - char m_delimiter; /*< The current delimiter. */ + std::string m_delimiter; /*< The current delimiter. */ }; };