73#include <boost/core/ignore_unused.hpp>
74#include <boost/lexical_cast.hpp>
89 TiXmlElement *regex = metric->FirstChildElement(
"regex");
93 const char *tmp = regex->GetText();
94 ASSERTL0(tmp,
"No text found in regex tag");
107 TiXmlElement *matches = metric->FirstChildElement(
"matches");
111 for (TiXmlElement *match = matches->FirstChildElement(
"match"); match;
112 match = match->NextSiblingElement(
"match"))
115 m_matches.push_back(std::vector<std::string>());
118 for (TiXmlElement *
field = match->FirstChildElement(
"field");
field;
122 const char *tmp =
field->GetText();
124 ASSERTL0(tmp,
"No text that specifies regex group "
125 "found in field tag");
132 "No match tag that specifies "
133 "regex groups was found inside matches tag.");
141 size_min = std::min((
int)match.size(), size_min);
142 size_max = std::max((
int)match.size(), size_max);
144 ASSERTL0(size_min != 0,
"No valid field tags found "
145 "for one of the match tags");
146 ASSERTL0(size_min == size_max,
"Number of valid field tags "
147 "not the same for all match tags");
157 boost::ignore_unused(pStdout, pStderr);
160 for (std::string line; getline(pStdout, line) || getline(pStderr, line);)
177 bool all_match =
false;
179 i < matches.size() && matches.size() == match.size() + 1;
183 std::string submatch(matches[i].first, matches[i].second);
186 if (submatch == match[i - 1])
219 boost::ignore_unused(pStderr);
222 for (std::string line; getline(pStdout, line) || getline(pStderr, line);)
230 if (matches.size() == 1)
236 m_matches.push_back(std::vector<std::string>());
239 for (
int i = 1; i < matches.size(); ++i)
242 std::string submatch(matches[i].first, matches[i].second);
250 TiXmlElement *matches =
m_metric->FirstChildElement(
"matches");
258 matches =
new TiXmlElement(
"matches");
264 TiXmlElement *match =
new TiXmlElement(
"match");
265 matches->LinkEndChild(match);
268 for (
const auto &field_it : match_it)
270 TiXmlElement *
field =
new TiXmlElement(
"field");
271 match->LinkEndChild(
field);
273 field->SetAttribute(
"id", boost::lexical_cast<std::string>(j++));
275 field->LinkEndChild(
new TiXmlText(field_it));
#define ASSERTL0(condition, msg)
std::string RegisterCreatorFunction(std::string key, CreatorFunction func)
Base class for all metrics. Metric represents a test metric that can be used to evaluate the function...
TiXmlElement * m_metric
Pointer to XML structure containing metric definition.
bool m_generate
Determines whether to generate this metric or not.
std::vector< std::vector< std::string > > m_matches
static MetricSharedPtr create(TiXmlElement *metric, bool generate)
MetricNoWarning(TiXmlElement *metric, bool generate)
Constructor.
bool v_Test(std::istream &pStdout, std::istream &pStderr) override
Test if the output contains the warning message. If so, the test fails, otherwise,...
void v_Generate(std::istream &pStdout, std::istream &pStderr) override
Test if the output contains the warning message. If so, generate the .tst file.
std::regex m_regexWarning
MetricFactory & GetMetricFactory()