ReactOS 0.4.17-dev-966-gf06eace
reader.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "initguid.h"
#include "ole2.h"
#include "xmllite.h"
#include "wine/test.h"
Include dependency graph for reader.c:

Go to the source code of this file.

Classes

struct  input_iids_t
 
struct  _testinput
 
struct  test_entry
 
struct  nodes_test
 
struct  test_entry_empty
 

Macros

#define COBJMACROS
 
#define CONST_VTABLE
 
#define TEST_READER_POSITION(reader, line, pos)    test_reader_pos(reader, line, pos, ~0u, ~0u, __LINE__)
 
#define TEST_READER_POSITION2(reader, line, pos, line_broken, pos_broken)    test_reader_pos(reader, line, pos, line_broken, pos_broken, __LINE__)
 
#define ok_iids(got, exp, brk, todo)   ok_iids_(got, exp, brk, todo, __LINE__)
 
#define set_input_string(a, b)   _set_input_string(__LINE__,a,b);
 
#define read_node(a, b)   _read_node(__LINE__,a,b)
 
#define next_attribute(a)   _next_attribute(__LINE__,a)
 
#define move_to_element(a)   _move_to_element(__LINE__,a)
 
#define TEST_READER_STATE(reader, state)   test_read_state(reader, state, state, __LINE__)
 
#define TEST_READER_STATE2(reader, state, brk)   test_read_state(reader, state, brk, __LINE__)
 
#define reader_value(a, b)   _reader_value(__LINE__,a,b)
 
#define reader_name(a, b)   _reader_name(__LINE__,a,b)
 
#define reader_prefix(a, b)   _reader_prefix(__LINE__,a,b)
 
#define reader_namespace(a, b)   _reader_namespace(__LINE__,a,b)
 
#define reader_qname(a, b)   _reader_qname(a,b,__LINE__)
 
#define read_value_char(a, b)   _read_value_char(a,b,__LINE__)
 
#define TEST_DEPTH(reader, depth)   test_reader_depth(reader, depth, ~0u, __LINE__)
 
#define TEST_DEPTH2(reader, depth, brk)   test_reader_depth(reader, depth, brk, __LINE__)
 

Typedefs

typedef struct input_iids_t input_iids_t
 
typedef struct _testinput testinput
 

Functions

 DEFINE_GUID (IID_IXmlReaderInput, 0x0b3ccc9b, 0x9214, 0x428b, 0xa2, 0xae, 0xef, 0x3a, 0xa8, 0x71, 0xaf, 0xda)
 
static IStream * create_stream_on_data (const void *data, unsigned int size)
 
static void test_reader_pos (IXmlReader *reader, UINT line, UINT pos, UINT line_broken, UINT pos_broken, int _line_)
 
static void ok_iids_ (const input_iids_t *iids, const IID **expected, const IID **exp_broken, BOOL todo, int line)
 
static const char * state_to_str (XmlReadState state)
 
static const char * type_to_str (XmlNodeType type)
 
static void _set_input_string (unsigned line, IXmlReader *reader, const char *xml)
 
static void _read_node (unsigned line, IXmlReader *reader, XmlNodeType expected_type)
 
static void _next_attribute (unsigned line, IXmlReader *reader)
 
static void _move_to_element (unsigned line, IXmlReader *reader)
 
static void test_read_state (IXmlReader *reader, XmlReadState expected, XmlReadState exp_broken, int line)
 
static const WCHAR * _reader_value (unsigned line, IXmlReader *reader, const WCHAR *expect)
 
static const WCHAR * _reader_name (unsigned line, IXmlReader *reader, const WCHAR *expect)
 
static const WCHAR * _reader_prefix (unsigned line, IXmlReader *reader, const WCHAR *expect)
 
static const WCHAR * _reader_namespace (unsigned line, IXmlReader *reader, const WCHAR *expect)
 
static const WCHAR * _reader_qname (IXmlReader *reader, const WCHAR *expect, unsigned line)
 
static void _read_value_char (IXmlReader *reader, WCHAR expected_char, unsigned line)
 
static testinput * impl_from_IUnknown (IUnknown *iface)
 
static HRESULT WINAPI testinput_QueryInterface (IUnknown *iface, REFIID riid, void **ppvObj)
 
static ULONG WINAPI testinput_AddRef (IUnknown *iface)
 
static ULONG WINAPI testinput_Release (IUnknown *iface)
 
static HRESULT testinput_createinstance (void **ppObj)
 
static HRESULT WINAPI teststream_QueryInterface (ISequentialStream *iface, REFIID riid, void **obj)
 
static ULONG WINAPI teststream_AddRef (ISequentialStream *iface)
 
static ULONG WINAPI teststream_Release (ISequentialStream *iface)
 
static HRESULT WINAPI teststream_Read (ISequentialStream *iface, void *pv, ULONG cb, ULONG *pread)
 
static HRESULT WINAPI teststream_Write (ISequentialStream *iface, const void *pv, ULONG cb, ULONG *written)
 
static HRESULT WINAPI resolver_QI (IXmlResolver *iface, REFIID riid, void **obj)
 
static ULONG WINAPI resolver_AddRef (IXmlResolver *iface)
 
static ULONG WINAPI resolver_Release (IXmlResolver *iface)
 
static HRESULT WINAPI resolver_ResolveUri (IXmlResolver *iface, const WCHAR *base_uri, const WCHAR *public_id, const WCHAR *system_id, IUnknown **input)
 
static void test_reader_create (void)
 
static void test_readerinput (void)
 
static void test_reader_state (void)
 
static void test_reader_depth (IXmlReader *reader, UINT depth, UINT brk, int line)
 
static void test_read_xmldeclaration (void)
 
static void test_read_comment (void)
 
static void test_read_pi (void)
 
static void test_read_full (void)
 
static void test_read_public_dtd (void)
 
static void test_read_system_dtd (void)
 
static void test_read_element (void)
 
static void test_read_pending (void)
 
static void test_readvaluechunk (void)
 
static void test_read_cdata (void)
 
static void test_read_text (void)
 
static void test_isemptyelement (void)
 
static void test_read_attribute (void)
 
static void test_reader_properties (void)
 
static void test_prefix (void)
 
static void test_namespaceuri (void)
 
static void test_read_charref (void)
 
static void test_encoding_detection (void)
 
static void test_eof_state (IXmlReader *reader, BOOL eof)
 
static void test_endoffile (void)
 
static void test_max_element_depth (void)
 
static void test_reader_position (void)
 
static void test_string_pointers (void)
 
static void test_attribute_by_name (void)
 
 START_TEST (reader)
 

Variables

static const char xmldecl_full [] = "\xef\xbb\xbf<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
 
static const char xmldecl_short [] = "<?xml version=\"1.0\"?><RegistrationInfo/>"
 
static const IID * setinput_full []
 
static const IID * setinput_full_old []
 
static const IID * setinput_readerinput []
 
static const IID * empty_seq []
 
static input_iids_t input_iids
 
static const struct IUnknownVtbl testinput_vtbl
 
static int stream_readcall
 
static const ISequentialStreamVtbl teststreamvtbl
 
static const IXmlResolverVtbl resolvervtbl
 
static IXmlResolver testresolver = { &resolvervtbl }
 
static struct test_entry comment_tests []
 
static struct test_entry pi_tests []
 
static const char misc_test_xml []
 
static struct nodes_test misc_test
 
static const char test_public_dtd []
 
static const char test_system_dtd []
 
static struct test_entry element_tests []
 
static ISequentialStream teststream = { &teststreamvtbl }
 
static struct test_entry cdata_tests []
 
static struct test_entry text_tests []
 
static struct test_entry_empty empty_element_tests []
 
static struct test_entry attributes_tests []
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file reader.c.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 22 of file reader.c.

◆ move_to_element

#define move_to_element (   a)    _move_to_element(__LINE__,a)

Definition at line 238 of file reader.c.

◆ next_attribute

#define next_attribute (   a)    _next_attribute(__LINE__,a)

Definition at line 230 of file reader.c.

◆ ok_iids

#define ok_iids (   got,
  exp,
  brk,
  todo 
)    ok_iids_(got, exp, brk, todo, __LINE__)

Definition at line 133 of file reader.c.

◆ read_node

#define read_node (   a,
  b 
)    _read_node(__LINE__,a,b)

Definition at line 216 of file reader.c.

◆ read_value_char

#define read_value_char (   a,
  b 
)    _read_value_char(a,b,__LINE__)

Definition at line 337 of file reader.c.

◆ reader_name

#define reader_name (   a,
  b 
)    _reader_name(__LINE__,a,b)

Definition at line 281 of file reader.c.

◆ reader_namespace

#define reader_namespace (   a,
  b 
)    _reader_namespace(__LINE__,a,b)

Definition at line 309 of file reader.c.

◆ reader_prefix

#define reader_prefix (   a,
  b 
)    _reader_prefix(__LINE__,a,b)

Definition at line 295 of file reader.c.

◆ reader_qname

#define reader_qname (   a,
  b 
)    _reader_qname(a,b,__LINE__)

Definition at line 323 of file reader.c.

◆ reader_value

#define reader_value (   a,
  b 
)    _reader_value(__LINE__,a,b)

Definition at line 267 of file reader.c.

◆ set_input_string

#define set_input_string (   a,
  b 
)    _set_input_string(__LINE__,a,b);

Definition at line 202 of file reader.c.

◆ TEST_DEPTH

#define TEST_DEPTH (   reader,
  depth 
)    test_reader_depth(reader, depth, ~0u, __LINE__)

Definition at line 834 of file reader.c.

◆ TEST_DEPTH2

#define TEST_DEPTH2 (   reader,
  depth,
  brk 
)    test_reader_depth(reader, depth, brk, __LINE__)

Definition at line 835 of file reader.c.

◆ TEST_READER_POSITION

#define TEST_READER_POSITION (   reader,
  line,
  pos 
)     test_reader_pos(reader, line, pos, ~0u, ~0u, __LINE__)

Definition at line 78 of file reader.c.

◆ TEST_READER_POSITION2

#define TEST_READER_POSITION2 (   reader,
  line,
  pos,
  line_broken,
  pos_broken 
)     test_reader_pos(reader, line, pos, line_broken, pos_broken, __LINE__)

Definition at line 80 of file reader.c.

◆ TEST_READER_STATE

#define TEST_READER_STATE (   reader,
  state 
)    test_read_state(reader, state, state, __LINE__)

Definition at line 264 of file reader.c.

◆ TEST_READER_STATE2

#define TEST_READER_STATE2 (   reader,
  state,
  brk 
)    test_read_state(reader, state, brk, __LINE__)

Definition at line 265 of file reader.c.

Typedef Documentation

◆ input_iids_t

◆ testinput

Function Documentation

◆ _move_to_element()

static void _move_to_element ( unsigned  line,
IXmlReader *  reader 
)
static

Definition at line 239 of file reader.c.

240{
241 HRESULT hr;
242 hr = IXmlReader_MoveToElement(reader);
243 ok_(__FILE__,line)(hr == S_OK, "Unexpected hr %#lx.\n", hr);
244}
#define ok_(x1, x2)
Definition: atltest.h:61
HRESULT hr
Definition: delayimp.cpp:582
#define S_OK
Definition: intsafe.h:52
Definition: parser.c:49
Definition: reader.h:84

◆ _next_attribute()

static void _next_attribute ( unsigned  line,
IXmlReader *  reader 
)
static

Definition at line 231 of file reader.c.

232{
233 HRESULT hr;
234 hr = IXmlReader_MoveToNextAttribute(reader);
235 ok_(__FILE__,line)(hr == S_OK, "Unexpected hr %#lx.\n", hr);
236}

◆ _read_node()

static void _read_node ( unsigned  line,
IXmlReader *  reader,
XmlNodeType  expected_type 
)
static

Definition at line 217 of file reader.c.

218{
220 HRESULT hr;
221
222 hr = IXmlReader_Read(reader, &type);
223 if (expected_type == XmlNodeType_None)
224 ok_(__FILE__,line)(hr == S_FALSE, "Read returned %#lx, expected S_FALSE.\n", hr);
225 else
226 ok_(__FILE__,line)(hr == S_OK, "Read returned %#lx.\n", hr);
227 ok_(__FILE__,line)(type == expected_type, "read type %d, expected %d\n", type, expected_type);
228}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define S_FALSE
Definition: winerror.h:3451
XmlNodeType
Definition: xmllite.idl:23
@ XmlNodeType_None
Definition: xmllite.idl:24

◆ _read_value_char()

static void _read_value_char ( IXmlReader *  reader,
WCHAR  expected_char,
unsigned  line 
)
static

Definition at line 338 of file reader.c.

339{
340 WCHAR c = 0xffff;
341 UINT count = 0;
342 HRESULT hr;
343
344 hr = IXmlReader_ReadValueChunk(reader, &c, 1, &count);
345 ok_(__FILE__,line)(hr == S_OK, "Unexpected hr %#lx.\n", hr);
346 ok_(__FILE__,line)(count == 1, "got %u\n", c);
347 ok_(__FILE__,line)(c == expected_char, "got %x\n", c);
348}
GLuint GLuint GLsizei count
Definition: gl.h:1545
const GLubyte * c
Definition: glext.h:8905
unsigned int UINT
Definition: sysinfo.c:13
#define c
Definition: ke_i.h:80
short WCHAR
Definition: pedump.c:58

◆ _reader_name()

static const WCHAR * _reader_name ( unsigned  line,
IXmlReader *  reader,
const WCHAR *  expect 
)
static

Definition at line 282 of file reader.c.

283{
284 const WCHAR *str = (void*)0xdeadbeef;
285 UINT len = 0xdeadbeef;
286 HRESULT hr;
287
288 hr = IXmlReader_GetLocalName(reader, &str, &len);
289 ok_(__FILE__,line)(hr == S_OK, "Unexpected hr %#lx.\n", hr);
290 ok_(__FILE__,line)(len == lstrlenW(str), "len = %u.\n", len);
291 ok_(__FILE__,line)(!lstrcmpW(str, expect), "name = %s\n", wine_dbgstr_w(str));
292 return str;
293}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
#define lstrlenW
Definition: compat.h:750
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
GLenum GLsizei len
Definition: glext.h:6722
#define wine_dbgstr_w
Definition: kernel32.h:34
const WCHAR * str

◆ _reader_namespace()

static const WCHAR * _reader_namespace ( unsigned  line,
IXmlReader *  reader,
const WCHAR *  expect 
)
static

Definition at line 310 of file reader.c.

311{
312 const WCHAR *str = (void*)0xdeadbeef;
313 UINT len = 0xdeadbeef;
314 HRESULT hr;
315
316 hr = IXmlReader_GetNamespaceUri(reader, &str, &len);
317 ok_(__FILE__,line)(hr == S_OK, "Unexpected hr %#lx.\n", hr);
318 ok_(__FILE__,line)(len == lstrlenW(str), "len = %u.\n", len);
319 ok_(__FILE__,line)(!lstrcmpW(str, expect), "namespace = %s\n", wine_dbgstr_w(str));
320 return str;
321}

◆ _reader_prefix()

static const WCHAR * _reader_prefix ( unsigned  line,
IXmlReader *  reader,
const WCHAR *  expect 
)
static

Definition at line 296 of file reader.c.

297{
298 const WCHAR *str = (void*)0xdeadbeef;
299 UINT len = 0xdeadbeef;
300 HRESULT hr;
301
302 hr = IXmlReader_GetPrefix(reader, &str, &len);
303 ok_(__FILE__,line)(hr == S_OK, "Unexpected hr %#lx.\n", hr);
304 ok_(__FILE__,line)(len == lstrlenW(str), "len = %u.\n", len);
305 ok_(__FILE__,line)(!lstrcmpW(str, expect), "prefix = %s\n", wine_dbgstr_w(str));
306 return str;
307}

◆ _reader_qname()

static const WCHAR * _reader_qname ( IXmlReader *  reader,
const WCHAR *  expect,
unsigned  line 
)
static

Definition at line 324 of file reader.c.

325{
326 const WCHAR *str = (void*)0xdeadbeef;
327 UINT len = 0xdeadbeef;
328 HRESULT hr;
329
330 hr = IXmlReader_GetQualifiedName(reader, &str, &len);
331 ok_(__FILE__,line)(hr == S_OK, "Unexpected hr %#lx.\n", hr);
332 ok_(__FILE__,line)(len == lstrlenW(str), "len = %u.\n", len);
333 ok_(__FILE__,line)(!lstrcmpW(str, expect), "name = %s\n", wine_dbgstr_w(str));
334 return str;
335}

◆ _reader_value()

static const WCHAR * _reader_value ( unsigned  line,
IXmlReader *  reader,
const WCHAR *  expect 
)
static

Definition at line 268 of file reader.c.

269{
270 const WCHAR *str = (void*)0xdeadbeef;
271 UINT len = 0xdeadbeef;
272 HRESULT hr;
273
274 hr = IXmlReader_GetValue(reader, &str, &len);
275 ok_(__FILE__,line)(hr == S_OK, "Unexpected hr %#lx.\n", hr);
276 ok_(__FILE__,line)(len == lstrlenW(str), "len = %u\n", len);
277 ok_(__FILE__,line)(!lstrcmpW(str, expect), "value = %s\n", wine_dbgstr_w(str));
278 return str;
279}

◆ _set_input_string()

static void _set_input_string ( unsigned  line,
IXmlReader *  reader,
const char *  xml 
)
static

Definition at line 203 of file reader.c.

204{
206 HRESULT hr;
207
209
210 hr = IXmlReader_SetInput(reader, (IUnknown *)stream);
211 ok_(__FILE__,line)(hr == S_OK, "Unexpected hr %#lx.\n", hr);
212
213 IStream_Release(stream);
214}
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
static IStream * create_stream_on_data(const void *data, unsigned int size)
Definition: reader.c:39
Definition: parse.h:23

◆ create_stream_on_data()

static IStream * create_stream_on_data ( const void *  data,
unsigned int  size 
)
static

Definition at line 39 of file reader.c.

40{
42 HGLOBAL hglobal;
43 void *ptr;
44 HRESULT hr;
45
46 hglobal = GlobalAlloc(GHND, size);
47 ptr = GlobalLock(hglobal);
48
50
51 hr = CreateStreamOnHGlobal(hglobal, TRUE, &stream);
52 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
53 ok(stream != NULL, "Expected non-NULL stream\n");
54
55 GlobalUnlock(hglobal);
56
57 return stream;
58}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL delete_on_release, IStream **stream)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
static ERESOURCE GlobalLock
Definition: sys_arch.c:8
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
#define GHND
Definition: winbase.h:321

Referenced by _set_input_string(), test_encoding_detection(), and test_read_xmldeclaration().

◆ DEFINE_GUID()

DEFINE_GUID ( IID_IXmlReaderInput  ,
0x0b3ccc9b  ,
0x9214  ,
0x428b  ,
0xa2  ,
0xae  ,
0xef  ,
0x3a  ,
0xa8  ,
0x71  ,
0xaf  ,
0xda   
)

◆ impl_from_IUnknown()

static testinput * impl_from_IUnknown ( IUnknown *  iface)
inlinestatic

Definition at line 356 of file reader.c.

357{
358 return CONTAINING_RECORD(iface, testinput, IUnknown_iface);
359}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by testinput_AddRef(), and testinput_Release().

◆ ok_iids_()

static void ok_iids_ ( const input_iids_t *  iids,
const IID **  expected,
const IID **  exp_broken,
BOOL  todo,
int  line 
)
static

Definition at line 116 of file reader.c.

117{
118 int i = 0, size = 0;
119
120 while (expected[i++]) size++;
121
123 ok_(__FILE__, line)(iids->count == size, "Sequence size mismatch (%d), got (%d)\n", size, iids->count);
124
125 if (iids->count != size) return;
126
127 for (i = 0; i < size; i++) {
128 ok_(__FILE__, line)(IsEqualGUID(&iids->iids[i], expected[i]) ||
129 (exp_broken ? broken(IsEqualGUID(&iids->iids[i], exp_broken[i])) : FALSE),
130 "Wrong IID(%d), got %s\n", i, wine_dbgstr_guid(&iids->iids[i]));
131 }
132}
#define broken(x)
Definition: atltest.h:178
#define FALSE
Definition: types.h:117
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define todo_wine_if(is_todo)
Definition: minitest.h:81
BOOL todo
Definition: filedlg.c:313
BOOL expected
Definition: store.c:2000
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:181
IID iids[10]
Definition: reader.c:84
int count
Definition: reader.c:85

◆ resolver_AddRef()

static ULONG WINAPI resolver_AddRef ( IXmlResolver *  iface)
static

Definition at line 486 of file reader.c.

487{
488 return 2;
489}

◆ resolver_QI()

static HRESULT WINAPI resolver_QI ( IXmlResolver *  iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 471 of file reader.c.

472{
473 ok(0, "unexpected call, riid %s\n", wine_dbgstr_guid(riid));
474
475 if (IsEqualIID(riid, &IID_IXmlResolver) || IsEqualIID(riid, &IID_IUnknown))
476 {
477 *obj = iface;
478 IXmlResolver_AddRef(iface);
479 return S_OK;
480 }
481
482 *obj = NULL;
483 return E_NOINTERFACE;
484}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ resolver_Release()

static ULONG WINAPI resolver_Release ( IXmlResolver *  iface)
static

Definition at line 491 of file reader.c.

492{
493 return 1;
494}

◆ resolver_ResolveUri()

static HRESULT WINAPI resolver_ResolveUri ( IXmlResolver *  iface,
const WCHAR *  base_uri,
const WCHAR *  public_id,
const WCHAR *  system_id,
IUnknown **  input 
)
static

Definition at line 496 of file reader.c.

498{
499 ok(0, "unexpected call\n");
500 return E_NOTIMPL;
501}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ START_TEST()

START_TEST ( reader  )

Definition at line 2674 of file reader.c.

2675{
2682 test_read_pi();
2693 test_prefix();
2702}
static void test_read_element(void)
Definition: reader.c:1405
static void test_readerinput(void)
Definition: reader.c:614
static void test_prefix(void)
Definition: reader.c:1985
static void test_read_public_dtd(void)
Definition: reader.c:1276
static void test_reader_state(void)
Definition: reader.c:778
static void test_namespaceuri(void)
Definition: reader.c:2041
static void test_read_charref(void)
Definition: reader.c:2133
static void test_endoffile(void)
Definition: reader.c:2240
static void test_read_full(void)
Definition: reader.c:1251
static void test_encoding_detection(void)
Definition: reader.c:2170
static void test_string_pointers(void)
Definition: reader.c:2470
static void test_attribute_by_name(void)
Definition: reader.c:2590
static void test_read_system_dtd(void)
Definition: reader.c:1338
static void test_isemptyelement(void)
Definition: reader.c:1832
static void test_reader_position(void)
Definition: reader.c:2404
static void test_read_cdata(void)
Definition: reader.c:1686
static void test_reader_properties(void)
Definition: reader.c:1957
static void test_read_pi(void)
Definition: reader.c:1156
static void test_reader_create(void)
Definition: reader.c:513
static void test_read_pending(void)
Definition: reader.c:1562
static void test_read_text(void)
Definition: reader.c:1760
static void test_max_element_depth(void)
Definition: reader.c:2301
static void test_read_comment(void)
Definition: reader.c:1065
static void test_read_xmldeclaration(void)
Definition: reader.c:837
static void test_read_attribute(void)
Definition: reader.c:1903
static void test_readvaluechunk(void)
Definition: reader.c:1598

◆ state_to_str()

static const char * state_to_str ( XmlReadState  state)
static

Definition at line 135 of file reader.c.

136{
137 static const char* state_names[] = {
138 "XmlReadState_Initial",
139 "XmlReadState_Interactive",
140 "XmlReadState_Error",
141 "XmlReadState_EndOfFile",
142 "XmlReadState_Closed"
143 };
144
145 static const char unknown[] = "unknown";
146
147 switch (state)
148 {
154 return state_names[state];
155 default:
156 return unknown;
157 }
158}
static int state
Definition: maze.c:121
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1674
@ XmlReadState_Closed
Definition: xmllite.idl:103
@ XmlReadState_Error
Definition: xmllite.idl:101
@ XmlReadState_EndOfFile
Definition: xmllite.idl:102
@ XmlReadState_Initial
Definition: xmllite.idl:99
@ XmlReadState_Interactive
Definition: xmllite.idl:100

Referenced by test_read_state().

◆ test_attribute_by_name()

static void test_attribute_by_name ( void  )
static

Definition at line 2590 of file reader.c.

2591{
2592 static const char *xml = "<a><elem xmlns=\"myns\" a=\"value a\" b=\"value b\" xmlns:ns=\"ns uri\" "
2593 "ns:c=\"value c\" c=\"value c2\"/></a>";
2594 static const WCHAR xmlns_uriW[] = L"http://www.w3.org/2000/xmlns/";
2596 HRESULT hr;
2597
2598 hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL);
2599 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2600
2602
2603 hr = IXmlReader_MoveToAttributeByName(reader, NULL, NULL);
2604 ok(hr == E_INVALIDARG || broken(hr == S_FALSE) /* WinXP */, "Unexpected hr %#lx.\n", hr);
2605
2606 hr = IXmlReader_MoveToAttributeByName(reader, L"", NULL);
2607 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
2608
2610 TEST_DEPTH(reader, 0);
2611
2612 hr = IXmlReader_MoveToAttributeByName(reader, L"", NULL);
2613 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
2614
2616 TEST_DEPTH(reader, 1);
2617
2618 hr = IXmlReader_MoveToAttributeByName(reader, NULL, NULL);
2619 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
2620
2621 hr = IXmlReader_MoveToAttributeByName(reader, NULL, xmlns_uriW);
2622 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
2623
2624 hr = IXmlReader_MoveToAttributeByName(reader, L"", xmlns_uriW);
2625 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
2626
2627 hr = IXmlReader_MoveToAttributeByName(reader, L"xmlns", NULL);
2628 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
2629
2630 hr = IXmlReader_MoveToAttributeByName(reader, L"xmlns", xmlns_uriW);
2631 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2632 TEST_DEPTH(reader, 2);
2633 reader_value(reader, L"myns");
2634
2635 hr = IXmlReader_MoveToAttributeByName(reader, L"a", NULL);
2636 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2637 TEST_DEPTH(reader, 2);
2638 reader_value(reader, L"value a");
2639
2640 hr = IXmlReader_MoveToAttributeByName(reader, L"b", NULL);
2641 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2642 TEST_DEPTH(reader, 2);
2643 reader_value(reader, L"value b");
2644
2645 hr = IXmlReader_MoveToAttributeByName(reader, L"a", L"myns");
2646 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
2647
2648 hr = IXmlReader_MoveToAttributeByName(reader, L"ns", NULL);
2649 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
2650
2651 hr = IXmlReader_MoveToAttributeByName(reader, L"ns", xmlns_uriW);
2652 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2653 TEST_DEPTH(reader, 2);
2654 reader_value(reader, L"ns uri");
2655
2656 hr = IXmlReader_MoveToAttributeByName(reader, L"b", L"");
2657 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2658 TEST_DEPTH(reader, 2);
2659 reader_value(reader, L"value b");
2660
2661 hr = IXmlReader_MoveToAttributeByName(reader, L"c", NULL);
2662 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2663 TEST_DEPTH(reader, 2);
2664 reader_value(reader, L"value c2");
2665
2666 hr = IXmlReader_MoveToAttributeByName(reader, L"c", L"ns uri");
2667 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2668 TEST_DEPTH(reader, 2);
2669 reader_value(reader, L"value c");
2670
2671 IXmlReader_Release(reader);
2672}
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT WINAPI CreateXmlReader(REFIID riid, void **obj, IMalloc *imalloc)
Definition: reader.c:3616
#define L(x)
Definition: resources.c:13
#define reader_value(a, b)
Definition: reader.c:267
#define TEST_DEPTH(reader, depth)
Definition: reader.c:834
#define set_input_string(a, b)
Definition: reader.c:202
#define read_node(a, b)
Definition: reader.c:216
@ XmlNodeType_Element
Definition: xmllite.idl:25

Referenced by START_TEST().

◆ test_encoding_detection()

static void test_encoding_detection ( void  )
static

Definition at line 2170 of file reader.c.

2171{
2172 static const struct encoding_testW
2173 {
2174 WCHAR text[16];
2175 }
2176 encoding_testsW[] =
2177 {
2178 { { '<','?','p','i',' ','?','>',0 } },
2179 { { '<','!','-','-',' ','c','-','-','>',0 } },
2180 { { 0xfeff,'<','a','/','>',0 } },
2181 { { '<','a','/','>',0 } },
2182 };
2183 static const char *encoding_testsA[] =
2184 {
2185 "<?pi ?>",
2186 "<!-- comment -->",
2187 "\xef\xbb\xbf<a/>", /* UTF-8 BOM */
2188 "<a/>",
2189 };
2192 IStream *stream;
2193 unsigned int i;
2194 HRESULT hr;
2195
2196 hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL);
2197 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2198
2199 /* there's no way to query detected encoding back, so just verify that document is browsable */
2200
2201 for (i = 0; i < ARRAY_SIZE(encoding_testsA); i++)
2202 {
2203 set_input_string(reader, encoding_testsA[i]);
2204
2206 hr = IXmlReader_Read(reader, &type);
2207 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2208 ok(type != XmlNodeType_None, "Unexpected node type %d\n", type);
2209 }
2210
2211 for (i = 0; i < ARRAY_SIZE(encoding_testsW); i++)
2212 {
2213 stream = create_stream_on_data(encoding_testsW[i].text, lstrlenW(encoding_testsW[i].text) * sizeof(WCHAR));
2214
2215 hr = IXmlReader_SetInput(reader, (IUnknown *)stream);
2216 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2217
2219 hr = IXmlReader_Read(reader, &type);
2220 ok(hr == S_OK, "%u: unexpected hr %#lx.\n", i, hr);
2221 ok(type != XmlNodeType_None, "%u: unexpected node type %d\n", i, type);
2222
2223 IStream_Release(stream);
2224 }
2225
2226 IXmlReader_Release(reader);
2227}
#define ARRAY_SIZE(A)
Definition: main.h:20
const WCHAR * text
Definition: package.c:1826

Referenced by START_TEST().

◆ test_endoffile()

static void test_endoffile ( void  )
static

Definition at line 2240 of file reader.c.

2241{
2244 HRESULT hr;
2245
2246 hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL);
2247 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2248
2250
2251 set_input_string(reader, "<a/>");
2252
2254
2256 hr = IXmlReader_Read(reader, &type);
2257 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2258 ok(type == XmlNodeType_Element, "Unexpected type %d\n", type);
2259
2261
2263 hr = IXmlReader_Read(reader, &type);
2264 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
2265 ok(type == XmlNodeType_None, "Unexpected type %d\n", type);
2266
2268
2269 hr = IXmlReader_SetInput(reader, NULL);
2270 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2271
2273
2274 IXmlReader_Release(reader);
2275
2276 hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL);
2277 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2278
2279 set_input_string(reader, "<a/>text");
2280
2282 hr = IXmlReader_Read(reader, &type);
2283 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2284 ok(type == XmlNodeType_Element, "Unexpected type %d\n", type);
2285
2287
2289 hr = IXmlReader_Read(reader, &type);
2290 ok(hr == WC_E_SYNTAX, "Unexpected hr %#lx.\n", hr);
2291 ok(type == XmlNodeType_None, "Unexpected type %d\n", type);
2292
2294
2295 hr = IXmlReader_SetInput(reader, NULL);
2296 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2297
2298 IXmlReader_Release(reader);
2299}
static void test_eof_state(IXmlReader *reader, BOOL eof)
Definition: reader.c:2229
@ WC_E_SYNTAX
Definition: xmllite.idl:158

Referenced by START_TEST().

◆ test_eof_state()

static void test_eof_state ( IXmlReader *  reader,
BOOL  eof 
)
static

Definition at line 2229 of file reader.c.

2230{
2232 HRESULT hr;
2233
2234 ok(IXmlReader_IsEOF(reader) == eof, "Unexpected IsEOF() result\n");
2235 hr = IXmlReader_GetProperty(reader, XmlReaderProperty_ReadState, &state);
2236 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2237 ok((state == XmlReadState_EndOfFile) == eof, "Unexpected EndOfFile state %Id.\n", state);
2238}
static int eof(int fd)
Definition: io.h:21
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
@ XmlReaderProperty_ReadState
Definition: xmllite.idl:131

Referenced by test_endoffile().

◆ test_isemptyelement()

static void test_isemptyelement ( void  )
static

Definition at line 1832 of file reader.c.

1833{
1837 HRESULT hr;
1838 BOOL ret;
1839
1840 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
1841 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1842
1843 while (test->xml)
1844 {
1846
1848 hr = IXmlReader_Read(reader, &type);
1849 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1850 ok(type == XmlNodeType_Element, "got %d\n", type);
1851
1852 ret = IXmlReader_IsEmptyElement(reader);
1853 ok(ret == test->empty, "got %d, expected %d. xml=%s\n", ret, test->empty, test->xml);
1854
1855 test++;
1856 }
1857
1858 /* Move to an attribute of an empty element. */
1859 set_input_string(reader, "<a attr1=\'b\' />");
1860
1861 hr = IXmlReader_Read(reader, &type);
1862 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1863 ok(type == XmlNodeType_Element, "Unexpected node type %d.\n", type);
1864 ret = IXmlReader_IsEmptyElement(reader);
1865 ok(ret, "Unexpected empty flag %d.\n", ret);
1866
1867 hr = IXmlReader_MoveToFirstAttribute(reader);
1868 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1869 hr = IXmlReader_GetNodeType(reader, &type);
1870 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1871 ok(type == XmlNodeType_Attribute, "Unexpected node type %d.\n", type);
1872 ret = IXmlReader_IsEmptyElement(reader);
1873 ok(!ret, "Unexpected empty flag %d.\n", ret);
1874
1875 IXmlReader_Release(reader);
1876}
return ret
Definition: mutex.c:147
unsigned int BOOL
Definition: ntddk_ex.h:94
static struct test_entry_empty empty_element_tests[]
Definition: reader.c:1826
#define test
Definition: rosglue.h:37
Definition: reader.c:1821
@ XmlNodeType_Attribute
Definition: xmllite.idl:26

Referenced by START_TEST().

◆ test_max_element_depth()

static void test_max_element_depth ( void  )
static

Definition at line 2301 of file reader.c.

2302{
2303 static const char *xml =
2304 "<a>"
2305 "<b attrb=\"_b\">"
2306 "<c>"
2307 "<d></d>"
2308 "</c>"
2309 "</b>"
2310 "</a>";
2311 XmlNodeType nodetype;
2312 unsigned int count;
2314 HRESULT hr;
2315
2316 hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL);
2317 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2318
2320
2321 hr = IXmlReader_SetProperty(reader, XmlReaderProperty_MaxElementDepth, 2);
2322 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2323
2324 TEST_DEPTH(reader, 0);
2325
2326 hr = IXmlReader_Read(reader, NULL);
2327 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2328
2329 TEST_DEPTH(reader, 0);
2330
2331 hr = IXmlReader_Read(reader, NULL);
2332 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2333
2334 TEST_DEPTH(reader, 1);
2336
2337 hr = IXmlReader_Read(reader, NULL);
2338 ok(hr == SC_E_MAXELEMENTDEPTH, "Unexpected hr %#lx.\n", hr);
2339
2340 TEST_DEPTH2(reader, 0, 2);
2342
2343 hr = IXmlReader_SetProperty(reader, XmlReaderProperty_MaxElementDepth, 10);
2344 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2345
2346 hr = IXmlReader_Read(reader, NULL);
2347 ok(hr == SC_E_MAXELEMENTDEPTH, "Unexpected hr %#lx.\n", hr);
2348
2349 TEST_DEPTH2(reader, 0, 2);
2351
2352 /* test if stepping into attributes enforces depth limit too */
2354
2355 hr = IXmlReader_SetProperty(reader, XmlReaderProperty_MaxElementDepth, 2);
2356 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2357
2358 TEST_DEPTH(reader, 0);
2359
2360 hr = IXmlReader_Read(reader, NULL);
2361 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2362
2363 TEST_DEPTH(reader, 0);
2364
2365 hr = IXmlReader_Read(reader, NULL);
2366 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2367
2368 TEST_DEPTH(reader, 1);
2369
2370 hr = IXmlReader_MoveToFirstAttribute(reader);
2371 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2372
2373 TEST_DEPTH(reader, 2);
2375
2376 nodetype = 123;
2377 hr = IXmlReader_Read(reader, &nodetype);
2378 ok(hr == SC_E_MAXELEMENTDEPTH, "Unexpected hr %#lx.\n", hr);
2379 ok(nodetype == XmlNodeType_None, "got node type %d\n", nodetype);
2380
2381 nodetype = 123;
2382 hr = IXmlReader_Read(reader, &nodetype);
2383 ok(hr == SC_E_MAXELEMENTDEPTH, "Unexpected hr %#lx.\n", hr);
2384 ok(nodetype == XmlNodeType_None, "got node type %d\n", nodetype);
2385
2386 TEST_DEPTH2(reader, 0, 2);
2388
2389 /* set max depth to 0, this disables depth limit */
2391
2392 hr = IXmlReader_SetProperty(reader, XmlReaderProperty_MaxElementDepth, 0);
2393 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2394
2395 count = 0;
2396 while (IXmlReader_Read(reader, NULL) == S_OK)
2397 count++;
2398 ok(count == 8, "Unexpected node number %u\n", count);
2400
2401 IXmlReader_Release(reader);
2402}
#define TEST_READER_STATE(reader, state)
Definition: reader.c:264
#define TEST_DEPTH2(reader, depth, brk)
Definition: reader.c:835
@ SC_E_MAXELEMENTDEPTH
Definition: xmllite.idl:206
@ XmlReaderProperty_MaxElementDepth
Definition: xmllite.idl:132

Referenced by START_TEST().

◆ test_namespaceuri()

static void test_namespaceuri ( void  )
static

Definition at line 2041 of file reader.c.

2042{
2043 struct uri_test
2044 {
2045 const char *xml;
2046 const WCHAR *uri[5];
2047 } uri_tests[] =
2048 {
2049 { "<a xmlns=\"defns a\"><b xmlns=\"defns b\"><c xmlns=\"defns c\"/></b></a>",
2050 { L"defns a", L"defns b", L"defns c", L"defns b", L"defns a" }},
2051 { "<r:a xmlns=\"defns a\" xmlns:r=\"ns r\"/>",
2052 { L"ns r" }},
2053 { "<r:a xmlns=\"defns a\" xmlns:r=\"ns r\"><b/></r:a>",
2054 { L"ns r", L"defns a", L"ns r" }},
2055 { "<a xmlns=\"defns a\" xmlns:r=\"ns r\"><r:b/></a>",
2056 { L"defns a", L"ns r", L"defns a" }},
2057 { "<a><b><c/></b></a>",
2058 { L"", L"", L"", L"", L"" }},
2059 { "<a>text</a>",
2060 { L"", L"", L"" }},
2061 { "<a>\r\n</a>",
2062 { L"", L"", L"" }},
2063 { "<a><![CDATA[data]]></a>",
2064 { L"", L"", L"" }},
2065 { "<?xml version=\"1.0\" ?><a/>",
2066 { L"", L"" }},
2067 { "<a><?pi ?></a>",
2068 { L"", L"", L"" }},
2069 { "<a><!-- comment --></a>",
2070 { L"", L"", L"" }},
2071 };
2074 unsigned int i;
2075 HRESULT hr;
2076
2077 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
2078 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2079
2080 for (i = 0; i < ARRAY_SIZE(uri_tests); i++) {
2081 unsigned int j = 0;
2082
2084
2085 type = ~0u;
2086 while (IXmlReader_Read(reader, &type) == S_OK) {
2087 const WCHAR *local, *qname;
2088 UINT length, length2;
2089
2097 type == XmlNodeType_XmlDeclaration, "Unexpected node type %d.\n", type);
2098
2099 local = NULL;
2100 length = 0;
2101 hr = IXmlReader_GetLocalName(reader, &local, &length);
2102 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2103 ok(local != NULL, "Unexpected NULL local name pointer\n");
2104
2105 qname = NULL;
2106 length2 = 0;
2107 hr = IXmlReader_GetQualifiedName(reader, &qname, &length2);
2108 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2109 ok(qname != NULL, "Unexpected NULL qualified name pointer\n");
2110
2111 if (type == XmlNodeType_Element ||
2115 {
2116 ok(*local != 0, "Unexpected empty local name\n");
2117 ok(length > 0, "Unexpected local name length\n");
2118
2119 ok(*qname != 0, "Unexpected empty qualified name\n");
2120 ok(length2 > 0, "Unexpected qualified name length\n");
2121 }
2122
2124
2125 j++;
2126 }
2127 ok(type == XmlNodeType_None, "Unexpected node type %d\n", type);
2128 }
2129
2130 IXmlReader_Release(reader);
2131}
#define local
Definition: zutil.h:30
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
const WCHAR * uri
Definition: sec_mgr.c:1564
static const uri_properties uri_tests[]
Definition: uri.c:140
#define reader_namespace(a, b)
Definition: reader.c:309
@ XmlNodeType_Whitespace
Definition: xmllite.idl:32
@ XmlNodeType_EndElement
Definition: xmllite.idl:33
@ XmlNodeType_ProcessingInstruction
Definition: xmllite.idl:29
@ XmlNodeType_CDATA
Definition: xmllite.idl:28
@ XmlNodeType_XmlDeclaration
Definition: xmllite.idl:34
@ XmlNodeType_Comment
Definition: xmllite.idl:30
@ XmlNodeType_Text
Definition: xmllite.idl:27

Referenced by START_TEST().

◆ test_prefix()

static void test_prefix ( void  )
static

Definition at line 1985 of file reader.c.

1986{
1987 static const struct
1988 {
1989 const char *xml;
1990 const WCHAR *prefix1;
1991 const WCHAR *prefix2;
1992 const WCHAR *prefix3;
1993 } prefix_tests[] =
1994 {
1995 { "<b xmlns=\"defns\" xml:a=\"a ns\"/>", L"", L"", L"xml" },
1996 { "<c:b xmlns:c=\"c ns\" xml:a=\"a ns\"/>", L"c", L"xmlns", L"xml" },
1997 };
1999 unsigned int i;
2000 HRESULT hr;
2001
2002 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
2003 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2004
2005 for (i = 0; i < ARRAY_SIZE(prefix_tests); i++) {
2007
2008 set_input_string(reader, prefix_tests[i].xml);
2009
2010 hr = IXmlReader_Read(reader, &type);
2011 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2012 ok(type == XmlNodeType_Element, "Unexpected node type %d.\n", type);
2013
2014 reader_prefix(reader, prefix_tests[i].prefix1);
2015
2016 hr = IXmlReader_MoveToFirstAttribute(reader);
2017 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2018
2019 hr = IXmlReader_GetNodeType(reader, &type);
2020 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2021 ok(type == XmlNodeType_Attribute, "Unexpected node type %d.\n", type);
2022
2023 reader_prefix(reader, prefix_tests[i].prefix2);
2024
2026
2027 hr = IXmlReader_GetNodeType(reader, &type);
2028 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2029 ok(type == XmlNodeType_Attribute, "Unexpected node type %d.\n", type);
2030
2031 reader_prefix(reader, prefix_tests[i].prefix3);
2032
2033 /* back to the element, check prefix */
2035 reader_prefix(reader, prefix_tests[i].prefix1);
2036 }
2037
2038 IXmlReader_Release(reader);
2039}
#define reader_prefix(a, b)
Definition: reader.c:295
#define move_to_element(a)
Definition: reader.c:238
#define next_attribute(a)
Definition: reader.c:230

Referenced by START_TEST().

◆ test_read_attribute()

static void test_read_attribute ( void  )
static

Definition at line 1903 of file reader.c.

1904{
1907 HRESULT hr;
1908
1909 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
1910 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1911
1912 while (test->xml)
1913 {
1915
1917
1918 hr = IXmlReader_Read(reader, NULL);
1919
1920 if (test->hr_broken)
1921 ok(hr == test->hr || broken(hr == test->hr_broken), "Unexpected hr %#lx, for %s.\n", hr, test->xml);
1922 else
1923 ok(hr == test->hr, "Unexpected hr %#lx, for %s.\n", hr, test->xml);
1924 if (hr == S_OK)
1925 {
1926 const WCHAR *str;
1927 UINT len;
1928
1930 hr = IXmlReader_GetNodeType(reader, &type);
1931 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1932
1933 ok(type == XmlNodeType_Element, "got %d for %s\n", type, test->xml);
1934
1935 hr = IXmlReader_MoveToFirstAttribute(reader);
1936 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1937
1939
1940 len = 1;
1941 str = NULL;
1942 hr = IXmlReader_GetQualifiedName(reader, &str, &len);
1943 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1944 ok(len == lstrlenW(test->name), "got %u\n", len);
1945 ok(!lstrcmpW(str, test->name), "got %s\n", wine_dbgstr_w(str));
1946
1947 /* value */
1949 }
1950
1951 test++;
1952 }
1953
1954 IXmlReader_Release(reader);
1955}
#define reader_name(a, b)
Definition: reader.c:281
static struct test_entry attributes_tests[]
Definition: reader.c:1878
char * value
Definition: wpp.c:53
char * name
Definition: wpp.c:52

Referenced by START_TEST().

◆ test_read_cdata()

static void test_read_cdata ( void  )
static

Definition at line 1686 of file reader.c.

1687{
1688 struct test_entry *test = cdata_tests;
1690 HRESULT hr;
1691
1692 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
1693 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1694
1695 while (test->xml)
1696 {
1698
1700
1702 hr = IXmlReader_Read(reader, &type);
1703
1704 /* read one more to get to CDATA */
1706 {
1708 hr = IXmlReader_Read(reader, &type);
1709 }
1710
1711 if (test->hr_broken)
1712 ok(hr == test->hr || broken(hr == test->hr_broken), "Unexpected hr %#lx, for %s.\n", hr, test->xml);
1713 else
1714 ok(hr == test->hr, "Unexpected hr %#lx, for %s.\n", hr, test->xml);
1715 if (hr == S_OK)
1716 {
1717 const WCHAR *str;
1718 UINT len;
1719
1720 ok(type == XmlNodeType_CDATA, "got %d for %s\n", type, test->xml);
1721
1722 reader_name(reader, L"");
1723
1724 str = NULL;
1725 hr = IXmlReader_GetLocalName(reader, &str, NULL);
1726 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1727 ok(*str == 0, "got %s\n", wine_dbgstr_w(str));
1728
1729 len = 1;
1730 str = NULL;
1731 hr = IXmlReader_GetQualifiedName(reader, &str, &len);
1732 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1733 ok(len == 0, "got %u\n", len);
1734 ok(*str == 0, "got %s\n", wine_dbgstr_w(str));
1735
1736 str = NULL;
1737 hr = IXmlReader_GetQualifiedName(reader, &str, NULL);
1738 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1739 ok(*str == 0, "got %s\n", wine_dbgstr_w(str));
1740
1741 /* value */
1743 }
1744
1745 test++;
1746 }
1747
1748 IXmlReader_Release(reader);
1749}
static struct test_entry cdata_tests[]
Definition: reader.c:1676

Referenced by START_TEST().

◆ test_read_charref()

static void test_read_charref ( void  )
static

Definition at line 2133 of file reader.c.

2134{
2135 static const char testA[] = "<a b=\"c\">&#x1f3;&#x103;&gt;</a>";
2136 static const WCHAR chardataW[] = {0x01f3,0x0103,'>',0};
2137 const WCHAR *value;
2140 HRESULT hr;
2141
2142 hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL);
2143 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2144
2145 set_input_string(reader, testA);
2146
2147 hr = IXmlReader_Read(reader, &type);
2148 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2149 ok(type == XmlNodeType_Element, "Unexpected node type %d\n", type);
2150
2151 hr = IXmlReader_Read(reader, &type);
2152 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2153 ok(type == XmlNodeType_Text, "Unexpected node type %d\n", type);
2154
2155 hr = IXmlReader_GetValue(reader, &value, NULL);
2156 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2157 ok(!lstrcmpW(value, chardataW), "Text value : %s\n", wine_dbgstr_w(value));
2158
2159 hr = IXmlReader_Read(reader, &type);
2160 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2161 ok(type == XmlNodeType_EndElement, "Unexpected node type %d\n", type);
2162
2163 hr = IXmlReader_Read(reader, &type);
2164 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
2165 ok(type == XmlNodeType_None, "Unexpected node type %d\n", type);
2166
2167 IXmlReader_Release(reader);
2168}
Definition: pdh_main.c:64

Referenced by START_TEST().

◆ test_read_comment()

static void test_read_comment ( void  )
static

Definition at line 1065 of file reader.c.

1066{
1067 static const char *teststr = "<a>text<!-- comment --></a>";
1068 struct test_entry *test = comment_tests;
1069 static const XmlNodeType types[] =
1070 {
1075 };
1076 unsigned int i = 0;
1079 HRESULT hr;
1080
1081 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
1082 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1083
1084 set_input_string(reader, teststr);
1085
1086 while (IXmlReader_Read(reader, &type) == S_OK)
1087 {
1088 const WCHAR *value;
1089
1090 ok(type == types[i], "%d: unexpected node type %d\n", i, type);
1091
1093 {
1094 hr = IXmlReader_GetValue(reader, &value, NULL);
1095 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1096 ok(*value != 0, "Expected node value\n");
1097 }
1098 i++;
1099 }
1100
1101 while (test->xml)
1102 {
1104
1106 hr = IXmlReader_Read(reader, &type);
1107 if (test->hr_broken)
1108 ok(hr == test->hr || broken(hr == test->hr_broken), "Unexpected hr %#lx, for %s.\n", hr, test->xml);
1109 else
1110 ok(hr == test->hr, "Unexpected hr %#lx, for %s.\n", hr, test->xml);
1111 if (hr == S_OK)
1112 {
1113 const WCHAR *str;
1114
1115 ok(type == XmlNodeType_Comment, "got %d for %s\n", type, test->xml);
1116
1117 reader_name(reader, L"");
1118
1119 str = NULL;
1120 hr = IXmlReader_GetLocalName(reader, &str, NULL);
1121 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1122 ok(*str == 0, "got %s\n", wine_dbgstr_w(str));
1123
1124 reader_qname(reader, L"");
1125
1126 str = NULL;
1127 hr = IXmlReader_GetQualifiedName(reader, &str, NULL);
1128 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1129 ok(*str == 0, "got %s\n", wine_dbgstr_w(str));
1130
1131 /* value */
1133 }
1134
1135 test++;
1136 }
1137
1138 IXmlReader_Release(reader);
1139}
#define reader_qname(a, b)
Definition: reader.c:323
static struct test_entry comment_tests[]
Definition: reader.c:1056
const WCHAR * value
Definition: reader.c:1050
Definition: cmds.c:130

Referenced by START_TEST().

◆ test_read_element()

static void test_read_element ( void  )
static

Definition at line 1405 of file reader.c.

1406{
1407 struct test_entry *test = element_tests;
1408 static const char stag[] =
1409 "<a attr1=\"_a\">"
1410 "<b attr2=\"_b\">"
1411 "text"
1412 "<c attr3=\"_c\"/>"
1413 "<d attr4=\"_d\"></d>"
1414 "</b>"
1415 "</a>";
1416 static const UINT depths[] = { 0, 1, 2, 2, 2, 3, 2, 1 };
1419 unsigned int i;
1420 UINT depth;
1421 HRESULT hr;
1422
1423 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
1424 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1425
1426 while (test->xml)
1427 {
1429
1431 hr = IXmlReader_Read(reader, &type);
1432 if (test->hr_broken)
1433 ok(hr == test->hr || broken(hr == test->hr_broken), "Unexpected hr %#lx, for %s.\n", hr, test->xml);
1434 else
1436 ok(hr == test->hr, "Unexpected hr %#lx, for %s.\n", hr, test->xml);
1437 if (hr == S_OK)
1438 {
1439 const WCHAR *str;
1440 UINT len;
1441
1442 ok(type == XmlNodeType_Element, "got %d for %s\n", type, test->xml);
1443
1444 len = 0;
1445 str = NULL;
1446 hr = IXmlReader_GetQualifiedName(reader, &str, &len);
1447 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1448 ok(len == lstrlenW(test->name), "got %u\n", len);
1449 ok(!lstrcmpW(str, test->name), "got %s\n", wine_dbgstr_w(str));
1450
1451 /* value */
1452 reader_value(reader, L"");
1453 }
1454
1455 test++;
1456 }
1457
1458 /* test reader depth increment */
1459 set_input_string(reader, stag);
1460
1461 i = 0;
1462 while (IXmlReader_Read(reader, &type) == S_OK)
1463 {
1464 UINT count;
1465
1467 type == XmlNodeType_Text, "Unexpected node type %d\n", type);
1468
1469 depth = 123;
1470 hr = IXmlReader_GetDepth(reader, &depth);
1471 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1472 ok(depth == depths[i], "%u: got depth %u, expected %u\n", i, depth, depths[i]);
1473
1475 {
1476 const WCHAR *prefix;
1477
1478 prefix = NULL;
1479 hr = IXmlReader_GetPrefix(reader, &prefix, NULL);
1480 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1481 ok(prefix != NULL, "got %p\n", prefix);
1482
1483 if (!*prefix)
1484 {
1485 const WCHAR *local, *qname;
1486
1487 local = NULL;
1488 hr = IXmlReader_GetLocalName(reader, &local, NULL);
1489 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1490 ok(local != NULL, "got %p\n", local);
1491
1492 qname = NULL;
1493 hr = IXmlReader_GetQualifiedName(reader, &qname, NULL);
1494 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1495 ok(qname != NULL, "got %p\n", qname);
1496
1497 ok(local == qname, "expected same pointer\n");
1498 }
1499 }
1500
1502 {
1503 count = 1;
1504 hr = IXmlReader_GetAttributeCount(reader, &count);
1505 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1506 ok(count == 0, "got %u\n", count);
1507 }
1508
1510 {
1511 count = 0;
1512 hr = IXmlReader_GetAttributeCount(reader, &count);
1513 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1514
1515 /* moving to attributes increases depth */
1516 if (count)
1517 {
1518 const WCHAR *value;
1519
1520 reader_value(reader, L"");
1521
1522 hr = IXmlReader_MoveToFirstAttribute(reader);
1523 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1524
1525 hr = IXmlReader_GetValue(reader, &value, NULL);
1526 ok(*value != 0, "Unexpected value %s\n", wine_dbgstr_w(value));
1527
1528 depth = 123;
1529 hr = IXmlReader_GetDepth(reader, &depth);
1530 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1531 ok(depth == depths[i] + 1, "%u: got depth %u, expected %u\n", i, depth, depths[i] + 1);
1532
1534 reader_value(reader, L"");
1535
1536 depth = 123;
1537 hr = IXmlReader_GetDepth(reader, &depth);
1538 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1539 ok(depth == depths[i], "%u: got depth %u, expected %u\n", i, depth, depths[i]);
1540 }
1541 }
1542
1543 i++;
1544 }
1545
1546 /* start/end tag mismatch */
1547 set_input_string(reader, "<a></b>");
1548
1550
1552 hr = IXmlReader_Read(reader, &type);
1553 ok(hr == WC_E_ELEMENTMATCH, "Unexpected hr %#lx.\n", hr);
1554 ok(type == XmlNodeType_None, "got %d\n", type);
1556
1557 IXmlReader_Release(reader);
1558}
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
static struct test_entry element_tests[]
Definition: reader.c:1389
Character const *const prefix
Definition: tempnam.cpp:195
@ NC_E_UNDECLAREDPREFIX
Definition: xmllite.idl:199
@ WC_E_ELEMENTMATCH
Definition: xmllite.idl:172

Referenced by START_TEST().

◆ test_read_full()

static void test_read_full ( void  )
static

Definition at line 1251 of file reader.c.

1252{
1253 struct nodes_test *test = &misc_test;
1255 HRESULT hr;
1256 int i;
1257
1258 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
1259 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1260
1262
1263 i = 0;
1264 do
1265 {
1266 read_node(reader, test->nodes[i].type);
1267 reader_value(reader, test->nodes[i].value);
1268 } while(test->nodes[i++].type != XmlNodeType_None);
1269
1270 IXmlReader_Release(reader);
1271}
static struct nodes_test misc_test
Definition: reader.c:1229

Referenced by START_TEST().

◆ test_read_pending()

static void test_read_pending ( void  )
static

Definition at line 1562 of file reader.c.

1563{
1565 const WCHAR *value;
1567 HRESULT hr;
1568 int c;
1569
1570 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
1571 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1572
1573 hr = IXmlReader_SetInput(reader, (IUnknown*)&teststream);
1574 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1575
1576 /* first read call returns incomplete node, second attempt fails with E_PENDING */
1577 stream_readcall = 0;
1579 hr = IXmlReader_Read(reader, &type);
1580 ok(hr == S_OK || broken(hr == E_PENDING), "Unexpected hr %#lx.\n", hr);
1581 /* newer versions are happy when it's enough data to detect node type,
1582 older versions keep reading until it fails to read more */
1583 todo_wine
1584 ok(stream_readcall == 1 || broken(stream_readcall > 1), "got %d\n", stream_readcall);
1585 ok(type == XmlNodeType_Comment || broken(type == XmlNodeType_None), "got %d\n", type);
1586
1587 /* newer versions' GetValue() makes an attempt to read more */
1589 value = (void*)0xdeadbeef;
1590 hr = IXmlReader_GetValue(reader, &value, NULL);
1591 ok(hr == E_PENDING, "Unexpected hr %#lx.\n", hr);
1592 ok(value == NULL || broken(value == (void*)0xdeadbeef) /* Win8 sets it to NULL */, "got %p\n", value);
1593 ok(c < stream_readcall || broken(c == stream_readcall), "got %d, expected %d\n", stream_readcall, c+1);
1594
1595 IXmlReader_Release(reader);
1596}
#define E_PENDING
Definition: dinput.h:172
#define todo_wine
Definition: minitest.h:80
static int stream_readcall
Definition: reader.c:439

Referenced by START_TEST().

◆ test_read_pi()

static void test_read_pi ( void  )
static

Definition at line 1156 of file reader.c.

1157{
1158 struct test_entry *test = pi_tests;
1160 HRESULT hr;
1161
1162 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
1163 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1164
1165 while (test->xml)
1166 {
1168
1170
1172 hr = IXmlReader_Read(reader, &type);
1173 if (test->hr_broken)
1174 ok(hr == test->hr || broken(hr == test->hr_broken), "Unexpected hr %#lx, for %s.\n", hr, test->xml);
1175 else
1176 ok(hr == test->hr, "Unexpected hr %#lx, for %s.\n", hr, test->xml);
1177 if (hr == S_OK)
1178 {
1179 const WCHAR *str;
1180 UINT len;
1181
1182 ok(type == XmlNodeType_ProcessingInstruction, "got %d for %s\n", type, test->xml);
1183
1185
1186 len = 0;
1187 str = NULL;
1188 hr = IXmlReader_GetQualifiedName(reader, &str, &len);
1189 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1190 ok(len == lstrlenW(test->name), "got %u\n", len);
1191 ok(!lstrcmpW(str, test->name), "got %s\n", wine_dbgstr_w(str));
1192
1193 /* value */
1195 }
1196
1197 test++;
1198 }
1199
1200 IXmlReader_Release(reader);
1201}
static struct test_entry pi_tests[]
Definition: reader.c:1141

Referenced by START_TEST().

◆ test_read_public_dtd()

static void test_read_public_dtd ( void  )
static

Definition at line 1276 of file reader.c.

1277{
1279 const WCHAR *str;
1281 UINT len, count;
1282 HRESULT hr;
1283
1284 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
1285 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1286
1288 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1289
1291
1293
1294 count = 0;
1295 hr = IXmlReader_GetAttributeCount(reader, &count);
1296 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1297 ok(count == 2, "got %d\n", count);
1298
1299 hr = IXmlReader_MoveToFirstAttribute(reader);
1300 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1301
1303 hr = IXmlReader_GetNodeType(reader, &type);
1304 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1305 ok(type == XmlNodeType_Attribute, "got %d\n", type);
1306
1307 reader_name(reader, L"PUBLIC");
1308 reader_value(reader, L"pubid");
1309
1311
1313 hr = IXmlReader_GetNodeType(reader, &type);
1314 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1315 ok(type == XmlNodeType_Attribute, "got %d\n", type);
1316
1317 reader_name(reader, L"SYSTEM");
1318 reader_value(reader, L"externalid uri");
1319
1321 reader_name(reader, L"testdtd");
1322
1323 len = 0;
1324 str = NULL;
1325 hr = IXmlReader_GetQualifiedName(reader, &str, &len);
1326 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1327todo_wine {
1328 ok(len == 7, "got %u\n", len);
1329 ok(!lstrcmpW(str, L"testdtd"), "got %s\n", wine_dbgstr_w(str));
1330}
1331 IXmlReader_Release(reader);
1332}
static const char test_public_dtd[]
Definition: reader.c:1273
@ DtdProcessing_Parse
Definition: xmllite.idl:119
@ XmlReaderProperty_DtdProcessing
Definition: xmllite.idl:130
@ XmlNodeType_DocumentType
Definition: xmllite.idl:31

Referenced by START_TEST().

◆ test_read_state()

static void test_read_state ( IXmlReader *  reader,
XmlReadState  expected,
XmlReadState  exp_broken,
int  line 
)
static

Definition at line 246 of file reader.c.

248{
249 BOOL broken_state;
251
252 state = -1; /* invalid state value */
253 IXmlReader_GetProperty(reader, XmlReaderProperty_ReadState, &state);
254
255 if (exp_broken == expected)
256 broken_state = FALSE;
257 else
258 broken_state = broken(exp_broken == state);
259
260 ok_(__FILE__, line)(state == expected || broken_state, "Expected (%s), got (%s)\n",
262}
static const char * state_to_str(XmlReadState state)
Definition: reader.c:135

◆ test_read_system_dtd()

static void test_read_system_dtd ( void  )
static

Definition at line 1338 of file reader.c.

1339{
1341 const WCHAR *str;
1343 UINT len, count;
1344 HRESULT hr;
1345
1346 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
1347 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1348
1350 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1351
1353
1355
1356 count = 0;
1357 hr = IXmlReader_GetAttributeCount(reader, &count);
1358 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1359 ok(count == 1, "got %d\n", count);
1360
1361 hr = IXmlReader_MoveToFirstAttribute(reader);
1362 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1363
1365 hr = IXmlReader_GetNodeType(reader, &type);
1366 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1367 ok(type == XmlNodeType_Attribute, "got %d\n", type);
1368
1369 reader_name(reader, L"SYSTEM");
1370 reader_value(reader, L"externalid uri");
1371
1373 reader_name(reader, L"testdtd");
1374
1375 len = 0;
1376 str = NULL;
1377 hr = IXmlReader_GetQualifiedName(reader, &str, &len);
1378 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1379todo_wine {
1380 ok(len == 7, "got %u\n", len);
1381 ok(!lstrcmpW(str, L"testdtd"), "got %s\n", wine_dbgstr_w(str));
1382}
1383
1385
1386 IXmlReader_Release(reader);
1387}
static const char test_system_dtd[]
Definition: reader.c:1334

Referenced by START_TEST().

◆ test_read_text()

static void test_read_text ( void  )
static

Definition at line 1760 of file reader.c.

1761{
1762 struct test_entry *test = text_tests;
1764 HRESULT hr;
1765
1766 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
1767 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1768
1769 while (test->xml)
1770 {
1772
1774
1776 hr = IXmlReader_Read(reader, &type);
1777
1778 /* read one more to get to text node */
1780 {
1782 hr = IXmlReader_Read(reader, &type);
1783 }
1784 ok(hr == test->hr, "Unexpected hr %#lx, for %s.\n", hr, test->xml);
1785 if (hr == S_OK)
1786 {
1787 const WCHAR *str;
1788 UINT len;
1789
1790 ok(type == XmlNodeType_Text, "got %d for %s\n", type, test->xml);
1791
1792 reader_name(reader, L"");
1793
1794 str = NULL;
1795 hr = IXmlReader_GetLocalName(reader, &str, NULL);
1796 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1797 ok(*str == 0, "got %s\n", wine_dbgstr_w(str));
1798
1799 len = 1;
1800 str = NULL;
1801 hr = IXmlReader_GetQualifiedName(reader, &str, &len);
1802 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1803 ok(len == 0, "got %u\n", len);
1804 ok(*str == 0, "got %s\n", wine_dbgstr_w(str));
1805
1806 str = NULL;
1807 hr = IXmlReader_GetQualifiedName(reader, &str, NULL);
1808 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1809 ok(*str == 0, "got %s\n", wine_dbgstr_w(str));
1810
1811 /* value */
1813 }
1814
1815 test++;
1816 }
1817
1818 IXmlReader_Release(reader);
1819}
static struct test_entry text_tests[]
Definition: reader.c:1751

Referenced by START_TEST().

◆ test_read_xmldeclaration()

static void test_read_xmldeclaration ( void  )
static

Definition at line 837 of file reader.c.

838{
839 static const struct
840 {
841 WCHAR name[12];
842 WCHAR val[12];
843 } name_val[] =
844 {
845 { {'v','e','r','s','i','o','n',0}, {'1','.','0',0} },
846 { {'e','n','c','o','d','i','n','g',0}, {'U','T','F','-','8',0} },
847 { {'s','t','a','n','d','a','l','o','n','e',0}, {'y','e','s',0} }
848 };
851 HRESULT hr;
853 UINT count = 0, len, i;
854 BOOL ret;
855 const WCHAR *val;
856
857 hr = CreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
858 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
859
861
862 hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
863 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
864
865 hr = IXmlReader_GetAttributeCount(reader, &count);
866 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
867 ok(count == 0, "got %d\n", count);
868
869 /* try to move without attributes */
870 hr = IXmlReader_MoveToElement(reader);
871 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
872
873 hr = IXmlReader_MoveToNextAttribute(reader);
874 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
875
876 hr = IXmlReader_MoveToFirstAttribute(reader);
877 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
878
880
882
883 /* new version 1.2.x and 1.3.x properly update position for <?xml ?> */
884 TEST_READER_POSITION2(reader, 1, 3, ~0u, 55);
885
886 TEST_DEPTH(reader, 0);
888
890
891 /* check attributes */
893
894 TEST_DEPTH(reader, 1);
895
897 hr = IXmlReader_GetNodeType(reader, &type);
898 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
899 ok(type == XmlNodeType_Attribute, "got %d\n", type);
900
901 TEST_READER_POSITION2(reader, 1, 7, ~0u, 55);
902
903 /* try to move from last attribute */
906 hr = IXmlReader_MoveToNextAttribute(reader);
907 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
908
910 hr = IXmlReader_GetNodeType(reader, &type);
911 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
912 ok(type == XmlNodeType_Attribute, "got %d\n", type);
913
914 hr = IXmlReader_MoveToFirstAttribute(reader);
915 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
916 TEST_READER_POSITION2(reader, 1, 7, ~0u, 55);
917
918 hr = IXmlReader_GetAttributeCount(reader, NULL);
919 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
920
921 hr = IXmlReader_GetAttributeCount(reader, &count);
922 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
923 ok(count == 3, "Expected 3, got %d\n", count);
924
925 for (i = 0; i < count; i++)
926 {
927 len = 0;
928 hr = IXmlReader_GetLocalName(reader, &val, &len);
929 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
930 ok(len == lstrlenW(name_val[i].name), "expected %u, got %u\n", lstrlenW(name_val[i].name), len);
931 ok(!lstrcmpW(name_val[i].name, val), "expected %s, got %s\n", wine_dbgstr_w(name_val[i].name), wine_dbgstr_w(val));
932
933 len = 0;
934 hr = IXmlReader_GetValue(reader, &val, &len);
935 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
936 ok(len == lstrlenW(name_val[i].val), "expected %u, got %u\n", lstrlenW(name_val[i].val), len);
937 ok(!lstrcmpW(name_val[i].val, val), "expected %s, got %s\n", wine_dbgstr_w(name_val[i].val), wine_dbgstr_w(val));
938
939 hr = IXmlReader_MoveToNextAttribute(reader);
940 ok(hr == ((i < count - 1) ? S_OK : S_FALSE), "Unexpected hr %#lx.\n", hr);
941 }
942
943 TEST_DEPTH(reader, 1);
944
946 TEST_READER_POSITION2(reader, 1, 3, ~0u, 55);
947
949 hr = IXmlReader_GetNodeType(reader, &type);
950 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
951 ok(type == XmlNodeType_XmlDeclaration, "got %d\n", type);
952
954 hr = IXmlReader_Read(reader, &type);
955 /* newer versions return syntax error here cause document is incomplete,
956 it makes more sense than invalid char error */
957todo_wine {
958 ok(hr == WC_E_SYNTAX || broken(hr == WC_E_XMLCHARACTER), "Unexpected hr %#lx.\n", hr);
959 ok(type == XmlNodeType_None, "got %d\n", type);
960}
961 IStream_Release(stream);
962
963 /* test short variant */
965
966 hr = IXmlReader_SetInput(reader, (IUnknown *)stream);
967 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
968
970 TEST_READER_POSITION2(reader, 1, 3, ~0u, 21);
972
973 hr = IXmlReader_GetAttributeCount(reader, &count);
974 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
975 ok(count == 1, "expected 1, got %d\n", count);
976
977 ret = IXmlReader_IsEmptyElement(reader);
978 ok(!ret, "element should not be empty\n");
979
981 reader_name(reader, L"xml");
982
983 reader_qname(reader, L"xml");
984
985 /* check attributes */
987
988 type = -1;
989 hr = IXmlReader_GetNodeType(reader, &type);
990 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
991 ok(type == XmlNodeType_Attribute, "got %d\n", type);
992 TEST_READER_POSITION2(reader, 1, 7, ~0u, 21);
993
994 /* try to move from last attribute */
995 hr = IXmlReader_MoveToNextAttribute(reader);
996 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
997
999 TEST_READER_POSITION2(reader, 1, 23, ~0u, 40);
1001
1002 hr = IXmlReader_GetAttributeCount(reader, &count);
1003 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1004 ok(count == 0, "expected 0, got %d\n", count);
1005
1006 ret = IXmlReader_IsEmptyElement(reader);
1007 ok(ret, "element should be empty\n");
1008
1009 reader_value(reader, L"");
1010 reader_name(reader, L"RegistrationInfo");
1011
1012 type = -1;
1013 hr = IXmlReader_Read(reader, &type);
1014 todo_wine
1015 ok(hr == WC_E_SYNTAX || hr == WC_E_XMLCHARACTER /* XP */, "Unexpected hr %#lx.\n", hr);
1016 ok(type == XmlNodeType_None, "expected XmlNodeType_None, got %s\n", type_to_str(type));
1018 todo_wine
1020
1021 IStream_Release(stream);
1022
1023 /* No encoding attribute. */
1024 set_input_string(reader, "<?xml version=\"1.0\" standalone=\"yes\"?><a/>");
1025 hr = IXmlReader_Read(reader, &type);
1026 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1027 ok(type == XmlNodeType_XmlDeclaration, "got %d\n", type);
1028
1029 /* Just version attribute, no spaces. */
1030 set_input_string(reader, "<?xml version=\"1.0\"?><a/>");
1031 hr = IXmlReader_Read(reader, &type);
1032 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1033 ok(type == XmlNodeType_XmlDeclaration, "got %d\n", type);
1034
1035 set_input_string(reader, "<?xml version=\"1.0\"encoding=\"UTF-8\"?><a/>");
1036 hr = IXmlReader_Read(reader, &type);
1037 ok(hr == WC_E_XMLDECL, "Unexpected hr %#lx.\n", hr);
1038
1039 set_input_string(reader, "<?xml version=\"1.0\"standalone=\"yes\"?><a/>");
1040 hr = IXmlReader_Read(reader, &type);
1041 ok(hr == WC_E_XMLDECL, "Unexpected hr %#lx.\n", hr);
1042
1043 IXmlReader_Release(reader);
1044}
GLuint GLfloat * val
Definition: glext.h:7180
static const char xmldecl_full[]
Definition: reader.c:36
#define TEST_READER_POSITION(reader, line, pos)
Definition: reader.c:78
static const char * type_to_str(XmlNodeType type)
Definition: reader.c:160
static const char xmldecl_short[]
Definition: reader.c:37
#define TEST_READER_POSITION2(reader, line, pos, line_broken, pos_broken)
Definition: reader.c:80
Definition: name.c:39
@ WC_E_XMLDECL
Definition: xmllite.idl:177
@ WC_E_XMLCHARACTER
Definition: xmllite.idl:156

Referenced by START_TEST().

◆ test_reader_create()

static void test_reader_create ( void  )
static

Definition at line 513 of file reader.c.

514{
515 IXmlResolver *resolver;
516 IUnknown *input, *unk;
518 LONG_PTR dtd;
519 XmlNodeType nodetype;
520 HRESULT hr;
521
522 /* crashes native */
523 if (0)
524 {
525 CreateXmlReader(&IID_IXmlReader, NULL, NULL);
526 CreateXmlReader(NULL, (void**)&reader, NULL);
527 }
528
529 hr = CreateXmlReader(&IID_IStream, (void **)&unk, NULL);
530 ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr);
531
532 hr = CreateXmlReader(&IID_IUnknown, (void **)&unk, NULL);
533 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
534 hr = IUnknown_QueryInterface(unk, &IID_IXmlReader, (void **)&reader);
535 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
536 ok(unk == (IUnknown *)reader, "unexpected interface\n");
537 IXmlReader_Release(reader);
538 IUnknown_Release(unk);
539
540 hr = CreateXmlReader(&IID_IUnknown, (void **)&reader, NULL);
541 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
542 IXmlReader_Release(reader);
543
544 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
545 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
546
548
549 nodetype = XmlNodeType_Element;
550 hr = IXmlReader_GetNodeType(reader, &nodetype);
551 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
552 ok(nodetype == XmlNodeType_None, "got %d\n", nodetype);
553
554 /* crashes on XP, 2k3, works on newer versions */
555 if (0)
556 {
557 hr = IXmlReader_GetNodeType(reader, NULL);
558 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
559 }
560
561 resolver = (void*)0xdeadbeef;
562 hr = IXmlReader_GetProperty(reader, XmlReaderProperty_XmlResolver, (LONG_PTR*)&resolver);
563 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
564 ok(resolver == NULL, "got %p\n", resolver);
565
566 hr = IXmlReader_SetProperty(reader, XmlReaderProperty_XmlResolver, 0);
567 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
568
569 hr = IXmlReader_SetProperty(reader, XmlReaderProperty_XmlResolver, (LONG_PTR)&testresolver);
570 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
571
572 resolver = NULL;
573 hr = IXmlReader_GetProperty(reader, XmlReaderProperty_XmlResolver, (LONG_PTR*)&resolver);
574 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
575 ok(resolver == &testresolver, "got %p\n", resolver);
576 IXmlResolver_Release(resolver);
577
578 hr = IXmlReader_SetProperty(reader, XmlReaderProperty_XmlResolver, 0);
579 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
580
581 dtd = -1;
582 hr = IXmlReader_GetProperty(reader, XmlReaderProperty_DtdProcessing, &dtd);
583 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
584 ok(dtd == DtdProcessing_Prohibit, "got %Id\n", dtd);
585
586 dtd = 2;
587 hr = IXmlReader_SetProperty(reader, XmlReaderProperty_DtdProcessing, dtd);
588 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
589
590 hr = IXmlReader_SetProperty(reader, XmlReaderProperty_DtdProcessing, -1);
591 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
592
593 /* Null input pointer, releases previous input */
594 hr = IXmlReader_SetInput(reader, NULL);
595 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
596
598
599 /* test input interface selection sequence */
601 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
602
603 if (hr == S_OK)
604 {
605 input_iids.count = 0;
606 hr = IXmlReader_SetInput(reader, input);
607 ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr);
609 IUnknown_Release(input);
610 }
611 IXmlReader_Release(reader);
612}
GLenum GLenum GLenum input
Definition: glext.h:9031
static const IID * setinput_full_old[]
Definition: reader.c:96
static HRESULT testinput_createinstance(void **ppObj)
Definition: reader.c:402
#define ok_iids(got, exp, brk, todo)
Definition: reader.c:133
#define TEST_READER_STATE2(reader, state, brk)
Definition: reader.c:265
static const IID * setinput_full[]
Definition: reader.c:88
static IXmlResolver testresolver
Definition: reader.c:511
static input_iids_t input_iids
Definition: reader.c:114
@ DtdProcessing_Prohibit
Definition: xmllite.idl:118
@ XmlReaderProperty_XmlResolver
Definition: xmllite.idl:129

Referenced by START_TEST().

◆ test_reader_depth()

static void test_reader_depth ( IXmlReader *  reader,
UINT  depth,
UINT  brk,
int  line 
)
static

Definition at line 821 of file reader.c.

822{
824 UINT d = ~0u;
825
826 IXmlReader_GetDepth(reader, &d);
827
828 condition = d == depth;
829 if (brk != ~0u)
830 condition |= broken(d == brk);
831 ok_(__FILE__, line)(condition, "Unexpected nesting depth %u, expected %u\n", d, depth);
832}
GLenum condition
Definition: glext.h:9255
#define d
Definition: ke_i.h:81

◆ test_reader_pos()

static void test_reader_pos ( IXmlReader *  reader,
UINT  line,
UINT  pos,
UINT  line_broken,
UINT  pos_broken,
int  _line_ 
)
static

Definition at line 60 of file reader.c.

62{
63 UINT l = ~0u, p = ~0u;
64 BOOL broken_state;
65
66 IXmlReader_GetLineNumber(reader, &l);
67 IXmlReader_GetLinePosition(reader, &p);
68
69 if (line_broken == ~0u && pos_broken == ~0u)
70 broken_state = FALSE;
71 else
72 broken_state = broken((line_broken == ~0u ? line : line_broken) == l &&
73 (pos_broken == ~0u ? pos : pos_broken) == p);
74
75 ok_(__FILE__, _line_)((l == line && pos == p) || broken_state,
76 "Expected (%d,%d), got (%d,%d)\n", line, pos, l, p);
77}
r l[0]
Definition: byte_order.h:168
GLfloat GLfloat p
Definition: glext.h:8902

◆ test_reader_position()

static void test_reader_position ( void  )
static

Definition at line 2404 of file reader.c.

2405{
2406 static const char *xml = "<c:a xmlns:c=\"nsdef c\" b=\"attr b\">\n</c:a>";
2409 UINT position;
2410 HRESULT hr;
2411
2412 hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL);
2413 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2414
2416
2417 /* position methods with Null args */
2418 hr = IXmlReader_GetLineNumber(reader, NULL);
2419 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
2420
2421 hr = IXmlReader_GetLinePosition(reader, NULL);
2422 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
2423
2424 position = 123;
2425 hr = IXmlReader_GetLinePosition(reader, &position);
2426 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
2427 ok(position == 0, "got %u\n", position);
2428
2429 position = 123;
2430 hr = IXmlReader_GetLineNumber(reader, &position);
2431 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
2432 ok(position == 0, "got %u\n", position);
2433
2435
2438 hr = IXmlReader_Read(reader, &type);
2439 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2440 ok(type == XmlNodeType_Element, "got type %d\n", type);
2441 TEST_READER_POSITION2(reader, 1, 2, ~0u, 34);
2442
2444 TEST_READER_POSITION2(reader, 1, 6, ~0u, 34);
2445
2447 TEST_READER_POSITION2(reader, 1, 24, ~0u, 34);
2448
2450 TEST_READER_POSITION2(reader, 1, 2, ~0u, 34);
2451
2452 hr = IXmlReader_Read(reader, &type);
2453 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2454 ok(type == XmlNodeType_Whitespace, "got type %d\n", type);
2455 TEST_READER_POSITION2(reader, 1, 35, 2, 6);
2456
2457 hr = IXmlReader_Read(reader, &type);
2458 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2459 ok(type == XmlNodeType_EndElement, "got type %d\n", type);
2460 TEST_READER_POSITION2(reader, 2, 3, 2, 6);
2461
2462 hr = IXmlReader_SetInput(reader, NULL);
2463 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2466
2467 IXmlReader_Release(reader);
2468}

Referenced by START_TEST().

◆ test_reader_properties()

static void test_reader_properties ( void  )
static

Definition at line 1957 of file reader.c.

1958{
1961 HRESULT hr;
1962
1963 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
1964 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1965
1966 value = 0;
1967 hr = IXmlReader_GetProperty(reader, XmlReaderProperty_MaxElementDepth, &value);
1968 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1969 ok(value == 256, "Unexpected default max depth value %Id.\n", value);
1970
1971 hr = IXmlReader_SetProperty(reader, XmlReaderProperty_MultiLanguage, 0);
1972 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1973
1974 hr = IXmlReader_SetProperty(reader, XmlReaderProperty_MaxElementDepth, 0);
1975 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1976
1977 value = 256;
1978 hr = IXmlReader_GetProperty(reader, XmlReaderProperty_MaxElementDepth, &value);
1979 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1980 ok(value == 0, "Unexpected max depth value %Id.\n", value);
1981
1982 IXmlReader_Release(reader);
1983}
@ XmlReaderProperty_MultiLanguage
Definition: xmllite.idl:126

Referenced by START_TEST().

◆ test_reader_state()

static void test_reader_state ( void  )
static

Definition at line 778 of file reader.c.

779{
780 XmlNodeType nodetype;
782 HRESULT hr;
783
784 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
785 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
786
787 /* invalid arguments */
788 hr = IXmlReader_GetProperty(reader, XmlReaderProperty_ReadState, NULL);
789 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
790
791 /* attempt to read on closed reader */
793
794if (0)
795{
796 /* newer versions crash here, probably because no input was set */
797 hr = IXmlReader_Read(reader, &nodetype);
798 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
799}
800 set_input_string(reader, "xml");
802
803 nodetype = XmlNodeType_Element;
804 hr = IXmlReader_Read(reader, &nodetype);
806 ok(FAILED(hr), "Unexpected hr %#lx.\n", hr);
807 ok(nodetype == XmlNodeType_None, "Unexpected node type %d\n", nodetype);
808
811
812 nodetype = XmlNodeType_Element;
813 hr = IXmlReader_Read(reader, &nodetype);
815 ok(FAILED(hr), "Unexpected hr %#lx.\n", hr);
816 ok(nodetype == XmlNodeType_None, "Unexpected node type %d\n", nodetype);
817
818 IXmlReader_Release(reader);
819}
#define FAILED(hr)
Definition: intsafe.h:51

Referenced by START_TEST().

◆ test_readerinput()

static void test_readerinput ( void  )
static

Definition at line 614 of file reader.c.

615{
616 IXmlReaderInput *reader_input;
617 IXmlReader *reader, *reader2;
618 IUnknown *obj, *input;
619 IStream *stream, *stream2;
620 XmlNodeType nodetype;
621 HRESULT hr;
622 LONG ref;
623
625 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
627 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
628
630 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
631
632 ref = IStream_AddRef(stream);
633 ok(ref == 2, "Expected 2, got %ld.\n", ref);
634 IStream_Release(stream);
636 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
637
638 hr = IUnknown_QueryInterface(reader_input, &IID_IStream, (void**)&stream2);
639 ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr);
640
641 hr = IUnknown_QueryInterface(reader_input, &IID_ISequentialStream, (void**)&stream2);
642 ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr);
643
644 /* IXmlReaderInput grabs a stream reference */
645 ref = IStream_AddRef(stream);
646 ok(ref == 3, "Expected 3, got %ld.\n", ref);
647 IStream_Release(stream);
648
649 /* try ::SetInput() with valid IXmlReaderInput */
650 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
651 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
652
653 ref = IUnknown_AddRef(reader_input);
654 ok(ref == 2, "Expected 2, got %ld.\n", ref);
655 IUnknown_Release(reader_input);
656
657 hr = IXmlReader_SetInput(reader, reader_input);
658 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
659
661
662 nodetype = XmlNodeType_Element;
663 hr = IXmlReader_GetNodeType(reader, &nodetype);
664 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
665 ok(nodetype == XmlNodeType_None, "got %d\n", nodetype);
666
667 /* IXmlReader grabs a IXmlReaderInput reference */
668 ref = IUnknown_AddRef(reader_input);
669 ok(ref == 3, "Expected 3, got %ld.\n", ref);
670 IUnknown_Release(reader_input);
671
672 ref = IStream_AddRef(stream);
673 ok(ref == 4, "Expected 4, got %ld.\n", ref);
674 IStream_Release(stream);
675
676 /* reset input and check state */
677 hr = IXmlReader_SetInput(reader, NULL);
678 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
679
681
682 IXmlReader_Release(reader);
683
684 ref = IStream_AddRef(stream);
685 ok(ref == 3, "Expected 3, got %ld.\n", ref);
686 IStream_Release(stream);
687
688 ref = IUnknown_AddRef(reader_input);
689 ok(ref == 2, "Expected 2, got %ld.\n", ref);
690 IUnknown_Release(reader_input);
691
692 /* IID_IXmlReaderInput */
693 /* it returns a kind of private undocumented vtable incompatible with IUnknown,
694 so it's not a COM interface actually.
695 Such query will be used only to check if input is really IXmlReaderInput */
696 obj = (IUnknown*)0xdeadbeef;
697 hr = IUnknown_QueryInterface(reader_input, &IID_IXmlReaderInput, (void**)&obj);
698 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
699 ref = IUnknown_AddRef(reader_input);
700 ok(ref == 3, "Expected 3, got %ld.\n", ref);
701 IUnknown_Release(reader_input);
702
703 IUnknown_Release(reader_input);
704 IUnknown_Release(reader_input);
705 IStream_Release(stream);
706
707 /* test input interface selection sequence */
708 input = NULL;
710 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
711
712 input_iids.count = 0;
713 ref = IUnknown_AddRef(input);
714 ok(ref == 2, "Expected 2, got %ld.\n", ref);
715 IUnknown_Release(input);
717 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
719 /* IXmlReaderInput stores stream interface as IUnknown */
720 ref = IUnknown_AddRef(input);
721 ok(ref == 3, "Expected 3, got %ld.\n", ref);
722 IUnknown_Release(input);
723
724 hr = CreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
725 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
726
727 input_iids.count = 0;
728 ref = IUnknown_AddRef(reader_input);
729 ok(ref == 2, "Expected 2, got %ld.\n", ref);
730 IUnknown_Release(reader_input);
731 ref = IUnknown_AddRef(input);
732 ok(ref == 3, "Expected 3, got %ld.\n", ref);
733 IUnknown_Release(input);
734 hr = IXmlReader_SetInput(reader, reader_input);
735 ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr);
737
739
740 ref = IUnknown_AddRef(input);
741 ok(ref == 3, "Expected 3, got %ld.\n", ref);
742 IUnknown_Release(input);
743
744 ref = IUnknown_AddRef(reader_input);
745 ok(ref == 3 || broken(ref == 2) /* versions 1.0.x and 1.1.x - XP, Vista */,
746 "Expected 3, got %ld.\n", ref);
747 IUnknown_Release(reader_input);
748 /* repeat another time, no check or caching here */
749 input_iids.count = 0;
750 hr = IXmlReader_SetInput(reader, reader_input);
751 ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr);
753
754 /* another reader */
755 hr = CreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader2, NULL);
756 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
757
758 /* resolving from IXmlReaderInput to IStream/ISequentialStream is done at
759 ::SetInput() level, each time it's called */
760 input_iids.count = 0;
761 hr = IXmlReader_SetInput(reader2, reader_input);
762 ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr);
764
765 IXmlReader_Release(reader2);
766 IXmlReader_Release(reader);
767
768 IUnknown_Release(reader_input);
769
770 /* Using codepage */
772 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
773 IUnknown_Release(reader_input);
774
775 IUnknown_Release(input);
776}
HRESULT WINAPI CreateXmlReaderInputWithEncodingCodePage(IUnknown *stream, IMalloc *imalloc, UINT codepage, BOOL hint, const WCHAR *base_uri, IXmlReaderInput **input)
Definition: reader.c:3707
HRESULT WINAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream, IMalloc *imalloc, const WCHAR *encoding, BOOL hint, const WCHAR *base_uri, IXmlReaderInput **input)
Definition: reader.c:3695
static const IID * empty_seq[]
Definition: reader.c:110
static const IID * setinput_readerinput[]
Definition: reader.c:104
long LONG
Definition: pedump.c:60
Definition: send.c:48

Referenced by START_TEST().

◆ test_readvaluechunk()

static void test_readvaluechunk ( void  )
static

Definition at line 1598 of file reader.c.

1599{
1602 WCHAR buf[64];
1603 WCHAR b;
1604 HRESULT hr;
1605 UINT c;
1606
1607 hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
1608 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1609
1610 set_input_string(reader, "<!-- comment1 --><!-- comment2 -->");
1611
1612 hr = IXmlReader_Read(reader, &type);
1613 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1614 ok(type == XmlNodeType_Comment, "type = %u\n", type);
1615
1616 read_value_char(reader, ' ');
1617 read_value_char(reader, 'c');
1618
1619 /* portion read as chunk is skipped from resulting node value */
1620 reader_value(reader, L"omment1 ");
1621
1622 /* once value is returned/allocated it's not possible to read by chunk */
1623 c = 0;
1624 b = 0;
1625 hr = IXmlReader_ReadValueChunk(reader, &b, 1, &c);
1626 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
1627 ok(c == 0, "got %u\n", c);
1628 ok(b == 0, "got %x\n", b);
1629
1630 c = 0xdeadbeef;
1631 hr = IXmlReader_ReadValueChunk(reader, buf, 0, &c);
1632 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1633 ok(!c, "c = %u\n", c);
1634
1635 reader_value(reader, L"omment1 ");
1636
1637 /* read comment2 */
1639
1640 c = 0xdeadbeef;
1641 hr = IXmlReader_ReadValueChunk(reader, buf, 0, &c);
1642 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1643 ok(!c, "c = %u\n", c);
1644
1645 c = 0xdeadbeef;
1646 memset(buf, 0xcc, sizeof(buf));
1647 hr = IXmlReader_ReadValueChunk(reader, buf, ARRAY_SIZE(buf), &c);
1648 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1649 ok(c == 10, "got %u\n", c);
1650 ok(buf[c] == 0xcccc, "buffer overflow\n");
1651 buf[c] = 0;
1652 ok(!lstrcmpW(buf, L" comment2 "), "buf = %s\n", wine_dbgstr_w(buf));
1653
1654 c = 0xdeadbeef;
1655 memset(buf, 0xcc, sizeof(buf));
1656 hr = IXmlReader_ReadValueChunk(reader, buf, ARRAY_SIZE(buf), &c);
1657 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
1658 ok(!c, "got %u\n", c);
1659
1660 /* portion read as chunk is skipped from resulting node value */
1661 reader_value(reader, L"");
1662
1663 /* once value is returned/allocated it's not possible to read by chunk */
1664 c = 0xdeadbeef;
1665 b = 0xffff;
1666 hr = IXmlReader_ReadValueChunk(reader, &b, 1, &c);
1667 ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
1668 ok(c == 0, "got %u\n", c);
1669 ok(b == 0xffff, "got %x\n", b);
1670
1671 reader_value(reader, L"");
1672
1673 IXmlReader_Release(reader);
1674}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define b
Definition: ke_i.h:79
#define read_value_char(a, b)
Definition: reader.c:337
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ test_string_pointers()

static void test_string_pointers ( void  )
static

Definition at line 2470 of file reader.c.

2471{
2472 const WCHAR *ns, *nsq, *empty, *xmlns_ns, *xmlns_name, *name, *p, *q, *xml, *ptr, *value;
2474 HRESULT hr;
2475
2476 hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL);
2477 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2478
2479 set_input_string(reader, "<elem xmlns=\"myns\">myns<elem2 /></elem>");
2480
2482 empty = reader_value(reader, L"");
2483 ok(empty == reader_prefix(reader, L""), "empty != prefix\n");
2484 name = reader_name(reader, L"elem");
2485 ok(name == reader_qname(reader, L"elem"), "name != qname\n");
2486 ns = reader_namespace(reader, L"myns");
2487
2489 ptr = reader_value(reader, L"myns");
2490 if (ns != ptr)
2491 {
2492 win_skip("attr value is different than namespace pointer, assuming old xmllite\n");
2493 IXmlReader_Release(reader);
2494 return;
2495 }
2496 ok(ns == ptr, "ns != value\n");
2497 ok(empty == reader_prefix(reader, L""), "empty != prefix\n");
2498 xmlns_ns = reader_namespace(reader, L"http://www.w3.org/2000/xmlns/");
2499 xmlns_name = reader_name(reader, L"xmlns");
2500 ok(xmlns_name == reader_qname(reader, L"xmlns"), "xmlns_name != qname\n");
2501
2503 ok(ns != reader_value(reader, L"myns"), "ns == value\n");
2504 ok(empty == reader_prefix(reader, L""), "empty != prefix\n");
2505 ok(empty == reader_namespace(reader, L""), "empty != namespace\n");
2506 ok(empty == reader_name(reader, L""), "empty != name\n");
2507 ok(empty == reader_qname(reader, L""), "empty != qname\n");
2508
2510 ok(empty == reader_prefix(reader, L""), "empty != prefix\n");
2511 ok(ns == reader_namespace(reader, L"myns"), "empty != namespace\n");
2512
2514 ok(empty == reader_prefix(reader, L""), "empty != prefix\n");
2515 ok(name == reader_name(reader, L"elem"), "empty != name\n");
2516 ok(name == reader_qname(reader, L"elem"), "empty != qname\n");
2517 ok(ns == reader_namespace(reader, L"myns"), "empty != namespace\n");
2518
2519 set_input_string(reader, "<elem xmlns:p=\"myns\" xmlns:q=\"mynsq\"><p:elem2 q:attr=\"\"></p:elem2></elem>");
2520
2522 ok(empty == reader_prefix(reader, L""), "empty != prefix\n");
2523 name = reader_name(reader, L"elem");
2524 ok(empty == reader_namespace(reader, L""), "empty != namespace\n");
2525
2527 ns = reader_value(reader, L"myns");
2528 ok(xmlns_name == reader_prefix(reader, L"xmlns"), "xmlns_name != prefix\n");
2529 p = reader_name(reader, L"p");
2530 ok(xmlns_ns == reader_namespace(reader, L"http://www.w3.org/2000/xmlns/"), "xmlns_ns != namespace\n");
2531
2533 nsq = reader_value(reader, L"mynsq");
2534 ok(xmlns_name == reader_prefix(reader, L"xmlns"), "xmlns_name != prefix\n");
2535 q = reader_name(reader, L"q");
2536 ok(xmlns_ns == reader_namespace(reader, L"http://www.w3.org/2000/xmlns/"), "xmlns_ns != namespace\n");
2537
2539 ok(p == reader_prefix(reader, L"p"), "p != prefix\n");
2540 ok(ns == reader_namespace(reader, L"myns"), "empty != namespace\n");
2541 name = reader_qname(reader, L"p:elem2");
2542
2544 ok(empty != reader_value(reader, L""), "empty == value\n");
2545 ok(q == reader_prefix(reader, L"q"), "q != prefix\n");
2546 ok(nsq == reader_namespace(reader, L"mynsq"), "nsq != namespace\n");
2547
2549 ptr = reader_qname(reader, L"p:elem2"); todo_wine ok(name != ptr, "q == qname\n");
2550
2551 set_input_string(reader, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
2552
2554 ok(empty == reader_value(reader, L""), "empty != value\n");
2555 ok(empty == reader_prefix(reader, L""), "empty != prefix\n");
2556 xml = reader_name(reader, L"xml");
2557 ptr = reader_qname(reader, L"xml"); todo_wine ok(xml == ptr, "xml != qname\n");
2558 ok(empty == reader_namespace(reader, L""), "empty != namespace\n");
2559
2561 ok(empty == reader_prefix(reader, L""), "empty != prefix\n");
2562 ok(empty == reader_namespace(reader, L""), "empty != namespace\n");
2563
2564 set_input_string(reader, "<elem xmlns:p=\"myns\"><p:elem2 attr=\"\" /></elem>");
2565
2568 read_value_char(reader, 'm');
2569 p = reader_value(reader, L"yns");
2570
2572 ns = reader_namespace(reader, L"myns");
2573 ok(ns+1 == p, "ns+1 != p\n");
2574
2575 set_input_string(reader, "<elem attr=\"value\"></elem>");
2576
2579 name = reader_name(reader, L"attr");
2580 value = reader_value(reader, L"value");
2581
2584 ok(name == reader_name(reader, L"attr"), "attr pointer changed\n");
2585 ok(value == reader_value(reader, L"value"), "value pointer changed\n");
2586
2587 IXmlReader_Release(reader);
2588}
static const WCHAR empty[1]
Definition: string.c:47
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
#define win_skip
Definition: minitest.h:67
Definition: mxnamespace.c:38

Referenced by START_TEST().

◆ testinput_AddRef()

static ULONG WINAPI testinput_AddRef ( IUnknown *  iface)
static

Definition at line 377 of file reader.c.

378{
380 return InterlockedIncrement(&This->ref);
381}
#define InterlockedIncrement
Definition: armddk.h:53
static testinput * impl_from_IUnknown(IUnknown *iface)
Definition: reader.c:356

◆ testinput_createinstance()

static HRESULT testinput_createinstance ( void **  ppObj)
static

Definition at line 402 of file reader.c.

403{
405
406 input = malloc(sizeof(*input));
407 if(!input) return E_OUTOFMEMORY;
408
409 input->IUnknown_iface.lpVtbl = &testinput_vtbl;
410 input->ref = 1;
411
412 *ppObj = &input->IUnknown_iface;
413
414 return S_OK;
415}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define malloc
Definition: debug_ros.c:4
static const struct IUnknownVtbl testinput_vtbl
Definition: reader.c:395

Referenced by test_reader_create(), and test_readerinput().

◆ testinput_QueryInterface()

static HRESULT WINAPI testinput_QueryInterface ( IUnknown *  iface,
REFIID  riid,
void **  ppvObj 
)
static

Definition at line 361 of file reader.c.

362{
364 {
365 *ppvObj = iface;
366 IUnknown_AddRef(iface);
367 return S_OK;
368 }
369
371
372 *ppvObj = NULL;
373
374 return E_NOINTERFACE;
375}

◆ testinput_Release()

static ULONG WINAPI testinput_Release ( IUnknown *  iface)
static

Definition at line 383 of file reader.c.

384{
386 LONG ref;
387
389 if (ref == 0)
390 free(input);
391
392 return ref;
393}
#define InterlockedDecrement
Definition: armddk.h:52
#define free
Definition: debug_ros.c:5

◆ teststream_AddRef()

static ULONG WINAPI teststream_AddRef ( ISequentialStream *  iface)
static

Definition at line 429 of file reader.c.

430{
431 return 2;
432}

◆ teststream_QueryInterface()

static HRESULT WINAPI teststream_QueryInterface ( ISequentialStream *  iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 417 of file reader.c.

418{
419 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_ISequentialStream))
420 {
421 *obj = iface;
422 return S_OK;
423 }
424
425 *obj = NULL;
426 return E_NOINTERFACE;
427}

◆ teststream_Read()

static HRESULT WINAPI teststream_Read ( ISequentialStream *  iface,
void *  pv,
ULONG  cb,
ULONG *  pread 
)
static

Definition at line 441 of file reader.c.

442{
443 static const char xml[] = "<!-- comment -->";
444
445 if (stream_readcall++)
446 {
447 *pread = 0;
448 return E_PENDING;
449 }
450
451 *pread = sizeof(xml) / 2;
452 memcpy(pv, xml, *pread);
453 return S_OK;
454}
ssize_t pread(int fd, void *buf, size_t count, off_t offset)

