summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-10-31 16:43:13 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-10-31 16:43:13 (GMT)
commit71e1b30a2dcb8eefae105a5562239e21f07768c7 (patch)
tree0c18610f809fecc06c89c1fa0e2c36e51498b7ba /test
parentcf67d5ccefd7092fdf5c2bc1284e74f4c3413c7b (diff)
downloaduscxml-71e1b30a2dcb8eefae105a5562239e21f07768c7.zip
uscxml-71e1b30a2dcb8eefae105a5562239e21f07768c7.tar.gz
uscxml-71e1b30a2dcb8eefae105a5562239e21f07768c7.tar.bz2
Moved Parser into DOMUtils and new node -> xpath function for debugging
Diffstat (limited to 'test')
-rw-r--r--test/src/test-arabica-xpath.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/src/test-arabica-xpath.cpp b/test/src/test-arabica-xpath.cpp
index fe457f4..ce389fa 100644
--- a/test/src/test-arabica-xpath.cpp
+++ b/test/src/test-arabica-xpath.cpp
@@ -5,6 +5,7 @@
#include <DOM/io/Stream.hpp>
#include <iostream>
#include <string>
+#include "uscxml/DOMUtils.h"
#define string_type std::string
#define string_adaptor Arabica::default_string_adaptor<std::string>
@@ -127,6 +128,23 @@ int main(int argc, char** argv) {
std::cout << numbers_ << std::endl;
std::cout << chapters_ << std::endl;
+ if (true) {
+ using namespace Arabica::XPath;
+ using namespace Arabica::DOM;
+ XPathValue<string_type, string_adaptor> result = parser.evaluate(SA::construct_from_utf8("//*"), document_);
+ for(int i = 0; i < result.asNodeSet().size(); i++) {
+ Node<string_type, string_adaptor> node = result.asNodeSet()[i];
+ std::string xpathExpr = uscxml::DOMUtils::xPathForNode(node);
+ if (xpathExpr.size()) {
+ XPathValue<string_type, string_adaptor> innerResult = parser.evaluate(xpathExpr, document_);
+ assert(innerResult.asNodeSet().size() > 0);
+ assert(innerResult.asNodeSet().size() == 1);
+ assert(innerResult.asNodeSet()[0] == node);
+ } else {
+ assert(node.getNodeType() != Node_base::ELEMENT_NODE);
+ }
+ }
+ }
if (false) {
using namespace Arabica::XPath;