Commit 63c489fa authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

xmllite/reader: Fix GetValue() for comments.

parent 2d3ec124
...@@ -3060,7 +3060,7 @@ static HRESULT WINAPI xmlreader_GetValue(IXmlReader* iface, const WCHAR **value, ...@@ -3060,7 +3060,7 @@ static HRESULT WINAPI xmlreader_GetValue(IXmlReader* iface, const WCHAR **value,
*value = NULL; *value = NULL;
if ((reader->nodetype == XmlNodeType_Comment && !val->str) || is_reader_pending(reader)) if ((reader->nodetype == XmlNodeType_Comment && !val->str && !val->len) || is_reader_pending(reader))
{ {
XmlNodeType type; XmlNodeType type;
HRESULT hr; HRESULT hr;
......
...@@ -954,18 +954,47 @@ static struct test_entry comment_tests[] = { ...@@ -954,18 +954,47 @@ static struct test_entry comment_tests[] = {
static void test_read_comment(void) static void test_read_comment(void)
{ {
static const char *teststr = "<a>text<!-- comment --></a>";
struct test_entry *test = comment_tests; struct test_entry *test = comment_tests;
static const XmlNodeType types[] =
{
XmlNodeType_Element,
XmlNodeType_Text,
XmlNodeType_Comment,
XmlNodeType_EndElement,
};
unsigned int i = 0;
IXmlReader *reader; IXmlReader *reader;
XmlNodeType type;
IStream *stream;
HRESULT hr; HRESULT hr;
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL); hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "S_OK, got %08x\n", hr); ok(hr == S_OK, "S_OK, got %08x\n", hr);
while (test->xml) stream = create_stream_on_data(teststr, strlen(teststr));
hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
ok(hr == S_OK, "got %08x\n", hr);
while (IXmlReader_Read(reader, &type) == S_OK)
{ {
XmlNodeType type; const WCHAR *value;
IStream *stream;
ok(type == types[i], "%d: unexpected node type %d\n", i, type);
if (type == XmlNodeType_Text || type == XmlNodeType_Comment)
{
hr = IXmlReader_GetValue(reader, &value, NULL);
ok(hr == S_OK, "got %08x\n", hr);
ok(*value != 0, "Expected node value\n");
}
i++;
}
IStream_Release(stream);
while (test->xml)
{
stream = create_stream_on_data(test->xml, strlen(test->xml)+1); stream = create_stream_on_data(test->xml, strlen(test->xml)+1);
hr = IXmlReader_SetInput(reader, (IUnknown*)stream); hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
ok(hr == S_OK, "got %08x\n", hr); ok(hr == S_OK, "got %08x\n", hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment