xmllite/tests: Some tests for returned namespace prefixes and uris.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
682d4f147c
commit
dec0e47149
|
@ -1906,6 +1906,139 @@ static void test_reader_properties(void)
|
||||||
IXmlReader_Release(reader);
|
IXmlReader_Release(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_prefix(void)
|
||||||
|
{
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
const char *xml;
|
||||||
|
const char *prefix1;
|
||||||
|
const char *prefix2;
|
||||||
|
const char *prefix3;
|
||||||
|
} prefix_tests[] =
|
||||||
|
{
|
||||||
|
{ "<b xmlns=\"defns\" xml:a=\"a ns\"/>", "", "", "xml" },
|
||||||
|
};
|
||||||
|
IXmlReader *reader;
|
||||||
|
unsigned int i;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||||
|
ok(hr == S_OK, "S_OK, got %08x\n", hr);
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(prefix_tests)/sizeof(prefix_tests[0]); i++) {
|
||||||
|
const WCHAR *prefix;
|
||||||
|
XmlNodeType type;
|
||||||
|
WCHAR *expected;
|
||||||
|
IStream *stream;
|
||||||
|
|
||||||
|
stream = create_stream_on_data(prefix_tests[i].xml, strlen(prefix_tests[i].xml) + 1);
|
||||||
|
hr = IXmlReader_SetInput(reader, (IUnknown *)stream);
|
||||||
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
|
|
||||||
|
hr = IXmlReader_Read(reader, &type);
|
||||||
|
ok(hr == S_OK, "Read() failed, %#x\n", hr);
|
||||||
|
ok(type == XmlNodeType_Element, "Unexpected node type %d.\n", type);
|
||||||
|
|
||||||
|
expected = a2w(prefix_tests[i].prefix1);
|
||||||
|
hr = IXmlReader_GetPrefix(reader, &prefix, NULL);
|
||||||
|
ok(hr == S_OK, "GetPrefix() failed, %#x.\n", hr);
|
||||||
|
ok(!lstrcmpW(prefix, expected), "Unexpected prefix %s, expected %s.\n", wine_dbgstr_w(prefix),
|
||||||
|
wine_dbgstr_w(expected));
|
||||||
|
free_str(expected);
|
||||||
|
|
||||||
|
hr = IXmlReader_MoveToFirstAttribute(reader);
|
||||||
|
ok(hr == S_OK, "MoveToFirstAttribute() failed, %#x.\n", hr);
|
||||||
|
|
||||||
|
hr = IXmlReader_GetNodeType(reader, &type);
|
||||||
|
ok(hr == S_OK, "GetNodeType() failed, %#x.\n", hr);
|
||||||
|
ok(type == XmlNodeType_Attribute, "Unexpected node type %d.\n", type);
|
||||||
|
|
||||||
|
expected = a2w(prefix_tests[i].prefix2);
|
||||||
|
hr = IXmlReader_GetPrefix(reader, &prefix, NULL);
|
||||||
|
ok(hr == S_OK, "GetPrefix() failed, %#x.\n", hr);
|
||||||
|
ok(!lstrcmpW(prefix, expected), "Unexpected prefix %s, expected %s.\n", wine_dbgstr_w(prefix),
|
||||||
|
wine_dbgstr_w(expected));
|
||||||
|
free_str(expected);
|
||||||
|
|
||||||
|
hr = IXmlReader_MoveToNextAttribute(reader);
|
||||||
|
ok(hr == S_OK, "MoveToNextAttribute() failed, %#x.\n", hr);
|
||||||
|
|
||||||
|
hr = IXmlReader_GetNodeType(reader, &type);
|
||||||
|
ok(hr == S_OK, "GetNodeType() failed, %#x.\n", hr);
|
||||||
|
ok(type == XmlNodeType_Attribute, "Unexpected node type %d.\n", type);
|
||||||
|
|
||||||
|
expected = a2w(prefix_tests[i].prefix3);
|
||||||
|
hr = IXmlReader_GetPrefix(reader, &prefix, NULL);
|
||||||
|
ok(hr == S_OK, "GetPrefix() failed, %#x.\n", hr);
|
||||||
|
ok(!lstrcmpW(prefix, expected), "Unexpected prefix %s, expected %s.\n", wine_dbgstr_w(prefix),
|
||||||
|
wine_dbgstr_w(expected));
|
||||||
|
free_str(expected);
|
||||||
|
|
||||||
|
IStream_Release(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
IXmlReader_Release(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_namespaceuri(void)
|
||||||
|
{
|
||||||
|
struct uri_test
|
||||||
|
{
|
||||||
|
const char *xml;
|
||||||
|
const char *uri[5];
|
||||||
|
} uri_tests[] =
|
||||||
|
{
|
||||||
|
{ "<a xmlns=\"defns a\"><b xmlns=\"defns b\"><c xmlns=\"defns c\"/></b></a>",
|
||||||
|
{ "defns a", "defns b", "defns c", "defns b", "defns a" }},
|
||||||
|
{ "<r:a xmlns=\"defns a\" xmlns:r=\"ns r\"/>",
|
||||||
|
{ "ns r" }},
|
||||||
|
{ "<r:a xmlns=\"defns a\" xmlns:r=\"ns r\"><b/></r:a>",
|
||||||
|
{ "ns r", "defns a", "ns r" }},
|
||||||
|
{ "<a xmlns=\"defns a\" xmlns:r=\"ns r\"><r:b/></a>",
|
||||||
|
{ "defns a", "ns r", "defns a" }},
|
||||||
|
{ "<a><b><c/></b></a>",
|
||||||
|
{ "", "", "", "", "" }},
|
||||||
|
};
|
||||||
|
IXmlReader *reader;
|
||||||
|
XmlNodeType type;
|
||||||
|
unsigned int i;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
|
||||||
|
ok(hr == S_OK, "S_OK, got %08x\n", hr);
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); i++) {
|
||||||
|
IStream *stream = create_stream_on_data(uri_tests[i].xml, strlen(uri_tests[i].xml) + 1);
|
||||||
|
unsigned int j = 0;
|
||||||
|
|
||||||
|
hr = IXmlReader_SetInput(reader, (IUnknown *)stream);
|
||||||
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
|
|
||||||
|
while (IXmlReader_Read(reader, &type) == S_OK) {
|
||||||
|
const WCHAR *uri, *local;
|
||||||
|
WCHAR *uriW;
|
||||||
|
|
||||||
|
ok(type == XmlNodeType_Element || type == XmlNodeType_EndElement, "Unexpected node type %d.\n", type);
|
||||||
|
|
||||||
|
hr = IXmlReader_GetLocalName(reader, &local, NULL);
|
||||||
|
ok(hr == S_OK, "S_OK, got %08x\n", hr);
|
||||||
|
|
||||||
|
hr = IXmlReader_GetNamespaceUri(reader, &uri, NULL);
|
||||||
|
ok(hr == S_OK, "S_OK, got %08x\n", hr);
|
||||||
|
|
||||||
|
uriW = a2w(uri_tests[i].uri[j]);
|
||||||
|
ok(!lstrcmpW(uriW, uri), "%s: uri %s\n", wine_dbgstr_w(local), wine_dbgstr_w(uri));
|
||||||
|
free_str(uriW);
|
||||||
|
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
|
||||||
|
IStream_Release(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
IXmlReader_Release(reader);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(reader)
|
START_TEST(reader)
|
||||||
{
|
{
|
||||||
test_reader_create();
|
test_reader_create();
|
||||||
|
@ -1925,4 +2058,6 @@ START_TEST(reader)
|
||||||
test_readvaluechunk();
|
test_readvaluechunk();
|
||||||
test_read_xmldeclaration();
|
test_read_xmldeclaration();
|
||||||
test_reader_properties();
|
test_reader_properties();
|
||||||
|
test_prefix();
|
||||||
|
test_namespaceuri();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue