74 const TestCase& testCase,
const std::string& pipeName,
75 const std::string& textFile,
const std::string& traceFilePrefix )
const
80 for (
const auto& test: testCase.
tests)
82 std::string traceFile(traceFilePrefix+test.trace);
87 LTRACE <<
"TestCaseProcessor::evalTestCase load trace file" << traceFile;
92 LERROR <<
"Error: Unable to parse output file " << traceFile <<
":" << result.
description();
94 "Error: Unable to parse output file !", pipeName, test);
99 LTRACE <<
"TestCaseProcessor::evalTestCase test:" << test.left << test.op << test.right;
100 if (test.op==
"notexists")
107 else if (test.op==
"exists")
111 std::ostringstream oss;
112 oss <<
"element doesn't exist ! : " << test.left;
121 left.removeDuplicates();
123 right.removeDuplicates();
127 Q_FOREACH (QString element, left)
129 sleft.insert(element);
131 QSet<QString> sright;
132 Q_FOREACH (QString element, right)
134 sright.insert(element);
141 std::ostringstream oss;
142 oss <<
"equality check failed : " << left <<
" != " << right << std::endl;
143 oss <<
" left : " << test.left << std::endl;
144 oss <<
" right: " << test.right;
148 else if (left.size()==0)
150 std::ostringstream oss;
151 oss <<
"left and right member are empty !";
155 else if (test.op==
"!=")
159 std::ostringstream oss;
160 oss <<
"inequality check failed : " << left <<
" == " << right << std::endl;
161 oss <<
" left : " << test.left << std::endl;
162 oss <<
" right: " << test.right;
166 else if (test.op==
"contains")
168 Q_FOREACH(QString s, sright)
170 if (!sleft.contains(s))
172 std::ostringstream oss;
173 oss <<
"includes check failed : " << left <<
" not contains " << right << std::endl;
174 oss <<
" left : " << test.left << std::endl;
175 oss <<
" right: " << test.right;
180 else if (test.op==
"notcontains")
182 Q_FOREACH(QString s, sleft)
184 if (!sright.contains(s))
186 std::ostringstream oss;
187 oss <<
"not includes check failed : " << left <<
" contains " << right;
192 else if (test.op==
"distinct")
194 Q_FOREACH(QString l, sleft)
196 Q_FOREACH(QString r, sright)
200 std::ostringstream oss;
201 oss << l.toUtf8().data() <<
" is a common value of the two sets that should be disctinct !" << std::endl;
202 oss <<
" left : " << test.left << std::endl;
203 oss <<
" right: " << test.right;
209 else if (test.op==
"intersect")
211 Q_FOREACH(QString l, sleft)
213 Q_FOREACH(QString r, sright)
221 std::ostringstream oss;
222 oss <<
"intersect failed : no common value between " << left <<
" and " << right <<
" !" << std::endl;
223 oss <<
" left : " << test.left << std::endl;
224 oss <<
" right: " << test.right;
227 else if ((test.op!=
"exists") && (test.op!=
"notexists"))
237 const std::string& expr,
243 if (expr.substr(0,6)==
"XPATH#")
246 QString xpath = QString::fromUtf8(expr.substr(6).c_str());
247 LDEBUG <<
"TestCaseProcessor::evaluateExpression setQuery("<<xpath<<
");";
249 LDEBUG <<
"TestCaseProcessor::evaluateExpression nb nodes selected:" << xnodes.
size();
250 for (
const auto& node: xnodes)
254 LDEBUG <<
"TestCaseProcessor::evaluateExpression result is an attribute with value:" << node.
attribute().
value();
257 else if (node.node())
259 LDEBUG <<
"TestCaseProcessor::evaluateExpression result is a node with text:" << node.node().
text().
as_string();
260 results.push_back(QString::fromUtf8(node.node().
text().
as_string()));
263 LDEBUG <<
"TestCaseProcessor::evaluateExpression evaluates to " << results;
265 else if (expr.substr(0,4)==
"SET#")
268 while (start<expr.size())
270 size_t end=expr.find(
'#',start);
271 if (end==std::string::npos)
275 std::string val=expr.substr(start,end-start);
276 results.push_back(QString::fromUtf8(val.c_str()));
282 results.push_back(QString::fromUtf8(expr.c_str()));
const char_t * as_string(const char_t *def=PUGIXML_TEXT("")) const