[XMLLITE_WINETEST]
[reactos.git] / rostests / winetests / xmllite / writer.c
1 /*
2 * XMLLite IXmlWriter tests
3 *
4 * Copyright 2011 (C) Alistair Leslie-Hughes
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20 #define COBJMACROS
21
22 #include <stdarg.h>
23 #include <stdio.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "ole2.h"
28 #include "xmllite.h"
29 #include "wine/test.h"
30
31 static HRESULT WINAPI (*pCreateXmlWriter)(REFIID riid, void **ppvObject, IMalloc *pMalloc);
32
33 static void test_writer_create(void)
34 {
35 HRESULT hr;
36 IXmlWriter *writer;
37
38 /* crashes native */
39 if (0)
40 {
41 pCreateXmlWriter(&IID_IXmlWriter, NULL, NULL);
42 pCreateXmlWriter(NULL, (LPVOID*)&writer, NULL);
43 }
44
45 hr = pCreateXmlWriter(&IID_IXmlWriter, (LPVOID*)&writer, NULL);
46 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
47 if(hr == S_OK)
48 {
49 IXmlWriter_Release(writer);
50 }
51 }
52
53 static BOOL init_pointers(void)
54 {
55 /* don't free module here, it's to be unloaded on exit */
56 HMODULE mod = LoadLibraryA("xmllite.dll");
57
58 if (!mod)
59 {
60 win_skip("xmllite library not available\n");
61 return FALSE;
62 }
63
64 #define MAKEFUNC(f) if (!(p##f = (void*)GetProcAddress(mod, #f))) return FALSE;
65 MAKEFUNC(CreateXmlWriter);
66 #undef MAKEFUNC
67
68 return TRUE;
69 }
70
71 START_TEST(writer)
72 {
73 HRESULT r;
74
75 r = CoInitialize( NULL );
76 ok( r == S_OK, "failed to init com\n");
77
78 if (!init_pointers())
79 {
80 CoUninitialize();
81 return;
82 }
83
84 test_writer_create();
85
86 CoUninitialize();
87 }