xmllite/tests: Test complete writer output for UTF-16 case.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2019-02-13 10:47:46 +03:00 committed by Alexandre Julliard
parent 8d2e59edaa
commit 9d4c73f4c1
1 changed files with 12 additions and 25 deletions

View File

@ -49,16 +49,18 @@ static void check_output_raw(IStream *stream, const void *expected, SIZE_T size,
SIZE_T content_size; SIZE_T content_size;
HGLOBAL hglobal; HGLOBAL hglobal;
HRESULT hr; HRESULT hr;
char *ptr; WCHAR *ptr;
hr = GetHGlobalFromStream(stream, &hglobal); hr = GetHGlobalFromStream(stream, &hglobal);
ok_(__FILE__, line)(hr == S_OK, "Failed to get the stream handle, hr %#x.\n", hr); ok_(__FILE__, line)(hr == S_OK, "Failed to get the stream handle, hr %#x.\n", hr);
content_size = GlobalSize(hglobal); content_size = GlobalSize(hglobal);
ok_(__FILE__, line)(size <= content_size, "Unexpected test output size.\n"); ok_(__FILE__, line)(size == content_size, "Unexpected test output size %ld.\n", content_size);
ptr = GlobalLock(hglobal); ptr = GlobalLock(hglobal);
if (size <= content_size) if (size <= content_size)
ok_(__FILE__, line)(!memcmp(expected, ptr, size), "Unexpected output content.\n"); ok_(__FILE__, line)(!memcmp(expected, ptr, size), "Unexpected output content.\n");
if (size != content_size && *ptr == 0xfeff)
ok_(__FILE__, line)(0, "Content: %s.\n", wine_dbgstr_wn(ptr, content_size / sizeof(WCHAR)));
GlobalUnlock(hglobal); GlobalUnlock(hglobal);
} }
@ -719,11 +721,14 @@ static void test_omitxmldeclaration(void)
static void test_bom(void) 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 versionW[] = {'v','e','r','s','i','o','n','=','"','1','.','0','"',0};
static const WCHAR utf16W[] = {'u','t','f','-','1','6',0}; static const WCHAR utf16W[] = {'u','t','f','-','1','6',0};
static const WCHAR xmlW[] = {'x','m','l',0}; static const WCHAR xmlW[] = {'x','m','l',0};
static const WCHAR bomW[] = {0xfeff};
IXmlWriterOutput *output; IXmlWriterOutput *output;
unsigned char *ptr;
IXmlWriter *writer; IXmlWriter *writer;
IStream *stream; IStream *stream;
HGLOBAL hglobal; HGLOBAL hglobal;
@ -750,12 +755,7 @@ static void test_bom(void)
hr = IXmlWriter_Flush(writer); hr = IXmlWriter_Flush(writer);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
hr = GetHGlobalFromStream(stream, &hglobal); CHECK_OUTPUT_RAW(stream, bomW, sizeof(bomW));
ok(hr == S_OK, "got 0x%08x\n", hr);
ptr = GlobalLock(hglobal);
ok(ptr[0] == 0xff && ptr[1] == 0xfe, "got %x,%x\n", ptr[0], ptr[1]);
GlobalUnlock(hglobal);
IStream_Release(stream); IStream_Release(stream);
IUnknown_Release(output); IUnknown_Release(output);
@ -776,12 +776,7 @@ static void test_bom(void)
hr = IXmlWriter_Flush(writer); hr = IXmlWriter_Flush(writer);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
hr = GetHGlobalFromStream(stream, &hglobal); CHECK_OUTPUT_RAW(stream, piW, sizeof(piW));
ok(hr == S_OK, "got 0x%08x\n", hr);
ptr = GlobalLock(hglobal);
ok(ptr[0] == 0xff && ptr[1] == 0xfe, "got %x,%x\n", ptr[0], ptr[1]);
GlobalUnlock(hglobal);
IUnknown_Release(output); IUnknown_Release(output);
IStream_Release(stream); IStream_Release(stream);
@ -802,12 +797,7 @@ static void test_bom(void)
hr = IXmlWriter_Flush(writer); hr = IXmlWriter_Flush(writer);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
hr = GetHGlobalFromStream(stream, &hglobal); CHECK_OUTPUT_RAW(stream, aopenW, sizeof(aopenW));
ok(hr == S_OK, "got 0x%08x\n", hr);
ptr = GlobalLock(hglobal);
ok(ptr[0] == 0xff && ptr[1] == 0xfe, "got %x,%x\n", ptr[0], ptr[1]);
GlobalUnlock(hglobal);
IUnknown_Release(output); IUnknown_Release(output);
IStream_Release(stream); IStream_Release(stream);
@ -833,10 +823,7 @@ static void test_bom(void)
hr = GetHGlobalFromStream(stream, &hglobal); hr = GetHGlobalFromStream(stream, &hglobal);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
ptr = GlobalLock(hglobal); CHECK_OUTPUT_RAW(stream, afullW, sizeof(afullW));
ok(ptr[0] == 0xff && ptr[1] == 0xfe && ptr[2] == '<', "Unexpected output: %#x,%#x,%#x\n",
ptr[0], ptr[1], ptr[2]);
GlobalUnlock(hglobal);
IUnknown_Release(output); IUnknown_Release(output);
IStream_Release(stream); IStream_Release(stream);