From 13faf34b07c7cc4953aa2ce868c5b0083b80184f Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Mon, 4 Jul 2016 11:35:37 +0200 Subject: [PATCH] webservices/tests: Add tests for WsWriteXmlBuffer. Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/webservices/tests/writer.c | 58 +++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/dlls/webservices/tests/writer.c b/dlls/webservices/tests/writer.c index 5314bc80209..f4336f6ac9c 100644 --- a/dlls/webservices/tests/writer.c +++ b/dlls/webservices/tests/writer.c @@ -1579,6 +1579,63 @@ static void test_WsSetWriterPosition(void) WsFreeHeap( heap ); } +static void test_WsWriteXmlBuffer(void) +{ + WS_XML_STRING localname = {1, (BYTE *)"t"}, ns = {0, NULL}; + WS_XML_WRITER *writer1, *writer2; + WS_XML_BUFFER *buffer1, *buffer2; + WS_HEAP *heap; + HRESULT hr; + + hr = WsCreateHeap( 1 << 16, 0, NULL, 0, &heap, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsCreateXmlBuffer( NULL, NULL, 0, NULL, NULL ); + ok( hr == E_INVALIDARG, "got %08x\n", hr ); + + hr = WsCreateWriter( NULL, 0, &writer1, NULL ) ; + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsCreateXmlBuffer( heap, NULL, 0, NULL, NULL ); + ok( hr == E_INVALIDARG, "got %08x\n", hr ); + + hr = WsCreateXmlBuffer( heap, NULL, 0, &buffer1, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsSetOutputToBuffer( writer1, buffer1, NULL, 0, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsWriteStartElement( writer1, NULL, &localname, &ns, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsWriteEndElement( writer1, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + check_output_buffer( buffer1, "", __LINE__ ); + + hr = WsCreateWriter( NULL, 0, &writer2, NULL ) ; + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsCreateXmlBuffer( heap, NULL, 0, &buffer2, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsSetOutputToBuffer( writer2, buffer2, NULL, 0, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsWriteXmlBuffer( writer2, buffer1, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + check_output_buffer( buffer2, "", __LINE__ ); + + hr = WsMoveWriter( writer2, WS_MOVE_TO_PREVIOUS_ELEMENT, NULL, NULL ); + todo_wine ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsWriteXmlBuffer( writer2, buffer1, NULL ); + todo_wine ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr ); + + WsFreeWriter( writer1 ); + WsFreeWriter( writer2 ); + WsFreeHeap( heap ); +} + START_TEST(writer) { test_WsCreateWriter(); @@ -1600,4 +1657,5 @@ START_TEST(writer) test_WsMoveWriter(); test_WsGetWriterPosition(); test_WsSetWriterPosition(); + test_WsWriteXmlBuffer(); }