Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/xmllite/tests/writer.c | 62 ++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 29 deletions(-)
diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 87cdaabce1..972eb96d9b 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -1572,6 +1572,27 @@ static void test_indentation(void) IXmlWriter_Release(writer); }
+static HRESULT write_attribute_string(IXmlWriter *writer, const char *prefix, const char *local, + const char *uri, const char *value) +{ + WCHAR *prefixW, *localW, *uriW, *valueW; + HRESULT hr; + + prefixW = strdupAtoW(prefix); + localW = strdupAtoW(local); + uriW = strdupAtoW(uri); + valueW = strdupAtoW(value); + + hr = IXmlWriter_WriteAttributeString(writer, prefixW, localW, uriW, valueW); + + heap_free(prefixW); + heap_free(localW); + heap_free(uriW); + heap_free(valueW); + + return hr; +} + static void test_WriteAttributeString(void) { static const struct @@ -1589,6 +1610,7 @@ static void test_WriteAttributeString(void) { NULL, "a", NULL, "b", "<e a="b" />", "<e a="b"" }, { "prefix", "local", "uri", "b", "<e prefix:local="b" xmlns:prefix="uri" />", "<e prefix:local="b"" }, { NULL, "a", "http://www.w3.org/2000/xmlns/", "defuri", "<e xmlns:a="defuri" />", "<e xmlns:a="defuri"" }, + { "xmlns", "a", NULL, "uri", "<e xmlns:a="uri" />", "<e xmlns:a="uri"" },
/* Autogenerated prefix names. */ { NULL, "a", "defuri", NULL, "<e p1:a="" xmlns:p1="defuri" />", "<e p1:a=""" }, @@ -1606,12 +1628,6 @@ static void test_WriteAttributeString(void) { "prefix", "a", "http://www.w3.org/2000/xmlns/", "defuri", "<e />", "<e", WR_E_XMLNSURIDECLARATION }, };
- static const WCHAR prefixW[] = {'p','r','e','f','i','x',0}; - static const WCHAR localW[] = {'l','o','c','a','l',0}; - static const WCHAR uriW[] = {'u','r','i',0}; - static const WCHAR elementW[] = {'e',0}; - static const WCHAR aW[] = {'a',0}; - static const WCHAR bW[] = {'b',0}; IXmlWriter *writer; IStream *stream; unsigned int i; @@ -1624,22 +1640,16 @@ static void test_WriteAttributeString(void)
for (i = 0; i < ARRAY_SIZE(attribute_tests); ++i) { - WCHAR *prefixW, *localW, *uriW, *valueW; - stream = writer_set_output(writer);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "Failed to start document, hr %#x.\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, elementW, NULL); + hr = write_start_element(writer, NULL, "e", NULL); ok(hr == S_OK, "Failed to start element, hr %#x.\n", hr);
- prefixW = strdupAtoW(attribute_tests[i].prefix); - localW = strdupAtoW(attribute_tests[i].local); - uriW = strdupAtoW(attribute_tests[i].uri); - valueW = strdupAtoW(attribute_tests[i].value); - - hr = IXmlWriter_WriteAttributeString(writer, prefixW, localW, uriW, valueW); + hr = write_attribute_string(writer, attribute_tests[i].prefix, attribute_tests[i].local, + attribute_tests[i].uri, attribute_tests[i].value); todo_wine_if(i != 0) ok(hr == attribute_tests[i].hr, "%u: unexpected hr %#x.\n", i, hr);
@@ -1654,11 +1664,6 @@ static void test_WriteAttributeString(void) hr = IXmlWriter_Flush(writer); ok(hr == S_OK, "Failed to flush, hr %#x.\n", hr);
- heap_free(prefixW); - heap_free(localW); - heap_free(uriW); - heap_free(valueW); - check_output(stream, attribute_tests[i].output, i == 1 || i == 2 || i == 3 || i == 4, __LINE__); IStream_Release(stream); } @@ -1669,21 +1674,20 @@ static void test_WriteAttributeString(void) hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + hr = write_start_element(writer, "p", "a", "outeruri"); ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = IXmlWriter_WriteAttributeString(writer, aW, NULL, NULL, bW); -todo_wine - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); - - hr = IXmlWriter_WriteAttributeString(writer, prefixW, localW, uriW, bW); + hr = write_attribute_string(writer, "prefix", "local", "uri", "b"); todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = IXmlWriter_WriteAttributeString(writer, NULL, aW, NULL, bW); + hr = write_attribute_string(writer, NULL, "a", NULL, "b"); ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = IXmlWriter_WriteAttributeString(writer, prefixW, localW, NULL, bW); + hr = write_attribute_string(writer, "p", "attr", NULL, "value"); + ok(hr == S_OK, "Failed to write attribute string, hr %#x.\n", hr); + + hr = write_attribute_string(writer, "prefix", "local", NULL, "b"); todo_wine ok(hr == WR_E_DUPLICATEATTRIBUTE, "got 0x%08x\n", hr);
@@ -1694,7 +1698,7 @@ todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
CHECK_OUTPUT_TODO(stream, - "<a prefix:local="b" a="b" xmlns:prefix="uri" />"); + "<p:a prefix:local="b" a="b" p:attr="value" xmlns:prefix="uri" xmlns:p="outeruri" />");
IXmlWriter_Release(writer); IStream_Release(stream);