◆ teststream_Release()

static ULONG WINAPI teststream_Release ( ISequentialStream *  iface)
static

Definition at line 434 of file reader.c.

435{
436 return 1;
437}

◆ teststream_Write()

static HRESULT WINAPI teststream_Write ( ISequentialStream *  iface,
const void *  pv,
ULONG  cb,
ULONG *  written 
)
static

Definition at line 456 of file reader.c.

457{
458 ok(0, "unexpected call\n");
459 return E_NOTIMPL;
460}

◆ type_to_str()

static const char * type_to_str ( XmlNodeType  type)
static

Definition at line 160 of file reader.c.

161{
162 static const char* type_names[] = {
163 "XmlNodeType_None",
164 "XmlNodeType_Element",
165 "XmlNodeType_Attribute",
166 "XmlNodeType_Text",
167 "XmlNodeType_CDATA",
168 "", "",
169 "XmlNodeType_ProcessingInstruction",
170 "XmlNodeType_Comment",
171 "",
172 "XmlNodeType_DocumentType",
173 "", "",
174 "XmlNodeType_Whitespace",
175 "",
176 "XmlNodeType_EndElement",
177 "",
178 "XmlNodeType_XmlDeclaration"
179 };
180
181 static const char unknown[] = "unknown";
182
183 switch (type)
184 {
185 case XmlNodeType_None:
188 case XmlNodeType_Text:
196 return type_names[type];
197 default:
198 return unknown;
199 }
200}

Referenced by test_read_xmldeclaration().

Variable Documentation

◆ attributes_tests

struct test_entry attributes_tests[]
static
Initial value:
=
{
{ "<a attr1=\"attrvalue\"/>", L"attr1", L"attrvalue", S_OK },
{ "<a attr1=\"a\'\'ttrvalue\"/>", L"attr1", L"a\'\'ttrvalue", S_OK },
{ "<a attr1=\'a\"ttrvalue\'/>", L"attr1", L"a\"ttrvalue", S_OK },
{ "<a attr1=\' \'/>", L"attr1", L" ", S_OK },
{ "<a attr1=\" \"/>", L"attr1", L" ", S_OK },
{ "<a attr1=\"\r\n \r \n \t\n\r\"/>", L"attr1", L" ", S_OK },
{ "<a attr1=\" val \"/>", L"attr1", L" val ", S_OK },
{ "<a attr1=\"\r\n\tval\n\"/>", L"attr1", L" val ", S_OK },
{ "<a attr1=\"val&#32;\"/>", L"attr1", L"val ", S_OK },
{ "<a attr1=\"val&#x20;\"/>", L"attr1", L"val ", S_OK },
{ "<a attr1=\"&lt;&gt;&amp;&apos;&quot;\"/>", L"attr1", L"<>&\'\"", S_OK },
{ "<a attr1=\"&entname;\"/>", NULL, NULL, WC_E_UNDECLAREDENTITY },
{ "<a attr1=\"val&#xfffe;\"/>", NULL, NULL, WC_E_XMLCHARACTER },
{ "<a attr1=\"val &#a;\"/>", NULL, NULL, WC_E_DIGIT, WC_E_SEMICOLON },
{ "<a attr1=\"val &#12a;\"/>", NULL, NULL, WC_E_SEMICOLON },
{ "<a attr1=\"val &#x12g;\"/>", NULL, NULL, WC_E_SEMICOLON },
{ "<a attr1=\"val &#xg;\"/>", NULL, NULL, WC_E_HEXDIGIT, WC_E_SEMICOLON },
{ "<a attr1=attrvalue/>", NULL, NULL, WC_E_QUOTE },
{ "<a attr1=\"attr<value\"/>", NULL, NULL, WC_E_LESSTHAN },
{ "<a attr1=\"&entname\"/>", NULL, NULL, WC_E_SEMICOLON },
{ NULL }
}
@ WC_E_LESSTHAN
Definition: xmllite.idl:151
@ WC_E_DIGIT
Definition: xmllite.idl:153
@ WC_E_UNDECLAREDENTITY
Definition: xmllite.idl:184
@ WC_E_SEMICOLON
Definition: xmllite.idl:147
@ WC_E_QUOTE
Definition: xmllite.idl:149
@ WC_E_HEXDIGIT
Definition: xmllite.idl:152

Definition at line 1878 of file reader.c.

Referenced by test_read_attribute().

◆ cdata_tests

struct test_entry cdata_tests[]
static
Initial value:
=
{
{ "<a><![CDATA[ ]]data ]]></a>", L"", L" ]]data ", S_OK },
{ "<a><![CDATA[<![CDATA[ data ]]]]></a>", L"", L"<![CDATA[ data ]]", S_OK },
{ "<a><![CDATA[\n \r\n \n\n ]]></a>", L"", L"\n \n \n\n ", S_OK, S_OK },
{ "<a><![CDATA[\r \r\r\n \n\n ]]></a>", L"", L"\n \n\n \n\n ", S_OK, S_OK },
{ "<a><![CDATA[\r\r \n\r \r \n\n ]]></a>", L"", L"\n\n \n\n \n \n\n ", S_OK },
{ NULL }
}

Definition at line 1676 of file reader.c.

Referenced by test_read_cdata().

◆ comment_tests

struct test_entry comment_tests[]
static
Initial value:
=
{
{ "<!-- comment -->", L"", L" comment ", S_OK },
{ "<!-- - comment-->", L"", L" - comment", S_OK },
{ "<!-- -- comment-->", NULL, NULL, WC_E_COMMENT, WC_E_GREATERTHAN },
{ "<!-- -- comment--->", NULL, NULL, WC_E_COMMENT, WC_E_GREATERTHAN },
{ NULL }
}
@ WC_E_GREATERTHAN
Definition: xmllite.idl:148
@ WC_E_COMMENT
Definition: xmllite.idl:160

Definition at line 1056 of file reader.c.

Referenced by test_read_comment().

◆ element_tests

struct test_entry element_tests[]
static
Initial value:
=
{
{ "<a/>", L"a", L"", S_OK },
{ "<a />", L"a", L"", S_OK },
{ "<a:b/>", L"a:b", L"", NC_E_UNDECLAREDPREFIX },
{ "<:a/>", NULL, NULL, NC_E_QNAMECHARACTER },
{ "< a/>", NULL, NULL, NC_E_QNAMECHARACTER },
{ "<a>", L"a", L"", S_OK },
{ "<a >", L"a", L"", S_OK },
{ "<a \r \t\n>", L"a", L"", S_OK },
{ "</a>", NULL, NULL, NC_E_QNAMECHARACTER },
{ "<a:b:c />", NULL, NULL, NC_E_QNAMECOLON },
{ "<:b:c />", NULL, NULL, NC_E_QNAMECHARACTER },
{ NULL }
}
@ NC_E_QNAMECOLON
Definition: xmllite.idl:196
@ NC_E_QNAMECHARACTER
Definition: xmllite.idl:195

Definition at line 1389 of file reader.c.

Referenced by test_read_element().

◆ empty_element_tests

struct test_entry_empty empty_element_tests[]
static
Initial value:
= {
{ "<a></a>", FALSE },
{ "<a/>", TRUE },
{ NULL }
}

Definition at line 1826 of file reader.c.

Referenced by test_isemptyelement().

◆ empty_seq

const IID* empty_seq[]
static
Initial value:
= {
}

Definition at line 110 of file reader.c.

Referenced by test_readerinput().

◆ input_iids

input_iids_t input_iids
static

Definition at line 114 of file reader.c.

Referenced by test_reader_create(), test_readerinput(), and testinput_QueryInterface().

◆ misc_test

struct nodes_test misc_test
static
Initial value:
= {
{
{ XmlNodeType_Comment, L" comment1 " },
{ XmlNodeType_Comment, L" comment2 " },
{ XmlNodeType_Comment, L" comment3 " },
{ XmlNodeType_Whitespace, L" \t \n \n" },
{ XmlNodeType_Comment, L" comment4 " },
{ XmlNodeType_Text, L"text" },
{ XmlNodeType_Comment, L" comment " },
{ XmlNodeType_Text, L"text2" },
}
}
static const char misc_test_xml[]
Definition: reader.c:1211

Definition at line 1229 of file reader.c.

Referenced by test_read_full().

◆ misc_test_xml

const char misc_test_xml[]
static
Initial value:
=
"<!-- comment1 -->"
"<!-- comment2 -->"
"<?pi1 pi1body ?>"
"<!-- comment3 -->"
" \t \r \n"
"<!-- comment4 -->"
"<a>"
"\r\n\t"
"<b/>"
"text"
"<!-- comment -->"
"text2"
"<?pi pibody ?>"
"\r\n"
"</a>"

Definition at line 1211 of file reader.c.

◆ pi_tests

struct test_entry pi_tests[]
static
Initial value:
=
{
{ "<?pi?>", L"pi", L"", S_OK },
{ "<?pi ?>", L"pi", L"", S_OK },
{ "<?pi ?>", L"pi", L"", S_OK },
{ "<?pi pi data?>", L"pi", L"pi data", S_OK },
{ "<?pi pi data ?>", L"pi", L"pi data ", S_OK },
{ "<?pi data ?>", L"pi", L"data ", S_OK },
{ "<?:pi ?>", NULL, NULL, WC_E_PI, WC_E_NAMECHARACTER },
{ "<?-pi ?>", NULL, NULL, WC_E_PI, WC_E_NAMECHARACTER },
{ "<?xml-stylesheet ?>", L"xml-stylesheet", L"", S_OK },
{ NULL }
}
@ WC_E_PI
Definition: xmllite.idl:187
@ WC_E_NAMECHARACTER
Definition: xmllite.idl:157
@ NC_E_NAMECOLON
Definition: xmllite.idl:197

Definition at line 1141 of file reader.c.

Referenced by test_read_pi().

◆ resolvervtbl

const IXmlResolverVtbl resolvervtbl
static
Initial value:
=
{
}
static HRESULT WINAPI resolver_ResolveUri(IXmlResolver *iface, const WCHAR *base_uri, const WCHAR *public_id, const WCHAR *system_id, IUnknown **input)
Definition: reader.c:496
static HRESULT WINAPI resolver_QI(IXmlResolver *iface, REFIID riid, void **obj)
Definition: reader.c:471
static ULONG WINAPI resolver_AddRef(IXmlResolver *iface)
Definition: reader.c:486
static ULONG WINAPI resolver_Release(IXmlResolver *iface)
Definition: reader.c:491

Definition at line 503 of file reader.c.

◆ setinput_full

const IID* setinput_full[]
static
Initial value:
= {
&IID_IXmlReaderInput,
&IID_IStream,
&IID_ISequentialStream,
}

Definition at line 88 of file reader.c.

Referenced by test_reader_create().

◆ setinput_full_old

const IID* setinput_full_old[]
static
Initial value:
= {
&IID_IXmlReaderInput,
&IID_ISequentialStream,
&IID_IStream,
}

Definition at line 96 of file reader.c.

Referenced by test_reader_create().

◆ setinput_readerinput

const IID* setinput_readerinput[]
static
Initial value:
= {
&IID_IStream,
&IID_ISequentialStream,
}

Definition at line 104 of file reader.c.

Referenced by test_readerinput().

◆ stream_readcall

int stream_readcall
static

Definition at line 439 of file reader.c.

Referenced by test_read_pending(), and teststream_Read().

◆ test_public_dtd

const char test_public_dtd[]
static
Initial value:
=
"<!DOCTYPE testdtd PUBLIC \"pubid\" \"externalid uri\" >"

Definition at line 1273 of file reader.c.

Referenced by test_read_public_dtd().

◆ test_system_dtd

const char test_system_dtd[]
static
Initial value:
=
"<!DOCTYPE testdtd SYSTEM \"externalid uri\" >"
"<!-- comment -->"

Definition at line 1334 of file reader.c.

Referenced by test_read_system_dtd().

◆ testinput_vtbl

const struct IUnknownVtbl testinput_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI testinput_AddRef(IUnknown *iface)
Definition: reader.c:377
static HRESULT WINAPI testinput_QueryInterface(IUnknown *iface, REFIID riid, void **ppvObj)
Definition: reader.c:361
static ULONG WINAPI testinput_Release(IUnknown *iface)
Definition: reader.c:383

Definition at line 395 of file reader.c.

Referenced by testinput_createinstance().

◆ testresolver

IXmlResolver testresolver = { &resolvervtbl }
static

Definition at line 511 of file reader.c.

Referenced by test_reader_create().

◆ teststream

Definition at line 1560 of file reader.c.

◆ teststreamvtbl

const ISequentialStreamVtbl teststreamvtbl
static
Initial value:
=
{
}
static HRESULT WINAPI teststream_QueryInterface(ISequentialStream *iface, REFIID riid, void **obj)
Definition: reader.c:417
static HRESULT WINAPI teststream_Write(ISequentialStream *iface, const void *pv, ULONG cb, ULONG *written)
Definition: reader.c:456
static ULONG WINAPI teststream_AddRef(ISequentialStream *iface)
Definition: reader.c:429
static ULONG WINAPI teststream_Release(ISequentialStream *iface)
Definition: reader.c:434
static HRESULT WINAPI teststream_Read(ISequentialStream *iface, void *pv, ULONG cb, ULONG *pread)
Definition: reader.c:441

Definition at line 462 of file reader.c.

◆ text_tests

struct test_entry text_tests[]
static
Initial value:
=
{
{ "<a>simple text</a>", L"", L"simple text", S_OK },
{ "<a>text ]]> text</a>", L"", L"", WC_E_CDSECTEND },
{ "<a>\n \r\n \n\n text</a>", L"", L"\n \n \n\n text", S_OK, S_OK },
{ "<a>\r \r\r\n \n\n text</a>", L"", L"\n \n\n \n\n text", S_OK, S_OK },
{ NULL }
}
@ WC_E_CDSECTEND
Definition: xmllite.idl:190

Definition at line 1751 of file reader.c.

Referenced by test_read_text().

◆ xmldecl_full

const char xmldecl_full[] = "\xef\xbb\xbf<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
static

Definition at line 36 of file reader.c.

Referenced by test_read_xmldeclaration().

◆ xmldecl_short

const char xmldecl_short[] = "<?xml version=\"1.0\"?><RegistrationInfo/>"
static

Definition at line 37 of file reader.c.

Referenced by test_read_xmldeclaration().