hr = IXmlReader_GetDepth(reader, &count);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
-todo_wine
ok(count == 1, "Expected 1, got %d\n", count);
hr = IXmlReader_MoveToElement(reader);
const char *value;
HRESULT hr;
HRESULT hr_broken; /* this is set to older version results */
+ int todo : 1;
};
static struct test_entry comment_tests[] = {
str = NULL;
hr = IXmlReader_GetLocalName(reader, &str, &len);
ok(hr == S_OK, "got 0x%08x\n", hr);
-todo_wine {
ok(len == lstrlenW(sysW), "got %u\n", len);
ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str));
-}
+
len = 0;
str = NULL;
hr = IXmlReader_GetValue(reader, &str, &len);
ok(hr == S_OK, "got 0x%08x\n", hr);
-todo_wine {
ok(len == lstrlenW(sysvalW), "got %u\n", len);
ok(!lstrcmpW(str, sysvalW), "got %s\n", wine_dbgstr_w(str));
-}
+
hr = IXmlReader_MoveToElement(reader);
ok(hr == S_OK, "got 0x%08x\n", hr);
str = NULL;
hr = IXmlReader_GetLocalName(reader, &str, &len);
ok(hr == S_OK, "got 0x%08x\n", hr);
+todo_wine {
ok(len == lstrlenW(dtdnameW), "got %u\n", len);
ok(!lstrcmpW(str, dtdnameW), "got %s\n", wine_dbgstr_w(str));
-
+}
len = 0;
str = NULL;
hr = IXmlReader_GetQualifiedName(reader, &str, &len);
ok(hr == S_OK, "got %08x\n", hr);
ok(depth == 0, "got %d\n", depth);
+ type = XmlNodeType_None;
hr = IXmlReader_Read(reader, &type);
ok(hr == S_OK, "got %08x\n", hr);
+ ok(type == XmlNodeType_Element, "got %d\n", type);
depth = 1;
hr = IXmlReader_GetDepth(reader, &depth);
ok(hr == S_OK, "got %08x\n", hr);
ok(depth == 0, "got %d\n", depth);
+ type = XmlNodeType_None;
hr = IXmlReader_Read(reader, &type);
ok(hr == S_OK, "got %08x\n", hr);
+ ok(type == XmlNodeType_Element, "got %d\n", type);
depth = 0;
hr = IXmlReader_GetDepth(reader, &depth);
static struct test_entry cdata_tests[] = {
{ "<a><![CDATA[ ]]data ]]></a>", "", " ]]data ", S_OK },
{ "<a><![CDATA[<![CDATA[ data ]]]]></a>", "", "<![CDATA[ data ]]", S_OK },
+ { "<a><![CDATA[\n \r\n \n\n ]]></a>", "", "\n \n \n\n ", S_OK, S_OK, 1 },
+ { "<a><![CDATA[\r \r\r\n \n\n ]]></a>", "", "\n \n\n \n\n ", S_OK, S_OK, 1 },
+ { "<a><![CDATA[\r\r \n\r \r \n\n ]]></a>", "", "\n\n \n\n \n \n\n ", S_OK },
{ NULL }
};
ok(type == XmlNodeType_CDATA, "got %d for %s\n", type, test->xml);
+ str_exp = a2w(test->name);
+
len = 1;
str = NULL;
hr = IXmlReader_GetLocalName(reader, &str, &len);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(len == strlen(test->name), "got %u\n", len);
+ ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+
+ str = NULL;
+ hr = IXmlReader_GetLocalName(reader, &str, NULL);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+
+ free_str(str_exp);
+
+ len = 1;
+ str = NULL;
+ hr = IXmlReader_GetQualifiedName(reader, &str, &len);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(len == strlen(test->name), "got %u\n", len);
str_exp = a2w(test->name);
ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
free_str(str_exp);
+ /* value */
+ len = 1;
+ str = NULL;
+ hr = IXmlReader_GetValue(reader, &str, &len);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ str_exp = a2w(test->value);
+ if (test->todo)
+ {
+ todo_wine {
+ ok(len == strlen(test->value), "got %u\n", len);
+ ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+ }
+ }
+ else
+ {
+ ok(len == strlen(test->value), "got %u\n", len);
+ ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+ }
+ free_str(str_exp);
+ }
+
+ IStream_Release(stream);
+ test++;
+ }
+
+ IXmlReader_Release(reader);
+}
+
+static struct test_entry text_tests[] = {
+ { "<a>simple text</a>", "", "simple text", S_OK },
+ { "<a>text ]]> text</a>", "", "", WC_E_CDSECTEND },
+ { NULL }
+};
+
+static void test_read_text(void)
+{
+ struct test_entry *test = text_tests;
+ IXmlReader *reader;
+ HRESULT hr;
+
+ hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ ok(hr == S_OK, "S_OK, got %08x\n", hr);
+
+ while (test->xml)
+ {
+ XmlNodeType type;
+ IStream *stream;
+
+ stream = create_stream_on_data(test->xml, strlen(test->xml)+1);
+ hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
+ ok(hr == S_OK, "got %08x\n", hr);
+
+ type = XmlNodeType_None;
+ hr = IXmlReader_Read(reader, &type);
+
+ /* read one more to get to CDATA */
+ if (type == XmlNodeType_Element)
+ {
+ type = XmlNodeType_None;
+ hr = IXmlReader_Read(reader, &type);
+ }
+
+ if (test->hr_broken)
+ ok(hr == test->hr || broken(hr == test->hr_broken), "got %08x for %s\n", hr, test->xml);
+ else
+ ok(hr == test->hr, "got %08x for %s\n", hr, test->xml);
+ if (hr == S_OK)
+ {
+ const WCHAR *str;
+ WCHAR *str_exp;
+ UINT len;
+
+ ok(type == XmlNodeType_Text, "got %d for %s\n", type, test->xml);
+
+ str_exp = a2w(test->name);
+
+ len = 1;
+ str = NULL;
+ hr = IXmlReader_GetLocalName(reader, &str, &len);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(len == strlen(test->name), "got %u\n", len);
+ ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+
+ str = NULL;
+ hr = IXmlReader_GetLocalName(reader, &str, NULL);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+
+ free_str(str_exp);
+
len = 1;
str = NULL;
hr = IXmlReader_GetQualifiedName(reader, &str, &len);
ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
free_str(str_exp);
+ /* value */
+ len = 1;
+ str = NULL;
+ hr = IXmlReader_GetValue(reader, &str, &len);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ str_exp = a2w(test->value);
+ if (test->todo)
+ {
+ todo_wine {
+ ok(len == strlen(test->value), "got %u\n", len);
+ ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+ }
+ }
+ else
+ {
+ ok(len == strlen(test->value), "got %u\n", len);
+ ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+ }
+ free_str(str_exp);
+ }
+
+ IStream_Release(stream);
+ test++;
+ }
+
+ IXmlReader_Release(reader);
+}
+
+struct test_entry_empty {
+ const char *xml;
+ BOOL empty;
+};
+
+static struct test_entry_empty empty_element_tests[] = {
+ { "<a></a>", FALSE },
+ { "<a/>", TRUE },
+ { NULL }
+};
+
+static void test_isemptyelement(void)
+{
+ struct test_entry_empty *test = empty_element_tests;
+ IXmlReader *reader;
+ HRESULT hr;
+
+ hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ ok(hr == S_OK, "S_OK, got %08x\n", hr);
+
+ while (test->xml)
+ {
+ XmlNodeType type;
+ IStream *stream;
+ BOOL ret;
+
+ stream = create_stream_on_data(test->xml, strlen(test->xml)+1);
+ hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
+ ok(hr == S_OK, "got %08x\n", hr);
+
+ type = XmlNodeType_None;
+ hr = IXmlReader_Read(reader, &type);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(type == XmlNodeType_Element, "got %d\n", type);
+
+ ret = IXmlReader_IsEmptyElement(reader);
+ ok(ret == test->empty, "got %d, expected %d. xml=%s\n", ret, test->empty, test->xml);
+
+ IStream_Release(stream);
+ test++;
+ }
+
+ IXmlReader_Release(reader);
+}
+
+static struct test_entry attributes_tests[] = {
+ { "<a attr1=\"attrvalue\"/>", "attr1", "attrvalue", S_OK },
+ { "<a attr1=\"a\'\'ttrvalue\"/>", "attr1", "a\'\'ttrvalue", S_OK },
+ { "<a attr1=\'a\"ttrvalue\'/>", "attr1", "a\"ttrvalue", S_OK },
+ { "<a attr1=\' \'/>", "attr1", " ", S_OK },
+ { "<a attr1=\" \"/>", "attr1", " ", S_OK },
+ { "<a attr1=\"\r\n \r \n \t\n\r\"/>", "attr1", " ", S_OK },
+ { "<a attr1=\" val \"/>", "attr1", " val ", S_OK },
+ { "<a attr1=\"\r\n\tval\n\"/>", "attr1", " val ", S_OK },
+ { "<a attr1=\"val \"/>", "attr1", "val ", S_OK },
+ { "<a attr1=\"val \"/>", "attr1", "val ", S_OK },
+ { "<a attr1=\"<>&'"\"/>", "attr1", "<>&\'\"", S_OK },
+ { "<a attr1=\"&entname;\"/>", NULL, NULL, WC_E_UNDECLAREDENTITY },
+ { "<a attr1=\"val\"/>", NULL, NULL, WC_E_XMLCHARACTER },
+ { "<a attr1=\"val &#a;\"/>", NULL, NULL, WC_E_DIGIT, WC_E_SEMICOLON },
+ { "<a attr1=\"val a;\"/>", NULL, NULL, WC_E_SEMICOLON },
+ { "<a attr1=\"val g;\"/>", NULL, NULL, WC_E_SEMICOLON },
+ { "<a attr1=\"val &#xg;\"/>", NULL, NULL, WC_E_HEXDIGIT, WC_E_SEMICOLON },
+ { "<a attr1=attrvalue/>", NULL, NULL, WC_E_QUOTE },
+ { "<a attr1=\"attr<value\"/>", NULL, NULL, WC_E_LESSTHAN },
+ { "<a attr1=\"&entname\"/>", NULL, NULL, WC_E_SEMICOLON },
+ { NULL }
+};
+
+static void test_read_attribute(void)
+{
+ struct test_entry *test = attributes_tests;
+ IXmlReader *reader;
+ HRESULT hr;
+
+ hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ ok(hr == S_OK, "S_OK, got %08x\n", hr);
+
+ while (test->xml)
+ {
+ XmlNodeType type;
+ IStream *stream;
+
+ stream = create_stream_on_data(test->xml, strlen(test->xml)+1);
+ hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
+ ok(hr == S_OK, "got %08x\n", hr);
+
+ type = XmlNodeType_None;
+ hr = IXmlReader_Read(reader, &type);
+
+ if (test->hr_broken)
+ ok(hr == test->hr || broken(hr == test->hr_broken), "got %08x for %s\n", hr, test->xml);
+ else
+ ok(hr == test->hr, "got %08x for %s\n", hr, test->xml);
+ if (hr == S_OK)
+ {
+ const WCHAR *str;
+ WCHAR *str_exp;
+ UINT len;
+
+ ok(type == XmlNodeType_Element, "got %d for %s\n", type, test->xml);
+
+ hr = IXmlReader_MoveToFirstAttribute(reader);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ len = 1;
+ str = NULL;
+ hr = IXmlReader_GetLocalName(reader, &str, &len);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(len == strlen(test->name), "got %u\n", len);
+ str_exp = a2w(test->name);
+ ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+ free_str(str_exp);
+
+ len = 1;
+ str = NULL;
+ hr = IXmlReader_GetQualifiedName(reader, &str, &len);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ todo_wine {
+ ok(len == strlen(test->name), "got %u\n", len);
+ str_exp = a2w(test->name);
+ ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+ free_str(str_exp);
+ }
/* value */
len = 1;
str = NULL;
test_reader_create();
test_readerinput();
test_reader_state();
+ test_read_attribute();
test_read_cdata();
test_read_comment();
test_read_pi();
test_read_dtd();
test_read_element();
+ test_isemptyelement();
+ test_read_text();
test_read_full();
test_read_pending();
test_readvaluechunk();