Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/xmllite/tests/writer.c | 674 ++++++++++++++---------------------- 1 file changed, 266 insertions(+), 408 deletions(-)
diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 2f6edb26d16..3e1c362664e 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -32,8 +32,6 @@ #include "initguid.h" DEFINE_GUID(IID_IXmlWriterOutput, 0xc1131708, 0x0f59, 0x477f, 0x93, 0x59, 0x7d, 0x33, 0x24, 0x51, 0xbc, 0x1a);
-static const WCHAR aW[] = {'a',0}; - #define EXPECT_REF(obj, ref) _expect_ref((IUnknown *)obj, ref, __LINE__) static void _expect_ref(IUnknown *obj, ULONG ref, int line) { @@ -92,19 +90,6 @@ static void check_output(IStream *stream, const char *expected, BOOL todo, int l #define CHECK_OUTPUT_TODO(stream, expected) check_output(stream, expected, TRUE, __LINE__) #define CHECK_OUTPUT_RAW(stream, expected, size) check_output_raw(stream, expected, size, __LINE__)
-static WCHAR *strdupAtoW(const char *str) -{ - WCHAR *ret = NULL; - DWORD len; - - if (!str) return ret; - len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); - ret = malloc(len * sizeof(WCHAR)); - if (ret) - MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); - return ret; -} - static void writer_set_property(IXmlWriter *writer, XmlWriterProperty property) { HRESULT hr; @@ -116,30 +101,29 @@ static void writer_set_property(IXmlWriter *writer, XmlWriterProperty property) /* used to test all Write* methods for consistent error state */ static void check_writer_state(IXmlWriter *writer, HRESULT exp_hr) { - static const WCHAR aW[] = {'a',0}; HRESULT hr;
/* FIXME: add WriteAttributes */
- hr = IXmlWriter_WriteAttributeString(writer, NULL, aW, NULL, aW); + hr = IXmlWriter_WriteAttributeString(writer, NULL, L"a", NULL, L"a"); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr);
- hr = IXmlWriter_WriteCData(writer, aW); + hr = IXmlWriter_WriteCData(writer, L"a"); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr);
- hr = IXmlWriter_WriteCharEntity(writer, aW[0]); + hr = IXmlWriter_WriteCharEntity(writer, 'a'); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr);
- hr = IXmlWriter_WriteChars(writer, aW, 1); + hr = IXmlWriter_WriteChars(writer, L"a", 1); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr);
- hr = IXmlWriter_WriteComment(writer, aW); + hr = IXmlWriter_WriteComment(writer, L"a"); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr);
- hr = IXmlWriter_WriteDocType(writer, aW, NULL, NULL, NULL); + hr = IXmlWriter_WriteDocType(writer, L"a", NULL, NULL, NULL); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr);
- hr = IXmlWriter_WriteElementString(writer, NULL, aW, NULL, aW); + hr = IXmlWriter_WriteElementString(writer, NULL, L"a", NULL, L"a"); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr);
hr = IXmlWriter_WriteEndDocument(writer); @@ -148,40 +132,40 @@ static void check_writer_state(IXmlWriter *writer, HRESULT exp_hr) hr = IXmlWriter_WriteEndElement(writer); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr);
- hr = IXmlWriter_WriteEntityRef(writer, aW); + hr = IXmlWriter_WriteEntityRef(writer, L"a"); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr);
hr = IXmlWriter_WriteFullEndElement(writer); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr);
- hr = IXmlWriter_WriteName(writer, aW); + hr = IXmlWriter_WriteName(writer, L"a"); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr);
- hr = IXmlWriter_WriteNmToken(writer, aW); + hr = IXmlWriter_WriteNmToken(writer, L"a"); ok(hr == exp_hr, "Unexpected hr %#lx, expected %#lx.\n", hr, exp_hr);
/* FIXME: add WriteNode */ /* FIXME: add WriteNodeShallow */
- hr = IXmlWriter_WriteProcessingInstruction(writer, aW, aW); + hr = IXmlWriter_WriteProcessingInstruction(writer, L"a", L"a"); ok(hr == exp_hr, "Unexpected hr %#lx., expected %#lx.\n", hr, exp_hr);
- hr = IXmlWriter_WriteQualifiedName(writer, aW, NULL); + hr = IXmlWriter_WriteQualifiedName(writer, L"a", NULL); ok(hr == exp_hr, "Unexpected hr %#lx., expected %#lx.\n", hr, exp_hr);
- hr = IXmlWriter_WriteRaw(writer, aW); + hr = IXmlWriter_WriteRaw(writer, L"a"); ok(hr == exp_hr, "Unexpected hr %#lx., expected %#lx.\n", hr, exp_hr);
- hr = IXmlWriter_WriteRawChars(writer, aW, 1); + hr = IXmlWriter_WriteRawChars(writer, L"a", 1); ok(hr == exp_hr, "Unexpected hr %#lx., expected %#lx.\n", hr, exp_hr);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == exp_hr, "Unexpected hr %#lx., expected %#lx.\n", hr, exp_hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == exp_hr, "Unexpected hr %#lx., expected %#lx.\n", hr, exp_hr);
- hr = IXmlWriter_WriteString(writer, aW); + hr = IXmlWriter_WriteString(writer, L"a"); ok(hr == exp_hr, "Unexpected hr %#lx., expected %#lx.\n", hr, exp_hr);
/* FIXME: add WriteSurrogateCharEntity */ @@ -340,25 +324,25 @@ static void test_invalid_output_encoding(IXmlWriter *writer, IUnknown *output)
/* TODO: WriteAttributes */
- hr = IXmlWriter_WriteAttributeString(writer, NULL, aW, NULL, aW); + hr = IXmlWriter_WriteAttributeString(writer, NULL, L"a", NULL, L"a"); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteCData(writer, aW); + hr = IXmlWriter_WriteCData(writer, L"a"); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteCharEntity(writer, 0x100); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteChars(writer, aW, 1); + hr = IXmlWriter_WriteChars(writer, L"a", 1); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteComment(writer, aW); + hr = IXmlWriter_WriteComment(writer, L"a"); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteDocType(writer, aW, NULL, NULL, NULL); + hr = IXmlWriter_WriteDocType(writer, L"a", NULL, NULL, NULL); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteElementString(writer, NULL, aW, NULL, NULL); + hr = IXmlWriter_WriteElementString(writer, NULL, L"a", NULL, NULL); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEndDocument(writer); @@ -367,40 +351,40 @@ static void test_invalid_output_encoding(IXmlWriter *writer, IUnknown *output) hr = IXmlWriter_WriteEndElement(writer); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteEntityRef(writer, aW); + hr = IXmlWriter_WriteEntityRef(writer, L"a"); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteFullEndElement(writer); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteName(writer, aW); + hr = IXmlWriter_WriteName(writer, L"a"); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteNmToken(writer, aW); + hr = IXmlWriter_WriteNmToken(writer, L"a"); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
/* TODO: WriteNode */ /* TODO: WriteNodeShallow */
- hr = IXmlWriter_WriteProcessingInstruction(writer, aW, aW); + hr = IXmlWriter_WriteProcessingInstruction(writer, L"a", L"a"); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteQualifiedName(writer, aW, NULL); + hr = IXmlWriter_WriteQualifiedName(writer, L"a", NULL); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteRaw(writer, aW); + hr = IXmlWriter_WriteRaw(writer, L"a"); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteRawChars(writer, aW, 1); + hr = IXmlWriter_WriteRawChars(writer, L"a", 1); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteString(writer, aW); + hr = IXmlWriter_WriteString(writer, L"a"); ok(hr == MX_E_ENCODING, "Unexpected hr %#lx.\n", hr);
/* TODO: WriteSurrogateCharEntity */ @@ -412,9 +396,6 @@ static void test_invalid_output_encoding(IXmlWriter *writer, IUnknown *output)
static void test_writeroutput(void) { - static const WCHAR utf16W[] = {'u','t','f','-','1','6',0}; - static const WCHAR usasciiW[] = {'u','s','-','a','s','c','i','i',0}; - static const WCHAR dummyW[] = {'d','u','m','m','y',0}; static const WCHAR utf16_outputW[] = {0xfeff,'<','a'}; IXmlWriterOutput *output; IXmlWriter *writer; @@ -428,7 +409,7 @@ static void test_writeroutput(void) EXPECT_REF(output, 1); IUnknown_Release(output);
- hr = CreateXmlWriterOutputWithEncodingName(&testoutput, NULL, utf16W, &output); + hr = CreateXmlWriterOutputWithEncodingName(&testoutput, NULL, L"utf-16", &output); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); unk = NULL; hr = IUnknown_QueryInterface(output, &IID_IXmlWriterOutput, (void**)&unk); @@ -458,7 +439,7 @@ static void test_writeroutput(void)
/* create with us-ascii */ output = NULL; - hr = CreateXmlWriterOutputWithEncodingName(&testoutput, NULL, usasciiW, &output); + hr = CreateXmlWriterOutputWithEncodingName(&testoutput, NULL, L"us-ascii", &output); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); IUnknown_Release(output);
@@ -475,7 +456,7 @@ static void test_writeroutput(void) hr = IXmlWriter_SetOutput(writer, output); ok(hr == S_OK, "Failed to set writer output, hr %#lx.\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == S_OK, "Write failed, hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -505,7 +486,7 @@ static void test_writeroutput(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
output = NULL; - hr = CreateXmlWriterOutputWithEncodingName((IUnknown *)stream, NULL, dummyW, &output); + hr = CreateXmlWriterOutputWithEncodingName((IUnknown *)stream, NULL, L"dummy", &output); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
test_invalid_output_encoding(writer, output); @@ -522,9 +503,6 @@ static void test_writestartdocument(void) static const char fullprolog[] = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"; static const char *prologversion2 = "<?xml version=\"1.0\" encoding=\"uS-asCii\"?>"; static const char prologversion[] = "<?xml version=\"1.0\"?>"; - static const WCHAR versionW[] = {'v','e','r','s','i','o','n','=','"','1','.','0','"',0}; - static const WCHAR usasciiW[] = {'u','S','-','a','s','C','i','i',0}; - static const WCHAR xmlW[] = {'x','m','l',0}; IXmlWriterOutput *output; IXmlWriter *writer; IStream *stream; @@ -537,7 +515,7 @@ static void test_writestartdocument(void) hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes); ok(hr == E_UNEXPECTED, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteProcessingInstruction(writer, xmlW, versionW); + hr = IXmlWriter_WriteProcessingInstruction(writer, L"xml", L"version="1.0""); ok(hr == E_UNEXPECTED, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -565,7 +543,7 @@ static void test_writestartdocument(void) /* now add PI manually, and try to start a document */ stream = writer_set_output(writer);
- hr = IXmlWriter_WriteProcessingInstruction(writer, xmlW, versionW); + hr = IXmlWriter_WriteProcessingInstruction(writer, L"xml", L"version="1.0""); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes); @@ -575,7 +553,7 @@ static void test_writestartdocument(void) ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr);
/* another attempt to add 'xml' PI */ - hr = IXmlWriter_WriteProcessingInstruction(writer, xmlW, versionW); + hr = IXmlWriter_WriteProcessingInstruction(writer, L"xml", L"version="1.0""); ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -591,7 +569,7 @@ static void test_writestartdocument(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
output = NULL; - hr = CreateXmlWriterOutputWithEncodingName((IUnknown *)stream, NULL, usasciiW, &output); + hr = CreateXmlWriterOutputWithEncodingName((IUnknown *)stream, NULL, L"uS-asCii", &output); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = CreateXmlWriter(&IID_IXmlWriter, (void **)&writer, NULL); @@ -646,8 +624,6 @@ static void test_flush(void) static void test_omitxmldeclaration(void) { static const char prologversion[] = "<?xml version=\"1.0\"?>"; - static const WCHAR versionW[] = {'v','e','r','s','i','o','n','=','"','1','.','0','"',0}; - static const WCHAR xmlW[] = {'x','m','l',0}; IXmlWriter *writer; HGLOBAL hglobal; IStream *stream; @@ -683,7 +659,7 @@ static void test_omitxmldeclaration(void) /* now add PI manually, and try to start a document */ stream = writer_set_output(writer);
- hr = IXmlWriter_WriteProcessingInstruction(writer, xmlW, versionW); + hr = IXmlWriter_WriteProcessingInstruction(writer, L"xml", L"version="1.0""); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -708,7 +684,7 @@ static void test_omitxmldeclaration(void) CHECK_OUTPUT(stream, prologversion);
/* another attempt to add 'xml' PI */ - hr = IXmlWriter_WriteProcessingInstruction(writer, xmlW, versionW); + hr = IXmlWriter_WriteProcessingInstruction(writer, L"xml", L"version="1.0""); ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -723,9 +699,6 @@ static void test_bom(void) static const WCHAR piW[] = {0xfeff,'<','?','x','m','l',' ','v','e','r','s','i','o','n','=','"','1','.','0','"','?','>'}; static const WCHAR aopenW[] = {0xfeff,'<','a'}; static const WCHAR afullW[] = {0xfeff,'<','a',' ','/','>'}; - static const WCHAR versionW[] = {'v','e','r','s','i','o','n','=','"','1','.','0','"',0}; - static const WCHAR utf16W[] = {'u','t','f','-','1','6',0}; - static const WCHAR xmlW[] = {'x','m','l',0}; static const WCHAR bomW[] = {0xfeff}; IXmlWriterOutput *output; IXmlWriter *writer; @@ -736,7 +709,7 @@ static void test_bom(void) hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W, &output); + hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, L"utf-16", &output); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL); @@ -763,13 +736,13 @@ static void test_bom(void) hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W, &output); + hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, L"utf-16", &output); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_SetOutput(writer, output); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteProcessingInstruction(writer, xmlW, versionW); + hr = IXmlWriter_WriteProcessingInstruction(writer, L"xml", L"version="1.0""); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -784,13 +757,13 @@ static void test_bom(void) hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W, &output); + hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, L"utf-16", &output); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_SetOutput(writer, output); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -805,7 +778,7 @@ static void test_bom(void) hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W, &output); + hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, L"utf-16", &output); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_SetOutput(writer, output); @@ -813,7 +786,7 @@ static void test_bom(void)
writer_set_property(writer, XmlWriterProperty_Indent);
- hr = IXmlWriter_WriteElementString(writer, NULL, aW, NULL, NULL); + hr = IXmlWriter_WriteElementString(writer, NULL, L"a", NULL, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -830,67 +803,13 @@ static void test_bom(void) IXmlWriter_Release(writer); }
-static HRESULT write_start_element(IXmlWriter *writer, const char *prefix, const char *local, - const char *uri) -{ - WCHAR *prefixW, *localW, *uriW; - HRESULT hr; - - prefixW = strdupAtoW(prefix); - localW = strdupAtoW(local); - uriW = strdupAtoW(uri); - - hr = IXmlWriter_WriteStartElement(writer, prefixW, localW, uriW); - - free(prefixW); - free(localW); - free(uriW); - - return hr; -} - -static HRESULT write_element_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_WriteElementString(writer, prefixW, localW, uriW, valueW); - - free(prefixW); - free(localW); - free(uriW); - free(valueW); - - return hr; -} - -static HRESULT write_string(IXmlWriter *writer, const char *str) -{ - WCHAR *strW; - HRESULT hr; - - strW = strdupAtoW(str); - - hr = IXmlWriter_WriteString(writer, strW); - - free(strW); - - return hr; -} - static void test_WriteStartElement(void) { static const struct { - const char *prefix; - const char *local; - const char *uri; + const WCHAR *prefix; + const WCHAR *local; + const WCHAR *uri; const char *output; const char *output_partial; HRESULT hr; @@ -899,22 +818,21 @@ static void test_WriteStartElement(void) } start_element_tests[] = { - { "prefix", "local", "uri", "<prefix:local xmlns:prefix="uri" />", "<prefix:local" }, - { NULL, "local", "uri", "<local xmlns="uri" />", "<local" }, - { "", "local", "uri", "<local xmlns="uri" />", "<local" }, - { "", "local", "uri", "<local xmlns="uri" />", "<local" }, + { L"prefix", L"local", L"uri", "<prefix:local xmlns:prefix="uri" />", "<prefix:local" }, + { NULL, L"local", L"uri", "<local xmlns="uri" />", "<local" }, + { L"", L"local", L"uri", "<local xmlns="uri" />", "<local" }, + { L"", L"local", L"uri", "<local xmlns="uri" />", "<local" },
- { "prefix", NULL, NULL, NULL, NULL, E_INVALIDARG }, - { NULL, NULL, "uri", NULL, NULL, E_INVALIDARG }, + { L"prefix", NULL, NULL, NULL, NULL, E_INVALIDARG }, + { NULL, NULL, L"uri", NULL, NULL, E_INVALIDARG }, { NULL, NULL, NULL, NULL, NULL, E_INVALIDARG }, - { NULL, "prefix:local", "uri", NULL, NULL, WC_E_NAMECHARACTER }, - { "pre:fix", "local", "uri", NULL, NULL, WC_E_NAMECHARACTER }, - { NULL, ":local", "uri", NULL, NULL, WC_E_NAMECHARACTER }, - { ":", "local", "uri", NULL, NULL, WC_E_NAMECHARACTER }, - { NULL, "local", "http://www.w3.org/2000/xmlns/", NULL, NULL, WR_E_XMLNSPREFIXDECLARATION }, - { "prefix", "local", "http://www.w3.org/2000/xmlns/", NULL, NULL, WR_E_XMLNSURIDECLARATION }, + { NULL, L"prefix:local", L"uri", NULL, NULL, WC_E_NAMECHARACTER }, + { L"pre:fix", L"local", L"uri", NULL, NULL, WC_E_NAMECHARACTER }, + { NULL, L":local", L"uri", NULL, NULL, WC_E_NAMECHARACTER }, + { L":", L"local", L"uri", NULL, NULL, WC_E_NAMECHARACTER }, + { NULL, L"local", L"http://www.w3.org/2000/xmlns/", NULL, NULL, WR_E_XMLNSPREFIXDECLARATION }, + { L"prefix", L"local", L"http://www.w3.org/2000/xmlns/", NULL, NULL, WR_E_XMLNSURIDECLARATION }, }; - static const WCHAR aW[] = {'a',0}; IXmlWriter *writer; IStream *stream; unsigned int i; @@ -923,12 +841,12 @@ static void test_WriteStartElement(void) hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_start_element(writer, NULL, "a", NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == E_UNEXPECTED, "Unexpected hr %#lx.\n", hr);
stream = writer_set_output(writer);
- hr = write_start_element(writer, NULL, "a", NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes); @@ -945,7 +863,7 @@ static void test_WriteStartElement(void) hr = IXmlWriter_WriteStartElement(writer, NULL, NULL, NULL); ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteProcessingInstruction(writer, aW, aW); + hr = IXmlWriter_WriteProcessingInstruction(writer, L"a", L"a"); ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr);
IStream_Release(stream); @@ -955,27 +873,27 @@ static void test_WriteStartElement(void) hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_element_string(writer, NULL, "b", NULL, "value"); + hr = IXmlWriter_WriteElementString(writer, NULL, L"b", NULL, L"value"); ok(hr == E_UNEXPECTED, "Unexpected hr %#lx.\n", hr);
stream = writer_set_output(writer);
- hr = write_start_element(writer, "prefix", "a", "uri"); + hr = IXmlWriter_WriteStartElement(writer, L"prefix", L"a", L"uri"); ok(hr == S_OK, "Failed to start element, hr %#lx.\n", hr);
- hr = write_element_string(writer, NULL, "b", NULL, "value"); + hr = IXmlWriter_WriteElementString(writer, NULL, L"b", NULL, L"value"); ok(hr == S_OK, "Failed to write element string, hr %#lx.\n", hr);
- hr = write_element_string(writer, NULL, "c", NULL, NULL); + hr = IXmlWriter_WriteElementString(writer, NULL, L"c", NULL, NULL); ok(hr == S_OK, "Failed to write element string, hr %#lx.\n", hr);
- hr = write_start_element(writer, NULL, "d", "uri"); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"d", L"uri"); ok(hr == S_OK, "Failed to start element, hr %#lx.\n", hr);
- hr = write_start_element(writer, "", "e", "uri"); + hr = IXmlWriter_WriteStartElement(writer, L"", L"e", L"uri"); ok(hr == S_OK, "Failed to start element, hr %#lx.\n", hr);
- hr = write_start_element(writer, "prefix2", "f", "uri"); + hr = IXmlWriter_WriteStartElement(writer, L"prefix2", L"f", L"uri"); ok(hr == S_OK, "Failed to start element, hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -1001,7 +919,7 @@ static void test_WriteStartElement(void) hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "Failed to start document, hr %#lx.\n", hr);
- hr = write_start_element(writer, start_element_tests[i].prefix, start_element_tests[i].local, + hr = IXmlWriter_WriteStartElement(writer, start_element_tests[i].prefix, start_element_tests[i].local, start_element_tests[i].uri); ok(hr == start_element_tests[i].hr, "%u: unexpected hr %#lx.\n", i, hr);
@@ -1031,39 +949,39 @@ static void test_WriteElementString(void) { static const struct { - const char *prefix; - const char *local; - const char *uri; - const char *value; + const WCHAR *prefix; + const WCHAR *local; + const WCHAR *uri; + const WCHAR *value; const char *output; HRESULT hr; int todo; } element_string_tests[] = { - { "prefix", "local", "uri", "value", "<prefix:local xmlns:prefix="uri">value</prefix:local>" }, - { NULL, "local", "uri", "value", "<local xmlns="uri">value</local>" }, - { "", "local", "uri", "value", "<local xmlns="uri">value</local>" }, - { "prefix", "local", "uri", NULL, "<prefix:local xmlns:prefix="uri" />" }, - { NULL, "local", "uri", NULL, "<local xmlns="uri" />" }, - { "", "local", "uri", NULL, "<local xmlns="uri" />" }, - { NULL, "local", NULL, NULL, "<local />" }, - { "prefix", "local", "uri", "", "<prefix:local xmlns:prefix="uri"></prefix:local>" }, - { NULL, "local", "uri", "", "<local xmlns="uri"></local>" }, - { "", "local", "uri", "", "<local xmlns="uri"></local>" }, - { NULL, "local", NULL, "", "<local></local>" }, - { "", "local", "http://www.w3.org/2000/xmlns/", NULL, "<local xmlns="http://www.w3.org/2000/xmlns/%5C" />" }, - - { "prefix", NULL, NULL, "value", NULL, E_INVALIDARG }, - { NULL, NULL, "uri", "value", NULL, E_INVALIDARG }, - { NULL, NULL, NULL, "value", NULL, E_INVALIDARG }, - { NULL, "prefix:local", "uri", "value", NULL, WC_E_NAMECHARACTER }, - { NULL, ":local", "uri", "value", NULL, WC_E_NAMECHARACTER }, - { ":", "local", "uri", "value", NULL, WC_E_NAMECHARACTER }, - { "prefix", "local", NULL, "value", NULL, WR_E_NSPREFIXWITHEMPTYNSURI }, - { "prefix", "local", "", "value", NULL, WR_E_NSPREFIXWITHEMPTYNSURI }, - { NULL, "local", "http://www.w3.org/2000/xmlns/", "value", NULL, WR_E_XMLNSPREFIXDECLARATION }, - { "prefix", "local", "http://www.w3.org/2000/xmlns/", "value", NULL, WR_E_XMLNSURIDECLARATION }, + { L"prefix", L"local", L"uri", L"value", "<prefix:local xmlns:prefix="uri">value</prefix:local>" }, + { NULL, L"local", L"uri", L"value", "<local xmlns="uri">value</local>" }, + { L"", L"local", L"uri", L"value", "<local xmlns="uri">value</local>" }, + { L"prefix", L"local", L"uri", NULL, "<prefix:local xmlns:prefix="uri" />" }, + { NULL, L"local", L"uri", NULL, "<local xmlns="uri" />" }, + { L"", L"local", L"uri", NULL, "<local xmlns="uri" />" }, + { NULL, L"local", NULL, NULL, "<local />" }, + { L"prefix", L"local", L"uri", L"", "<prefix:local xmlns:prefix="uri"></prefix:local>" }, + { NULL, L"local", L"uri", L"", "<local xmlns="uri"></local>" }, + { L"", L"local", L"uri", L"", "<local xmlns="uri"></local>" }, + { NULL, L"local", NULL, L"", "<local></local>" }, + { L"", L"local", L"http://www.w3.org/2000/xmlns/", NULL, "<local xmlns="http://www.w3.org/2000/xmlns/%5C" />" }, + + { L"prefix", NULL, NULL, L"value", NULL, E_INVALIDARG }, + { NULL, NULL, L"uri", L"value", NULL, E_INVALIDARG }, + { NULL, NULL, NULL, L"value", NULL, E_INVALIDARG }, + { NULL, L"prefix:local", L"uri", L"value", NULL, WC_E_NAMECHARACTER }, + { NULL, L":local", L"uri", L"value", NULL, WC_E_NAMECHARACTER }, + { L":", L"local", L"uri", L"value", NULL, WC_E_NAMECHARACTER }, + { L"prefix", L"local", NULL, L"value", NULL, WR_E_NSPREFIXWITHEMPTYNSURI }, + { L"prefix", L"local", L"", L"value", NULL, WR_E_NSPREFIXWITHEMPTYNSURI }, + { NULL, L"local", L"http://www.w3.org/2000/xmlns/", L"value", NULL, WR_E_XMLNSPREFIXDECLARATION }, + { L"prefix", L"local", L"http://www.w3.org/2000/xmlns/", L"value", NULL, WR_E_XMLNSURIDECLARATION }, }; IXmlWriter *writer; IStream *stream; @@ -1073,48 +991,48 @@ static void test_WriteElementString(void) hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_element_string(writer, NULL, "b", NULL, "value"); + hr = IXmlWriter_WriteElementString(writer, NULL, L"b", NULL, L"value"); ok(hr == E_UNEXPECTED, "Unexpected hr %#lx.\n", hr);
stream = writer_set_output(writer);
- hr = write_start_element(writer, NULL, "a", NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_element_string(writer, NULL, "b", NULL, "value"); + hr = IXmlWriter_WriteElementString(writer, NULL, L"b", NULL, L"value"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_element_string(writer, NULL, "b", NULL, NULL); + hr = IXmlWriter_WriteElementString(writer, NULL, L"b", NULL, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_element_string(writer, "prefix", "b", "uri", NULL); + hr = IXmlWriter_WriteElementString(writer, L"prefix", L"b", L"uri", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_start_element(writer, "prefix", "c", "uri"); + hr = IXmlWriter_WriteStartElement(writer, L"prefix", L"c", L"uri"); ok(hr == S_OK, "Failed to start element, hr %#lx.\n", hr);
- hr = write_element_string(writer, "prefix", "d", NULL, NULL); + hr = IXmlWriter_WriteElementString(writer, L"prefix", L"d", NULL, NULL); ok(hr == S_OK, "Failed to write element, hr %#lx.\n", hr);
- hr = write_element_string(writer, "prefix2", "d", "uri", NULL); + hr = IXmlWriter_WriteElementString(writer, L"prefix2", L"d", L"uri", NULL); ok(hr == S_OK, "Failed to write element, hr %#lx.\n", hr);
- hr = write_element_string(writer, NULL, "e", "uri", NULL); + hr = IXmlWriter_WriteElementString(writer, NULL, L"e", L"uri", NULL); ok(hr == S_OK, "Failed to write element, hr %#lx.\n", hr);
- hr = write_element_string(writer, "prefix", "f", "uri2", NULL); + hr = IXmlWriter_WriteElementString(writer, L"prefix", L"f", L"uri2", NULL); ok(hr == S_OK, "Failed to write element, hr %#lx.\n", hr);
- hr = write_element_string(writer, NULL, "g", "uri3", NULL); + hr = IXmlWriter_WriteElementString(writer, NULL, L"g", L"uri3", NULL); ok(hr == S_OK, "Failed to write element, hr %#lx.\n", hr);
- hr = write_element_string(writer, "prefix", "h", NULL, NULL); + hr = IXmlWriter_WriteElementString(writer, L"prefix", L"h", NULL, NULL); ok(hr == S_OK, "Failed to write element, hr %#lx.\n", hr);
- hr = write_element_string(writer, "prefix_i", "i", NULL, NULL); + hr = IXmlWriter_WriteElementString(writer, L"prefix_i", L"i", NULL, NULL); ok(hr == WR_E_NSPREFIXWITHEMPTYNSURI, "Failed to write element, hr %#lx.\n", hr);
- hr = write_element_string(writer, "", "j", "uri", NULL); + hr = IXmlWriter_WriteElementString(writer, L"", L"j", L"uri", NULL); ok(hr == S_OK, "Failed to write element, hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -1143,7 +1061,7 @@ static void test_WriteElementString(void) hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "Failed to start document, hr %#lx.\n", hr);
- hr = write_element_string(writer, element_string_tests[i].prefix, element_string_tests[i].local, + hr = IXmlWriter_WriteElementString(writer, element_string_tests[i].prefix, element_string_tests[i].local, element_string_tests[i].uri, element_string_tests[i].value); ok(hr == element_string_tests[i].hr, "%u: unexpected hr %#lx.\n", i, hr);
@@ -1180,10 +1098,10 @@ static void test_WriteEndElement(void)
stream = writer_set_output(writer);
- hr = write_start_element(writer, NULL, "a", NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_start_element(writer, NULL, "b", NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"b", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEndElement(writer); @@ -1203,8 +1121,6 @@ static void test_WriteEndElement(void)
static void test_writeenddocument(void) { - static const WCHAR aW[] = {'a',0}; - static const WCHAR bW[] = {'b',0}; IXmlWriter *writer; IStream *stream; HGLOBAL hglobal; @@ -1229,16 +1145,16 @@ static void test_writeenddocument(void) hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_SetOutput(writer, (IUnknown*)stream); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, bW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"b", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEndDocument(writer); @@ -1262,9 +1178,6 @@ static void test_writeenddocument(void)
static void test_WriteComment(void) { - static const WCHAR closeW[] = {'-','-','>',0}; - static const WCHAR aW[] = {'a',0}; - static const WCHAR bW[] = {'b',0}; IXmlWriter *writer; IStream *stream; HRESULT hr; @@ -1274,7 +1187,7 @@ static void test_WriteComment(void)
writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
- hr = IXmlWriter_WriteComment(writer, aW); + hr = IXmlWriter_WriteComment(writer, L"a"); ok(hr == E_UNEXPECTED, "Unexpected hr %#lx.\n", hr);
stream = writer_set_output(writer); @@ -1282,19 +1195,19 @@ static void test_WriteComment(void) hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteComment(writer, aW); + hr = IXmlWriter_WriteComment(writer, L"a"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, bW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"b", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteComment(writer, aW); + hr = IXmlWriter_WriteComment(writer, L"a"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteComment(writer, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteComment(writer, closeW); + hr = IXmlWriter_WriteComment(writer, L"-->"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -1308,10 +1221,6 @@ static void test_WriteComment(void)
static void test_WriteCData(void) { - static const WCHAR closeW[] = {']',']','>',0}; - static const WCHAR close2W[] = {'a',']',']','>','b',0}; - static const WCHAR aW[] = {'a',0}; - static const WCHAR bW[] = {'b',0}; IXmlWriter *writer; IStream *stream; HRESULT hr; @@ -1321,24 +1230,24 @@ static void test_WriteCData(void)
writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
- hr = IXmlWriter_WriteCData(writer, aW); + hr = IXmlWriter_WriteCData(writer, L"a"); ok(hr == E_UNEXPECTED, "Unexpected hr %#lx.\n", hr);
stream = writer_set_output(writer);
- hr = IXmlWriter_WriteStartElement(writer, NULL, bW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"b", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteCData(writer, aW); + hr = IXmlWriter_WriteCData(writer, L"a"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteCData(writer, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteCData(writer, closeW); + hr = IXmlWriter_WriteCData(writer, L"]]>"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteCData(writer, close2W); + hr = IXmlWriter_WriteCData(writer, L"a]]>b"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -1359,8 +1268,7 @@ static void test_WriteCData(void)
static void test_WriteRaw(void) { - static const WCHAR rawW[] = {'a','<',':',0}; - static const WCHAR aW[] = {'a',0}; + static const WCHAR rawW[] = L"a<:"; IXmlWriter *writer; IStream *stream; HRESULT hr; @@ -1391,7 +1299,7 @@ static void test_WriteRaw(void) hr = IXmlWriter_WriteRaw(writer, rawW); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteElementString(writer, NULL, aW, NULL, aW); + hr = IXmlWriter_WriteElementString(writer, NULL, L"a", NULL, L"a"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes); @@ -1417,7 +1325,6 @@ static void test_WriteRaw(void)
static void test_writer_state(void) { - static const WCHAR aW[] = {'a',0}; IXmlWriter *writer; IStream *stream; HRESULT hr; @@ -1440,7 +1347,7 @@ static void test_writer_state(void) /* WriteAttributeString */ stream = writer_set_output(writer);
- hr = IXmlWriter_WriteAttributeString(writer, NULL, aW, NULL, aW); + hr = IXmlWriter_WriteAttributeString(writer, NULL, L"a", NULL, L"a"); ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr);
check_writer_state(writer, WR_E_INVALIDACTION); @@ -1467,7 +1374,7 @@ static void test_writer_state(void) /* WriteCData */ stream = writer_set_output(writer);
- hr = IXmlWriter_WriteCData(writer, aW); + hr = IXmlWriter_WriteCData(writer, L"a"); ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr);
check_writer_state(writer, WR_E_INVALIDACTION); @@ -1476,7 +1383,7 @@ static void test_writer_state(void) /* WriteName */ stream = writer_set_output(writer);
- hr = IXmlWriter_WriteName(writer, aW); + hr = IXmlWriter_WriteName(writer, L"a"); ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr);
check_writer_state(writer, WR_E_INVALIDACTION); @@ -1485,7 +1392,7 @@ static void test_writer_state(void) /* WriteNmToken */ stream = writer_set_output(writer);
- hr = IXmlWriter_WriteNmToken(writer, aW); + hr = IXmlWriter_WriteNmToken(writer, L"a"); ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr);
check_writer_state(writer, WR_E_INVALIDACTION); @@ -1494,7 +1401,7 @@ static void test_writer_state(void) /* WriteString */ stream = writer_set_output(writer);
- hr = IXmlWriter_WriteString(writer, aW); + hr = IXmlWriter_WriteString(writer, L"a"); ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr);
check_writer_state(writer, WR_E_INVALIDACTION); @@ -1505,9 +1412,6 @@ static void test_writer_state(void)
static void test_indentation(void) { - static const WCHAR commentW[] = {'c','o','m','m','e','n','t',0}; - static const WCHAR aW[] = {'a',0}; - static const WCHAR bW[] = {'b',0}; IXmlWriter *writer; IStream *stream; HRESULT hr; @@ -1523,13 +1427,13 @@ static void test_indentation(void) hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteComment(writer, commentW); + hr = IXmlWriter_WriteComment(writer, L"comment"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, bW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"b", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEndDocument(writer); @@ -1549,13 +1453,13 @@ static void test_indentation(void) /* WriteElementString */ stream = writer_set_output(writer);
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteElementString(writer, NULL, bW, NULL, NULL); + hr = IXmlWriter_WriteElementString(writer, NULL, L"b", NULL, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteElementString(writer, NULL, bW, NULL, NULL); + hr = IXmlWriter_WriteElementString(writer, NULL, L"b", NULL, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEndElement(writer); @@ -1575,35 +1479,14 @@ 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); - - free(prefixW); - free(localW); - free(uriW); - free(valueW); - - return hr; -} - static void test_WriteAttributeString(void) { static const struct { - const char *prefix; - const char *local; - const char *uri; - const char *value; + const WCHAR *prefix; + const WCHAR *local; + const WCHAR *uri; + const WCHAR *value; const char *output; const char *output_partial; HRESULT hr; @@ -1613,62 +1496,62 @@ static void test_WriteAttributeString(void) } attribute_tests[] = { - { NULL, "a", NULL, "b", "<e a="b" />", "<e a="b"" }, - { "", "a", NULL, "b", "<e a="b" />", "<e a="b"" }, - { NULL, "a", "", "b", "<e a="b" />", "<e a="b"" }, - { "", "a", "", "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"" }, - { "xmlns", "a", "", "uri", "<e xmlns:a="uri" />", "<e xmlns:a="uri"" }, - { "prefix", "xmlns", "uri", "value", "<e prefix:xmlns="value" xmlns:prefix="uri" />", "<e prefix:xmlns="value"" }, - { "prefix", "xmlns", "uri", NULL, "<e prefix:xmlns="" xmlns:prefix="uri" />", "<e prefix:xmlns=""" }, - { "prefix", "xmlns", "uri", "", "<e prefix:xmlns="" xmlns:prefix="uri" />", "<e prefix:xmlns=""" }, - { "prefix", "xmlns", NULL, "uri", "<e xmlns="uri" />", "<e xmlns="uri"" }, - { "prefix", "xmlns", "", "uri", "<e xmlns="uri" />", "<e xmlns="uri"" }, - { "xml", "space", NULL, "preserve", "<e xml:space="preserve" />", "<e xml:space="preserve"" }, - { "xml", "space", "", "preserve", "<e xml:space="preserve" />", "<e xml:space="preserve"" }, - { "xml", "space", NULL, "default", "<e xml:space="default" />", "<e xml:space="default"" }, - { "xml", "space", "", "default", "<e xml:space="default" />", "<e xml:space="default"" }, - { "xml", "a", NULL, "value", "<e xml:a="value" />", "<e xml:a="value"" }, - { "xml", "a", "", "value", "<e xml:a="value" />", "<e xml:a="value"" }, + { NULL, L"a", NULL, L"b", "<e a="b" />", "<e a="b"" }, + { L"", L"a", NULL, L"b", "<e a="b" />", "<e a="b"" }, + { NULL, L"a", L"", L"b", "<e a="b" />", "<e a="b"" }, + { L"", L"a", L"", L"b", "<e a="b" />", "<e a="b"" }, + { L"prefix", L"local", L"uri", L"b", "<e prefix:local="b" xmlns:prefix="uri" />", "<e prefix:local="b"" }, + { NULL, L"a", L"http://www.w3.org/2000/xmlns/", L"defuri", "<e xmlns:a="defuri" />", "<e xmlns:a="defuri"" }, + { L"xmlns", L"a", NULL, L"uri", "<e xmlns:a="uri" />", "<e xmlns:a="uri"" }, + { L"xmlns", L"a", L"", L"uri", "<e xmlns:a="uri" />", "<e xmlns:a="uri"" }, + { L"prefix", L"xmlns", L"uri", L"value", "<e prefix:xmlns="value" xmlns:prefix="uri" />", "<e prefix:xmlns="value"" }, + { L"prefix", L"xmlns", L"uri", NULL, "<e prefix:xmlns="" xmlns:prefix="uri" />", "<e prefix:xmlns=""" }, + { L"prefix", L"xmlns", L"uri", L"", "<e prefix:xmlns="" xmlns:prefix="uri" />", "<e prefix:xmlns=""" }, + { L"prefix", L"xmlns", NULL, L"uri", "<e xmlns="uri" />", "<e xmlns="uri"" }, + { L"prefix", L"xmlns", L"", L"uri", "<e xmlns="uri" />", "<e xmlns="uri"" }, + { L"xml", L"space", NULL, L"preserve", "<e xml:space="preserve" />", "<e xml:space="preserve"" }, + { L"xml", L"space", L"", L"preserve", "<e xml:space="preserve" />", "<e xml:space="preserve"" }, + { L"xml", L"space", NULL, L"default", "<e xml:space="default" />", "<e xml:space="default"" }, + { L"xml", L"space", L"", L"default", "<e xml:space="default" />", "<e xml:space="default"" }, + { L"xml", L"a", NULL, L"value", "<e xml:a="value" />", "<e xml:a="value"" }, + { L"xml", L"a", L"", L"value", "<e xml:a="value" />", "<e xml:a="value"" },
/* Autogenerated prefix names. */ - { NULL, "a", "defuri", NULL, "<e p1:a="" xmlns:p1="defuri" />", "<e p1:a=""", S_OK, 1, 1, 1 }, - { NULL, "a", "defuri", "b", "<e p1:a="b" xmlns:p1="defuri" />", "<e p1:a="b"", S_OK, 1, 1, 1 }, - { "", "a", "defuri", NULL, "<e p1:a="" xmlns:p1="defuri" />", "<e p1:a=""", S_OK, 1, 1, 1 }, - { NULL, "a", "defuri", "", "<e p1:a="" xmlns:p1="defuri" />", "<e p1:a=""", S_OK, 1, 1, 1 }, - { "", "a", "defuri", "b", "<e p1:a="b" xmlns:p1="defuri" />", "<e p1:a="b"", S_OK, 1, 1, 1 }, + { NULL, L"a", L"defuri", NULL, "<e p1:a="" xmlns:p1="defuri" />", "<e p1:a=""", S_OK, 1, 1, 1 }, + { NULL, L"a", L"defuri", L"b", "<e p1:a="b" xmlns:p1="defuri" />", "<e p1:a="b"", S_OK, 1, 1, 1 }, + { L"", L"a", L"defuri", NULL, "<e p1:a="" xmlns:p1="defuri" />", "<e p1:a=""", S_OK, 1, 1, 1 }, + { NULL, L"a", L"defuri", L"", "<e p1:a="" xmlns:p1="defuri" />", "<e p1:a=""", S_OK, 1, 1, 1 }, + { L"", L"a", L"defuri", L"b", "<e p1:a="b" xmlns:p1="defuri" />", "<e p1:a="b"", S_OK, 1, 1, 1 },
/* Failing cases. */ - { NULL, NULL, "http://www.w3.org/2000/xmlns/", "defuri", "<e />", "<e", E_INVALIDARG }, - { "", "a", "http://www.w3.org/2000/xmlns/", "defuri", "<e />", "<e", WR_E_XMLNSPREFIXDECLARATION, 1, 1, 1 }, - { "", NULL, "http://www.w3.org/2000/xmlns/", "defuri", "<e />", "<e", E_INVALIDARG }, - { "", "", "http://www.w3.org/2000/xmlns/", "defuri", "<e />", "<e", E_INVALIDARG, 1, 1, 1 }, - { NULL, "", "http://www.w3.org/2000/xmlns/", "defuri", "<e />", "<e", E_INVALIDARG, 1, 1, 1 }, - { "prefix", "a", "http://www.w3.org/2000/xmlns/", "defuri", "<e />", "<e", WR_E_XMLNSURIDECLARATION, 1, 1, 1 }, - { "prefix", NULL, "http://www.w3.org/2000/xmlns/", "defuri", "<e />", "<e", E_INVALIDARG }, - { "prefix", NULL, NULL, "b", "<e />", "<e", E_INVALIDARG }, - { "prefix", NULL, "uri", NULL, "<e />", "<e", E_INVALIDARG }, - { "xml", NULL, NULL, "value", "<e />", "<e", E_INVALIDARG }, - { "xmlns", "a", "defuri", NULL, "<e />", "<e", WR_E_XMLNSPREFIXDECLARATION }, - { "xmlns", "a", "b", "uri", "<e />", "<e", WR_E_XMLNSPREFIXDECLARATION }, - { NULL, "xmlns", "uri", NULL, "<e />", "<e", WR_E_XMLNSPREFIXDECLARATION, 0, 0, 1 }, - { "xmlns", NULL, "uri", NULL, "<e />", "<e", WR_E_XMLNSPREFIXDECLARATION, 0, 0, 1 }, - { "pre:fix", "local", "uri", "b", "<e />", "<e", WC_E_NAMECHARACTER }, - { "pre:fix", NULL, "uri", "b", "<e />", "<e", E_INVALIDARG }, - { "prefix", "lo:cal", "uri", "b", "<e />", "<e", WC_E_NAMECHARACTER }, - { "xmlns", NULL, NULL, "uri", "<e />", "<e", WR_E_NSPREFIXDECLARED }, - { "xmlns", NULL, "", "uri", "<e />", "<e", WR_E_NSPREFIXDECLARED }, - { "xmlns", "", NULL, "uri", "<e />", "<e", WR_E_NSPREFIXDECLARED }, - { "xmlns", "", "", "uri", "<e />", "<e", WR_E_NSPREFIXDECLARED }, - { "xml", "space", "", "value", "<e />", "<e", WR_E_INVALIDXMLSPACE }, - { "xml", "space", NULL, "value", "<e />", "<e", WR_E_INVALIDXMLSPACE }, - { "xml", "a", "uri", "value", "<e />", "<e", WR_E_XMLPREFIXDECLARATION }, - { "xml", "space", NULL, "preServe", "<e />", "<e", WR_E_INVALIDXMLSPACE }, - { "xml", "space", NULL, "defAult", "<e />", "<e", WR_E_INVALIDXMLSPACE }, - { "xml", "space", NULL, NULL, "<e />", "<e", WR_E_INVALIDXMLSPACE }, - { "xml", "space", NULL, "", "<e />", "<e", WR_E_INVALIDXMLSPACE }, + { NULL, NULL, L"http://www.w3.org/2000/xmlns/", L"defuri", "<e />", "<e", E_INVALIDARG }, + { L"", L"a", L"http://www.w3.org/2000/xmlns/", L"defuri", "<e />", "<e", WR_E_XMLNSPREFIXDECLARATION, 1, 1, 1 }, + { L"", NULL, L"http://www.w3.org/2000/xmlns/", L"defuri", "<e />", "<e", E_INVALIDARG }, + { L"", L"", L"http://www.w3.org/2000/xmlns/", L"defuri", "<e />", "<e", E_INVALIDARG, 1, 1, 1 }, + { NULL, L"", L"http://www.w3.org/2000/xmlns/", L"defuri", "<e />", "<e", E_INVALIDARG, 1, 1, 1 }, + { L"prefix", L"a", L"http://www.w3.org/2000/xmlns/", L"defuri", "<e />", "<e", WR_E_XMLNSURIDECLARATION, 1, 1, 1 }, + { L"prefix", NULL, L"http://www.w3.org/2000/xmlns/", L"defuri", "<e />", "<e", E_INVALIDARG }, + { L"prefix", NULL, NULL, L"b", "<e />", "<e", E_INVALIDARG }, + { L"prefix", NULL, L"uri", NULL, "<e />", "<e", E_INVALIDARG }, + { L"xml", NULL, NULL, L"value", "<e />", "<e", E_INVALIDARG }, + { L"xmlns", L"a", L"defuri", NULL, "<e />", "<e", WR_E_XMLNSPREFIXDECLARATION }, + { L"xmlns", L"a", L"b", L"uri", "<e />", "<e", WR_E_XMLNSPREFIXDECLARATION }, + { NULL, L"xmlns", L"uri", NULL, "<e />", "<e", WR_E_XMLNSPREFIXDECLARATION, 0, 0, 1 }, + { L"xmlns", NULL, L"uri", NULL, "<e />", "<e", WR_E_XMLNSPREFIXDECLARATION, 0, 0, 1 }, + { L"pre:fix", L"local", L"uri", L"b", "<e />", "<e", WC_E_NAMECHARACTER }, + { L"pre:fix", NULL, L"uri", L"b", "<e />", "<e", E_INVALIDARG }, + { L"prefix", L"lo:cal", L"uri", L"b", "<e />", "<e", WC_E_NAMECHARACTER }, + { L"xmlns", NULL, NULL, L"uri", "<e />", "<e", WR_E_NSPREFIXDECLARED }, + { L"xmlns", NULL, L"", L"uri", "<e />", "<e", WR_E_NSPREFIXDECLARED }, + { L"xmlns", L"", NULL, L"uri", "<e />", "<e", WR_E_NSPREFIXDECLARED }, + { L"xmlns", L"", L"", L"uri", "<e />", "<e", WR_E_NSPREFIXDECLARED }, + { L"xml", L"space", L"", L"value", "<e />", "<e", WR_E_INVALIDXMLSPACE }, + { L"xml", L"space", NULL, L"value", "<e />", "<e", WR_E_INVALIDXMLSPACE }, + { L"xml", L"a", L"uri", L"value", "<e />", "<e", WR_E_XMLPREFIXDECLARATION }, + { L"xml", L"space", NULL, L"preServe", "<e />", "<e", WR_E_INVALIDXMLSPACE }, + { L"xml", L"space", NULL, L"defAult", "<e />", "<e", WR_E_INVALIDXMLSPACE }, + { L"xml", L"space", NULL, NULL, "<e />", "<e", WR_E_INVALIDXMLSPACE }, + { L"xml", L"space", NULL, L"", "<e />", "<e", WR_E_INVALIDXMLSPACE }, };
IXmlWriter *writer; @@ -1688,10 +1571,10 @@ static void test_WriteAttributeString(void) hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "Failed to start document, hr %#lx.\n", hr);
- hr = write_start_element(writer, NULL, "e", NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"e", NULL); ok(hr == S_OK, "Failed to start element, hr %#lx.\n", hr);
- hr = write_attribute_string(writer, attribute_tests[i].prefix, attribute_tests[i].local, + hr = IXmlWriter_WriteAttributeString(writer, attribute_tests[i].prefix, attribute_tests[i].local, attribute_tests[i].uri, attribute_tests[i].value); todo_wine_if(attribute_tests[i].todo_hr) ok(hr == attribute_tests[i].hr, "%u: unexpected hr %#lx, expected %#lx.\n", i, hr, attribute_tests[i].hr); @@ -1717,32 +1600,32 @@ static void test_WriteAttributeString(void) hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_start_element(writer, "p", "a", "outeruri"); + hr = IXmlWriter_WriteStartElement(writer, L"p", L"a", L"outeruri"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_attribute_string(writer, "prefix", "local", "uri", "b"); + hr = IXmlWriter_WriteAttributeString(writer, L"prefix", L"local", L"uri", L"b"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_attribute_string(writer, NULL, "a", NULL, "b"); + hr = IXmlWriter_WriteAttributeString(writer, NULL, L"a", NULL, L"b"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_attribute_string(writer, "xmlns", "prefix", NULL, "uri"); + hr = IXmlWriter_WriteAttributeString(writer, L"xmlns", L"prefix", NULL, L"uri"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_attribute_string(writer, "p", "attr", NULL, "value"); + hr = IXmlWriter_WriteAttributeString(writer, L"p", L"attr", NULL, L"value"); ok(hr == S_OK, "Failed to write attribute string, hr %#lx.\n", hr);
- hr = write_attribute_string(writer, "prefix", "local", NULL, "b"); + hr = IXmlWriter_WriteAttributeString(writer, L"prefix", L"local", NULL, L"b"); todo_wine ok(hr == WR_E_DUPLICATEATTRIBUTE, "Unexpected hr %#lx.\n", hr);
- hr = write_start_element(writer, NULL, "b", NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"b", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_attribute_string(writer, NULL, "attr2", "outeruri", "value"); + hr = IXmlWriter_WriteAttributeString(writer, NULL, L"attr2", L"outeruri", L"value"); ok(hr == S_OK, "Failed to write attribute string, hr %#lx.\n", hr);
- hr = write_attribute_string(writer, "pr", "attr3", "outeruri", "value"); + hr = IXmlWriter_WriteAttributeString(writer, L"pr", L"attr3", L"outeruri", L"value"); ok(hr == S_OK, "Failed to write attribute string, hr %#lx.\n", hr);
hr = IXmlWriter_WriteEndDocument(writer); @@ -1764,13 +1647,13 @@ static void test_WriteAttributeString(void) hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_start_element(writer, NULL, "e", NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"e", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_attribute_string(writer, "xmlns", "prefix", NULL, "uri"); + hr = IXmlWriter_WriteAttributeString(writer, L"xmlns", L"prefix", NULL, L"uri"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_attribute_string(writer, "prefix", "attr", NULL, "value"); + hr = IXmlWriter_WriteAttributeString(writer, L"prefix", L"attr", NULL, L"value"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEndDocument(writer); @@ -1789,7 +1672,6 @@ static void test_WriteAttributeString(void)
static void test_WriteFullEndElement(void) { - static const WCHAR aW[] = {'a',0}; IXmlWriter *writer; IStream *stream; HRESULT hr; @@ -1806,7 +1688,7 @@ static void test_WriteFullEndElement(void) hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteFullEndElement(writer); @@ -1831,10 +1713,10 @@ static void test_WriteFullEndElement(void) hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteFullEndElement(writer); @@ -1857,7 +1739,6 @@ static void test_WriteFullEndElement(void)
static void test_WriteCharEntity(void) { - static const WCHAR aW[] = {'a',0}; IXmlWriter *writer; IStream *stream; HRESULT hr; @@ -1873,13 +1754,13 @@ static void test_WriteCharEntity(void) hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteCharEntity(writer, 0x100); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEndDocument(writer); @@ -1906,31 +1787,31 @@ static void test_WriteString(void)
writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
- hr = write_string(writer, "a"); + hr = IXmlWriter_WriteString(writer, L"a"); ok(hr == E_UNEXPECTED, "Unexpected hr %#lx.\n", hr);
- hr = write_string(writer, NULL); + hr = IXmlWriter_WriteString(writer, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_string(writer, ""); + hr = IXmlWriter_WriteString(writer, L""); ok(hr == E_UNEXPECTED, "Unexpected hr %#lx.\n", hr);
stream = writer_set_output(writer);
- hr = write_start_element(writer, NULL, "b", NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"b", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_string(writer, NULL); + hr = IXmlWriter_WriteString(writer, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_string(writer, ""); + hr = IXmlWriter_WriteString(writer, L""); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_string(writer, "a"); + hr = IXmlWriter_WriteString(writer, L"a"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
/* WriteString automatically escapes markup characters */ - hr = write_string(writer, "<&">="); + hr = IXmlWriter_WriteString(writer, L"<&">="); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -1942,10 +1823,10 @@ static void test_WriteString(void)
stream = writer_set_output(writer);
- hr = write_start_element(writer, NULL, "b", NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"b", NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = write_string(writer, NULL); + hr = IXmlWriter_WriteString(writer, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -1954,7 +1835,7 @@ static void test_WriteString(void) CHECK_OUTPUT(stream, "<b");
- hr = write_string(writer, ""); + hr = IXmlWriter_WriteString(writer, L""); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -1974,13 +1855,13 @@ static void test_WriteString(void)
writer_set_property(writer, XmlWriterProperty_Indent);
- hr = write_start_element(writer, NULL, "a", NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == S_OK, "Failed to start element, hr %#lx.\n", hr);
- hr = write_start_element(writer, NULL, "b", NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"b", NULL); ok(hr == S_OK, "Failed to start element, hr %#lx.\n", hr);
- hr = write_string(writer, "text"); + hr = IXmlWriter_WriteString(writer, L"text"); ok(hr == S_OK, "Failed to write a string, hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -2015,10 +1896,10 @@ static void test_WriteString(void)
stream = writer_set_output(writer);
- hr = write_start_element(writer, NULL, "a", NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); ok(hr == S_OK, "Failed to start element, hr %#lx.\n", hr);
- hr = write_start_element(writer, NULL, "b", NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"b", NULL); ok(hr == S_OK, "Failed to start element, hr %#lx.\n", hr);
hr = IXmlWriter_WriteEndElement(writer); @@ -2031,10 +1912,10 @@ static void test_WriteString(void) "<a>\r\n" " <b />");
- hr = write_start_element(writer, NULL, "c", NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"c", NULL); ok(hr == S_OK, "Failed to start element, hr %#lx.\n", hr);
- hr = write_attribute_string(writer, NULL, "attr", NULL, "value"); + hr = IXmlWriter_WriteAttributeString(writer, NULL, L"attr", NULL, L"value"); ok(hr == S_OK, "Failed to write attribute string, hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -2045,7 +1926,7 @@ static void test_WriteString(void) " <b />\r\n" " <c attr="value"");
- hr = write_string(writer, "text"); + hr = IXmlWriter_WriteString(writer, L"text"); ok(hr == S_OK, "Failed to write a string, hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -2067,10 +1948,10 @@ static void test_WriteString(void) " <b />\r\n" " <c attr="value">text</c>");
- hr = write_start_element(writer, NULL, "d", NULL); + hr = IXmlWriter_WriteStartElement(writer, NULL, L"d", NULL); ok(hr == S_OK, "Failed to start element, hr %#lx.\n", hr);
- hr = write_string(writer, ""); + hr = IXmlWriter_WriteString(writer, L""); ok(hr == S_OK, "Failed to write a string, hr %#lx.\n", hr);
hr = IXmlWriter_WriteEndElement(writer); @@ -2102,60 +1983,37 @@ static void test_WriteString(void) IStream_Release(stream); }
-static HRESULT write_doctype(IXmlWriter *writer, const char *name, const char *pubid, const char *sysid, - const char *subset) -{ - WCHAR *nameW, *pubidW, *sysidW, *subsetW; - HRESULT hr; - - nameW = strdupAtoW(name); - pubidW = strdupAtoW(pubid); - sysidW = strdupAtoW(sysid); - subsetW = strdupAtoW(subset); - - hr = IXmlWriter_WriteDocType(writer, nameW, pubidW, sysidW, subsetW); - - free(nameW); - free(pubidW); - free(sysidW); - free(subsetW); - - return hr; -} - static void test_WriteDocType(void) { static const struct { - const char *name; - const char *pubid; - const char *sysid; - const char *subset; + const WCHAR *name; + const WCHAR *pubid; + const WCHAR *sysid; + const WCHAR *subset; const char *output; } doctype_tests[] = { - { "a", "", NULL, NULL, "<!DOCTYPE a PUBLIC \"\" \"\">" }, - { "a", NULL, NULL, NULL, "<!DOCTYPE a>" }, - { "a", NULL, "", NULL, "<!DOCTYPE a SYSTEM \"\">" }, - { "a", "", "", NULL, "<!DOCTYPE a PUBLIC \"\" \"\">" }, - { "a", "pubid", "", NULL, "<!DOCTYPE a PUBLIC \"pubid\" \"\">" }, - { "a", "pubid", NULL, NULL, "<!DOCTYPE a PUBLIC \"pubid\" \"\">" }, - { "a", "", "sysid", NULL, "<!DOCTYPE a PUBLIC \"\" \"sysid\">" }, - { "a", NULL, NULL, "", "<!DOCTYPE a []>" }, - { "a", NULL, NULL, "subset", "<!DOCTYPE a [subset]>" }, - { "a", "", NULL, "subset", "<!DOCTYPE a PUBLIC \"\" \"\" [subset]>" }, - { "a", NULL, "", "subset", "<!DOCTYPE a SYSTEM \"\" [subset]>" }, - { "a", "", "", "subset", "<!DOCTYPE a PUBLIC \"\" \"\" [subset]>" }, - { "a", "pubid", NULL, "subset", "<!DOCTYPE a PUBLIC \"pubid\" \"\" [subset]>" }, - { "a", "pubid", "", "subset", "<!DOCTYPE a PUBLIC \"pubid\" \"\" [subset]>" }, - { "a", NULL, "sysid", "subset", "<!DOCTYPE a SYSTEM \"sysid\" [subset]>" }, - { "a", "", "sysid", "subset", "<!DOCTYPE a PUBLIC \"\" \"sysid\" [subset]>" }, - { "a", "pubid", "sysid", "subset", "<!DOCTYPE a PUBLIC \"pubid\" \"sysid\" [subset]>" }, + { L"a", L"", NULL, NULL, "<!DOCTYPE a PUBLIC \"\" \"\">" }, + { L"a", NULL, NULL, NULL, "<!DOCTYPE a>" }, + { L"a", NULL, L"", NULL, "<!DOCTYPE a SYSTEM \"\">" }, + { L"a", L"", L"", NULL, "<!DOCTYPE a PUBLIC \"\" \"\">" }, + { L"a", L"pubid", L"", NULL, "<!DOCTYPE a PUBLIC \"pubid\" \"\">" }, + { L"a", L"pubid", NULL, NULL, "<!DOCTYPE a PUBLIC \"pubid\" \"\">" }, + { L"a", L"", L"sysid", NULL, "<!DOCTYPE a PUBLIC \"\" \"sysid\">" }, + { L"a", NULL, NULL, L"", "<!DOCTYPE a []>" }, + { L"a", NULL, NULL, L"subset", "<!DOCTYPE a [subset]>" }, + { L"a", L"", NULL, L"subset", "<!DOCTYPE a PUBLIC \"\" \"\" [subset]>" }, + { L"a", NULL, L"", L"subset", "<!DOCTYPE a SYSTEM \"\" [subset]>" }, + { L"a", L"", L"", L"subset", "<!DOCTYPE a PUBLIC \"\" \"\" [subset]>" }, + { L"a", L"pubid", NULL, L"subset", "<!DOCTYPE a PUBLIC \"pubid\" \"\" [subset]>" }, + { L"a", L"pubid", L"", L"subset", "<!DOCTYPE a PUBLIC \"pubid\" \"\" [subset]>" }, + { L"a", NULL, L"sysid", L"subset", "<!DOCTYPE a SYSTEM \"sysid\" [subset]>" }, + { L"a", L"", L"sysid", L"subset", "<!DOCTYPE a PUBLIC \"\" \"sysid\" [subset]>" }, + { L"a", L"pubid", L"sysid", L"subset", "<!DOCTYPE a PUBLIC \"pubid\" \"sysid\" [subset]>" }, }; static const WCHAR pubidW[] = {'p',0x100,'i','d',0}; - static const WCHAR nameW[] = {'-','a',0}; - static const WCHAR emptyW[] = { 0 }; IXmlWriter *writer; IStream *stream; unsigned int i; @@ -2169,15 +2027,15 @@ static void test_WriteDocType(void) hr = IXmlWriter_WriteDocType(writer, NULL, NULL, NULL, NULL); ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteDocType(writer, emptyW, NULL, NULL, NULL); + hr = IXmlWriter_WriteDocType(writer, L"", NULL, NULL, NULL); ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
/* Name validation. */ - hr = IXmlWriter_WriteDocType(writer, nameW, NULL, NULL, NULL); + hr = IXmlWriter_WriteDocType(writer, L"-a", NULL, NULL, NULL); ok(hr == WC_E_NAMECHARACTER, "Unexpected hr %#lx.\n", hr);
/* Pubid validation. */ - hr = IXmlWriter_WriteDocType(writer, aW, pubidW, NULL, NULL); + hr = IXmlWriter_WriteDocType(writer, L"a", pubidW, NULL, NULL); ok(hr == WC_E_PUBLICID, "Unexpected hr %#lx.\n", hr);
IStream_Release(stream); @@ -2186,7 +2044,7 @@ static void test_WriteDocType(void) { stream = writer_set_output(writer);
- hr = write_doctype(writer, doctype_tests[i].name, doctype_tests[i].pubid, doctype_tests[i].sysid, + hr = IXmlWriter_WriteDocType(writer, doctype_tests[i].name, doctype_tests[i].pubid, doctype_tests[i].sysid, doctype_tests[i].subset); ok(hr == S_OK, "%u: failed to write doctype, hr %#lx.\n", i, hr);
@@ -2195,7 +2053,7 @@ static void test_WriteDocType(void)
CHECK_OUTPUT(stream, doctype_tests[i].output);
- hr = write_doctype(writer, doctype_tests[i].name, doctype_tests[i].pubid, doctype_tests[i].sysid, + hr = IXmlWriter_WriteDocType(writer, doctype_tests[i].name, doctype_tests[i].pubid, doctype_tests[i].sysid, doctype_tests[i].subset); ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr);