diff options
-rw-r--r-- | src/pugixml.cpp | 2 | ||||
-rw-r--r-- | src/pugixpath.cpp | 4 | ||||
-rw-r--r-- | tests/test_dom_traverse.cpp | 7 |
3 files changed, 9 insertions, 4 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp index c84ad2a..0b50fe7 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -134,7 +134,7 @@ namespace pugi if (lhs[i] != rhs[i])
return false;
- return true;
+ return lhs[count] == 0;
}
// Character set pattern match.
diff --git a/src/pugixpath.cpp b/src/pugixpath.cpp index f5663bd..6239ed2 100644 --- a/src/pugixpath.cpp +++ b/src/pugixpath.cpp @@ -940,9 +940,7 @@ namespace pugi {
size_t length = static_cast<size_t>(end - begin);
- if (!impl::strequalrange(other, begin, length)) return false;
-
- return other[length] == 0;
+ return impl::strequalrange(other, begin, length);
}
};
diff --git a/tests/test_dom_traverse.cpp b/tests/test_dom_traverse.cpp index 2e6b5e3..896bf6f 100644 --- a/tests/test_dom_traverse.cpp +++ b/tests/test_dom_traverse.cpp @@ -596,6 +596,13 @@ TEST_XML(dom_node_first_element_by_path, "<node><child1>text<child2/></child1></ CHECK(doc.child(STR("node")).first_element_by_path(STR("..")) == doc);
CHECK(doc.child(STR("node")).first_element_by_path(STR(".")) == doc.child(STR("node")));
+
+ CHECK(doc.child(STR("node")).first_element_by_path(STR("../node/./child1/../.")) == doc.child(STR("node")));
+
+ CHECK(doc.child(STR("node")).first_element_by_path(STR("child1")) == doc.child(STR("node")).child(STR("child1")));
+ CHECK(doc.child(STR("node")).first_element_by_path(STR("child1/")) == doc.child(STR("node")).child(STR("child1")));
+ CHECK(doc.child(STR("node")).first_element_by_path(STR("child")) == xml_node());
+ CHECK(doc.child(STR("node")).first_element_by_path(STR("child11")) == xml_node());
}
struct test_walker: xml_tree_walker
|