3#include <knowCore/IOFormat.h>
4#include <knowCore/Logging.h>
5#include <knowDBC/Result.h>
6#include <knowRDF/BlankNode.h>
7#include <knowRDF/Graph.h>
8#include <knowRDF/Literal.h>
9#include <knowRDF/Node.h>
10#include <knowCore/Uris/xsd.h>
18 _debug <<
"<" << _value.
datatype() <<
">(";
19 auto const& [s, v, m] = _value.printable();
24 _debug <<
"err: " << m;
31 auto const& [s, v, m] = _v1.
compare(_v2, knowCore::ComparisonOperator::AlmostEqual);
37 QDebug warn = qWarning().nospace();
38 warn << IOFormat::bold <<
"Fields: " << IOFormat::reset;
39 for(
int j = 0; j < r.fields(); ++j)
46 for(
int j = 0; j < r.tuples(); ++j)
48 QDebug warn = qWarning().nospace();
49 warn << IOFormat::bold << j <<
"th: " << IOFormat::reset;
50 for(
int k = 0; k < r.fields(); ++k)
52 details::print(warn, r.value(j, k)) <<
" ";
58 qWarning().nospace() << IOFormat::blue <<
"Possible reference values were" << IOFormat::reset;
61 qWarning().nospace() << IOFormat::red <<
"Tested values were" << IOFormat::reset;
67 QVector<bool> indexes(r2.tuples(),
false);
68 for(
int i = 0; i < r1.tuples(); ++i)
70 bool found_one =
false;
71 for(
int j = 0; j < r2.tuples(); ++j)
75 bool equal_tuple =
true;
76 for(
int k = 0; k < r1.fields(); ++k)
97 QDebug warn = qWarning().nospace();
98 warn << IOFormat::red <<
"Error: No match for " << i <<
"th tuple: " << IOFormat::reset;
99 for(
int k = 0; k < r1.fields(); ++k)
101 details::print(warn, r1.value(i, k)) <<
" ";
112 inline void print_one(QDebug& warn,
const knowRDF::Node* node)
116 case knowRDF::Node::Type::Undefined:
119 case knowRDF::Node::Type::Uri:
122 case knowRDF::Node::Type::BlankNode:
125 case knowRDF::Node::Type::Literal:
128 case knowRDF::Node::Type::Variable:
135 QMultiHash<knowCore::Uri, const knowRDF::Node*> children = node->
children();
137 print_one(warn, node);
139 for(QMultiHash<knowCore::Uri, const knowRDF::Node*>::const_iterator it = children.begin(); it != children.end(); ++it)
141 warn <<
"(" << it.key() <<
", ";
142 print_one(warn, it.value());
151 switch(node1->
type())
153 case knowRDF::Node::Type::Undefined:
155 case knowRDF::Node::Type::Uri:
156 return node1->
uri() == node2->
uri();
157 case knowRDF::Node::Type::BlankNode:
159 case knowRDF::Node::Type::Literal:
161 case knowRDF::Node::Type::Variable:
162 KNOWCORE_LOG_FATAL(
"Impossible");
170 for(QMultiHash<knowCore::Uri, const knowRDF::Node*>::const_iterator it = _hash.begin(); it != _hash.end(); ++it)
172 r.append(QPair<knowCore::Uri, const knowRDF::Node*>(it.key(), it.value()));
182 QVector<bool> indexes(nodes_2.size(),
false);
184 for(
int i = 0; i < nodes_1.size(); ++i)
186 bool found_one =
false;
188 for(
int j = 0; j < nodes_2.size(); ++j)
193 if(details::similar(node1, node2) and node1->
children().size() == node2->
children().size())
197 QVector<bool> indexes_children(children2.size(),
false);
199 bool all_children_found =
true;
201 for(
int k = 0; k < children1.size(); ++k)
203 bool found_one_child =
false;
204 QPair<knowCore::Uri, const knowRDF::Node*> c1 = children1[k];
205 for(
int l = 0; l < children2.size(); ++l)
207 if(not indexes_children[l])
209 QPair<knowCore::Uri, const knowRDF::Node*> c2 = children2[l];
210 if(c1.first == c2.first and details::similar(c1.second, c2.second))
212 found_one_child =
true;
213 indexes_children[l] =
true;
218 if(not found_one_child)
220 all_children_found =
false;
224 if(all_children_found)
236 QDebug warn = qWarning().nospace();
237 warn << IOFormat::red <<
"Error: No match for " << i <<
"th node: ";
238 details::print(warn, node1);
239 warn << IOFormat::reset;
241 qWarning().nospace() << IOFormat::blue <<
"Possible reference values were" << IOFormat::reset;
242 for(
int j = 0; j < nodes_2.size(); ++j)
244 QDebug warn = qWarning().nospace();
245 warn << IOFormat::bold << j <<
"th: ";
246 details::print(warn, nodes_2[j]);
247 warn << IOFormat::reset;
249 qWarning().nospace() << IOFormat::red <<
"Tested values were" << IOFormat::reset;
250 for(
int j = 0; j < nodes_1.size(); ++j)
252 QDebug warn = qWarning().nospace();
253 warn << IOFormat::bold << j <<
"th: ";
254 details::print(warn, nodes_1[j]);
255 warn << IOFormat::reset;
263 if(nodes_1.size() != nodes_2.size())
265 qWarning().nospace() << IOFormat::red <<
"Different test results got: " << nodes_1.size() <<
" expecting: " << nodes_2.size() << IOFormat::reset;
Uri datatype() const
Definition Value.cpp:230
cres_qresult< bool > compare(const Value &_value, ComparisonOperators _operators) const
Definition Value.cpp:316
int fieldIndex(const QString &_name) const
Definition Result.cpp:77
QString fieldName(int _index) const
Definition Result.h:65
knowCore::Uri uri() const
Definition Node.cpp:121
QString variable() const
Definition Node.cpp:119
Literal literal() const
Definition Node.cpp:123
QMultiHash< knowCore::Uri, const Node * > children() const
Definition Node.cpp:157
BlankNode blankNode() const
Definition Node.cpp:117
Type type() const
Definition Node.cpp:125