MXS-1196: Allow delimiters to be multi-character

In some new test files, the delimiter is 2 characters.
This commit is contained in:
Johan Wikman
2017-05-03 15:46:02 +03:00
parent 53dfa818e3
commit 8a0455c2fe
2 changed files with 11 additions and 6 deletions

View File

@ -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)

View File

@ -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. */
};
};