Commit 8b2b455b authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

xmllite/writer: Close open tag with WriteFullEndElement().

parent 6870f3c0
......@@ -1143,6 +1143,80 @@ todo_wine
IStream_Release(stream);
}
static void test_WriteFullEndElement(void)
{
static const WCHAR aW[] = {'a',0};
IXmlWriter *writer;
IStream *stream;
HRESULT hr;
hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
/* standalone element */
stream = writer_set_output(writer);
hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_Indent, TRUE);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteFullEndElement(writer);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteEndDocument(writer);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_Flush(writer);
ok(hr == S_OK, "got 0x%08x\n", hr);
CHECK_OUTPUT(stream,
"<a></a>");
IStream_Release(stream);
/* nested elements */
stream = writer_set_output(writer);
hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_Indent, TRUE);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteFullEndElement(writer);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteEndDocument(writer);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_Flush(writer);
ok(hr == S_OK, "got 0x%08x\n", hr);
CHECK_OUTPUT(stream,
"<a>\r\n"
" <a></a>\r\n"
"</a>");
IXmlWriter_Release(writer);
IStream_Release(stream);
}
START_TEST(writer)
{
test_writer_create();
......@@ -1160,4 +1234,5 @@ START_TEST(writer)
test_WriteRaw();
test_indentation();
test_WriteAttributeString();
test_WriteFullEndElement();
}
......@@ -947,11 +947,13 @@ static HRESULT WINAPI xmlwriter_WriteFullEndElement(IXmlWriter *iface)
if (!element)
return WR_E_INVALIDACTION;
writer_close_starttag(This);
writer_dec_indent(This);
/* write full end tag */
write_output_buffer(This->output, closeelementW, ARRAY_SIZE(closeelementW));
write_output_buffer(This->output, element->qname, element->len);
write_output_buffer(This->output, gtW, ARRAY_SIZE(gtW));
This->starttagopen = FALSE;
return S_OK;
}
......
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