48 const QString & namespaceURI,
const QString & localname,
const QString & qname,
const QXmlAttributes & attrs)
52 std::string name=getName(localname,qname);
56 LDEBUG <<
"TestCasesHandler::startElement: new testcase ";
58 currentTestCase.id=attributeValue(
"id", attrs);
59 std::string typech=attributeValue(
"type", attrs);
60 currentTestCase.type=(typech.empty()?
"undefined":typech);
61 LDEBUG <<
"TestCasesHandler::startElement: id=" << currentTestCase.id
62 <<
", type=" << currentTestCase.type;
63 }
else if (name==
"text") {
65 LDEBUG <<
"TestCasesHandler::startElement: start text ";
67 }
else if (name==
"expl") {
68 LDEBUG <<
"TestCasesHandler::startElement: start expl ";
70 }
else if (name==
"call-parameters") {
72 LDEBUG <<
"TestCasesHandler::startElement: start call-parameters ";
73 }
else if (name==
"list") {
74 LDEBUG <<
"TestCasesHandler::startElement: start list ";
75 m_listKey = attributeValue(
"key", attrs);
76 MultiValCallParams::iterator pos = currentTestCase.multiValCallParams.find(m_listKey);
77 if( pos == currentTestCase.multiValCallParams.end() ) {
79 std::pair<std::string,std::list<std::string> > newElem(m_listKey,std::list<std::string>() );
83 currentTestCase.multiValCallParams.insert(newElem);
86 }
else if (name==
"map") {
87 LDEBUG <<
"TestCasesHandler::startElement: start map ";
88 m_mapKey = attributeValue(
"key",attrs);
89 MapValCallParams::iterator pos = currentTestCase.mapValCallParams.find(m_mapKey);
90 if( pos == currentTestCase.mapValCallParams.end() ) {
92 std::pair<std::string,std::map<std::string,std::string> > newElem(m_mapKey,std::map<std::string,std::string>() );
96 currentTestCase.mapValCallParams.insert(newElem);
99 }
else if (name==
"item") {
100 LDEBUG <<
"TestCasesHandler::startElement: start item ";
101 if( m_inList ==
true ) {
102 MultiValCallParams::iterator pos = currentTestCase.multiValCallParams.find(m_listKey);
103 if( pos != currentTestCase.multiValCallParams.end() ) {
104 std::string val = attributeValue(
"value", attrs);
105 (*pos).second.push_back(val);
108 LERROR <<
"!! TestCasesHandler::startElement: no list for param " << m_listKey;
111 else if (m_inMap ==
true) {
112 MapValCallParams::iterator pos = currentTestCase.mapValCallParams.find(m_mapKey);
113 if( pos != currentTestCase.mapValCallParams.end() ) {
114 std::string attr = attributeValue(
"key", attrs);
115 std::string val = attributeValue(
"value",attrs);
116 (*pos).second.insert(make_pair(attr,val));
119 LERROR <<
"!! TestCasesHandler::startElement: no list for param " << m_listKey;
123 }
else if (name==
"param") {
124 LDEBUG <<
"TestCasesHandler::startElement: start param ";
125 std::string key = attributeValue(
"key",attrs);
126 std::string val = attributeValue(
"value", attrs);
127 currentTestCase.simpleValCallParams.insert(std::pair<std::string, std::string>(key,val) );
130 }
else if (name==
"test") {
134 tu.
id=attributeValue(
"id", attrs);
135 tu.
trace=attributeValue(
"trace", attrs);
136 tu.
comment=attributeValue(
"comment", attrs);
137 tu.
left=attributeValue(
"left", attrs);
138 tu.
op=attributeValue(
"operator", attrs);
139 tu.
right=attributeValue(
"right",attrs);
140 tu.
conditional=(attributeValue(
"conditional",attrs)==
"yes");
141 currentTestCase.tests.push_back(tu);
142 LDEBUG <<
"TestCasesHandler::startElement: push testUnit"
144 <<
", trace =" << tu.
trace
146 <<
", left =" << tu.
left
148 <<
", right =" << tu.
right
158 currentTestCase.explanation.append(chars.toUtf8().data());
159 }
else if (m_inText) {
161 std::string newTextVal(chars.toUtf8().data());
163 SimpleValCallParams::iterator pos = currentTestCase.simpleValCallParams.find(
"text");
164 if( pos == currentTestCase.simpleValCallParams.end() ) {
166 currentTestCase.simpleValCallParams.insert(std::pair<std::string, std::string>(
"text",newTextVal) );
169 std::string& textVal = (*pos).second;
170 textVal.append(chars.toUtf8().data());
181 std::string name=getName(localname,qname);
182 if (name==
"testcase")
185 LDEBUG <<
"TestCasesHandler::endElement: call processTestCase(" << currentTestCase.id
186 <<
"," << currentTestCase.type <<
")";
187 TestCaseError e = m_processor.processTestCase(currentTestCase);
190 std::cout << currentTestCase.id <<
" (" << currentTestCase.type <<
") got error (type: '"<<e()<<
"'): "
191 << std::endl << e.
what() << std::endl;
193 m_hasFatalError =
true;
207 std::cout <<
"runtime error: " << e.
what() << std::endl;
209 throw std::runtime_error(e.
what());
214 std::cout << currentTestCase.id <<
" (" << currentTestCase.type <<
") passed successfully." << std::endl;;
217 }
else if (name==
"text") {
220 }
else if (name==
"expl") {
222 }
else if (name==
"call-parameters") {
224 }
else if (name==
"list") {
226 }
else if (name==
"map") {