msxml3/tests: Add additional conformance tests to the xpath tests (try 2)

John Chadwick johnwchadwick at gmail.com
Wed Jul 3 04:11:13 CDT 2013


This patch adds additional xpath tests to the msxml3 tests. Following
Nikolay Sivov's advice, these provide a wide range of new tests, two
of which currently fail in Wine (for reasons previously described.)
These are now marked 'todo' in a much cleaner way.
-------------- next part --------------
From 9caf8732b53d9a930ebc93b89a7d8da6a41ea4f5 Mon Sep 17 00:00:00 2001
From: John Chadwick <johnwchadwick at gmail.com>
Date: Wed, 3 Jul 2013 05:05:13 -0400
Subject: msxml3/tests: Add additional conformance tests to the xpath tests.

---
 dlls/msxml3/tests/domdoc.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c
index 20b9609..517af71 100644
--- a/dlls/msxml3/tests/domdoc.c
+++ b/dlls/msxml3/tests/domdoc.c
@@ -4361,9 +4361,54 @@ static const selection_ns_t selection_ns_data[] = {
     { NULL }
 };
 
+typedef struct {
+    const char *query;
+    const char *list;
+    BOOL todo;
+} xpath_test_t;
+
+static const xpath_test_t xpath_test[] = {
+    { "*/a", "E1.E1.E2.D1 E1.E2.E2.D1 E1.E4.E2.D1" },
+    { "*/b", "E2.E1.E2.D1 E2.E2.E2.D1 E2.E4.E2.D1" },
+    { "*/c", "E3.E1.E2.D1 E3.E2.E2.D1" },
+    { "*/d", "E4.E1.E2.D1 E4.E2.E2.D1 E4.E4.E2.D1" },
+    { "//a", "E1.E1.E2.D1 E1.E2.E2.D1 E1.E4.E2.D1" },
+    { "//b", "E2.E1.E2.D1 E2.E2.E2.D1 E2.E4.E2.D1" },
+    { "//c", "E3.E1.E2.D1 E3.E2.E2.D1" },
+    { "//d", "E4.E1.E2.D1 E4.E2.E2.D1 E4.E4.E2.D1" },
+    { "//c[@type]", "E3.E2.E2.D1" },
+    { "//c[@type]/ancestor::node()[1]", "E2.E2.D1" },
+    { "//c[@type]/ancestor-or-self::node()[1]", "E3.E2.E2.D1" },
+    { "//c[@type]/attribute::node()[1]", "A'type'.E3.E2.E2.D1" },
+    { "//c[@type]/child::node()[1]", "T1.E3.E2.E2.D1"  },
+    { "//c[@type]/descendant::node()[1]", "T1.E3.E2.E2.D1" },
+    { "//c[@type]/descendant-or-self::node()[1]", "E3.E2.E2.D1" },
+    { "//c[@type]/following::node()[1]", "E4.E2.E2.D1" },
+    { "//c[@type]/following-sibling::node()[1]", "E4.E2.E2.D1" },
+    { "//c[@type]/parent::node()[1]", "E2.E2.D1" },
+    { "//c[@type]/preceding::node()[1]", "T1.E2.E2.E2.D1" },
+    { "//c[@type]/self::node()[1]", "E3.E2.E2.D1" },
+    { "child::*", "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1" },
+    { "child::node()", "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1" },
+    { "child::text()", "" },
+    { "child::*/..", "E2.D1" },
+    { "child::*//@*/..", "E2.E5.E1.E2.D1 E3.E2.E2.D1" },
+    { "self::node()", "E2.D1" },
+    { "ancestor::node()", "D1" },
+    { "elem[c][last()]/a", "E1.E2.E2.D1"},
+    /* FIXME: selectNodes returns DOMNodeList, should be in document order. */
+    { "ancestor-or-self::node()", "D1 E2.D1", TRUE },
+    { "ancestor-or-self::node()[1]", "E2.D1" },
+    /* FIXME: [] should bind stronger than // */
+    { "(//a[1])[last()]", "E1.E4.E2.D1", TRUE },
+    { "((//a)[1])[last()]", "E1.E1.E2.D1" },
+    { NULL }
+};
+
 static void test_XPath(void)
 {
     const selection_ns_t *ptr = selection_ns_data;
+    const xpath_test_t *xptest = xpath_test;
     VARIANT var;
     VARIANT_BOOL b;
     IXMLDOMDocument2 *doc;
@@ -4406,6 +4451,29 @@ static void test_XPath(void)
     EXPECT_HR(hr, S_OK);
     expect_list_and_release(list, "E2.D1");
 
+    /* peform xpath tests */
+    for ( ; xptest->query ; xptest++ )
+    {
+        const char *failmsg = "query=%s, invalid node list: %s, expected %s\n";
+        char *str;
+
+        hr = IXMLDOMNode_selectNodes(rootNode, _bstr_(xptest->query), &list);
+        ok(hr == S_OK, "query evaluation failed for query=%s", xptest->query);
+
+        if (hr != S_OK)
+            continue;
+
+        str = list_to_string(list);
+
+        if (xptest->todo)
+            todo_wine ok(strcmp(str, xptest->list)==0, failmsg, xptest->query, str, xptest->list);
+        else
+            ok(strcmp(str, xptest->list)==0, failmsg, xptest->query, str, xptest->list);
+
+        if (list)
+            IXMLDOMNodeList_Release(list);
+    }
+
 if (0)
 {
     /* namespace:: axis test is disabled until namespace definitions
-- 
1.8.3.1


More information about the wine-patches mailing list