{
XML_Memory_Handling_Suite memsuite = { duff_allocator, realloc, free };
unsigned int i;
-#define MAX_ALLOC_COUNT 10
+ const unsigned int max_alloc_count = 10;
/* Something this simple shouldn't need more than 10 allocations */
- for (i = 0; i < MAX_ALLOC_COUNT; i++)
+ for (i = 0; i < max_alloc_count; i++)
{
allocation_count = i;
parser = XML_ParserCreate_MM(NULL, &memsuite, NULL);
}
if (i == 0)
fail("Parser unexpectedly ignored failing allocator");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parser not created with max allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test memory allocation failures for a parser with an encoding */
{
XML_Memory_Handling_Suite memsuite = { duff_allocator, realloc, free };
unsigned int i;
-#define MAX_ALLOC_COUNT 10
+ const unsigned int max_alloc_count = 10;
/* Try several levels of allocation */
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
parser = XML_ParserCreate_MM("us-ascii", &memsuite, NULL);
if (parser != NULL)
}
if (i == 0)
fail("Parser ignored failing allocator");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parser not created with max allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test that freeing a NULL parser doesn't cause an explosion.
"<?xml version='1.0' encoding='utf-8'?>\n"
"<doc>Hello, world</doc>";
int i;
-#define MAX_ALLOC_COUNT 15
+ const int max_alloc_count = 15;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetXmlDeclHandler(parser, dummy_xdecl_handler);
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
}
if (i == 0)
fail("Parse succeeded despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed with max allocations");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* As above, but with an encoding big enough to cause storing the
"'?>"
"<doc>Hello, world</doc>";
int i;
-#define MAX_ALLOC_COUNT 20
+ const int max_alloc_count = 20;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetXmlDeclHandler(parser, dummy_xdecl_handler);
XML_SetUnknownEncodingHandler(parser, long_encoding_handler, NULL);
}
if (i == 0)
fail("Parse succeeded despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed with max allocations");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test the effects of allocation failures on a straightforward parse */
"Hello, world"
"</doc>";
int i;
-#define MAX_ALLOC_COUNT 15
+ const int max_alloc_count = 15;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetProcessingInstructionHandler(parser, dummy_pi_handler);
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
}
if (i == 0)
fail("Parse succeeded despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed with max allocations");
-#undef MAX_ALLOC_COUNT
}
END_TEST
"<?pi unknown?>\n"
"</doc>";
int i;
-#define MAX_ALLOC_COUNT 15
+ const int max_alloc_count = 15;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetProcessingInstructionHandler(parser, dummy_pi_handler);
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
}
if (i == 0)
fail("Parse succeeded despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed with max allocations");
-#undef MAX_ALLOC_COUNT
}
END_TEST
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
"Q?><doc/>";
int i;
-#define MAX_ALLOC_COUNT 20
+ const int max_alloc_count = 20;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetProcessingInstructionHandler(parser, dummy_pi_handler);
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
}
if (i == 0)
fail("Parse succeeded despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed with max allocations");
}
-#undef MAX_ALLOC_COUNT
END_TEST
START_TEST(test_alloc_parse_comment)
"<!-- Test parsing this comment -->"
"<doc>Hi</doc>";
int i;
-#define MAX_ALLOC_COUNT 15
+ const int max_alloc_count = 15;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetCommentHandler(parser, dummy_comment_handler);
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
}
if (i == 0)
fail("Parse succeeded despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed with max allocations");
-#undef MAX_ALLOC_COUNT
}
END_TEST
"<!-- Parse this comment too -->"
"</doc>";
int i;
-#define MAX_ALLOC_COUNT 15
+ const int max_alloc_count = 15;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetCommentHandler(parser, dummy_comment_handler);
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
}
if (i == 0)
fail("Parse succeeded despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed with max allocations");
-#undef MAX_ALLOC_COUNT
}
END_TEST
{
XML_Parser new_parser;
unsigned int i;
-#define MAX_ALLOC_COUNT 10
+ const unsigned int max_alloc_count = 10;
/* Try a few different allocation levels */
- for (i = 0; i < MAX_ALLOC_COUNT; i++)
+ for (i = 0; i < max_alloc_count; i++)
{
allocation_count = i;
new_parser = XML_ExternalEntityParserCreate(parser, context, NULL);
}
if (i == 0)
fail("External parser creation ignored failing allocator");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Extern parser not created with max allocation count");
/* Make sure other random allocation doesn't now fail */
/* Make sure the failure code path is executed too */
return XML_STATUS_ERROR;
-#undef MAX_ALLOC_COUNT
}
/* Test that external parser creation running out of memory is
char foo_text[] =
"<!ELEMENT doc (#PCDATA)*>";
unsigned int i;
-#define MAX_ALLOC_COUNT 15
+ const unsigned int max_alloc_count = 15;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
XML_SetParamEntityParsing(parser,
XML_PARAM_ENTITY_PARSING_ALWAYS);
XML_SetUserData(parser, foo_text);
}
if (i == 0)
fail("Parsing ignored failing allocator");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed with allocation count 10");
}
-#undef MAX_ALLOC_COUNT
END_TEST
const char *text;
XML_Parser new_parser;
int i;
-#define MAX_ALLOC_COUNT 20
+ const int max_alloc_count = 20;
if (callno == 0) {
/* First time through, check how many calls to malloc occur */
text = ("<?xml version='1.0' encoding='us-ascii'?>"
"<e/>");
/* Try at varying levels to exercise more code paths */
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = callno + i;
new_parser = XML_ExternalEntityParserCreate(parser,
context,
XML_ParserFree(new_parser);
return XML_STATUS_ERROR;
}
- else if (i == MAX_ALLOC_COUNT) {
+ else if (i == max_alloc_count) {
fail("Second external parser not created");
return XML_STATUS_ERROR;
}
}
XML_ParserFree(new_parser);
return XML_STATUS_OK;
-#undef MAX_ALLOC_COUNT
}
/* Test that running out of memory in dtdCopy is correctly reported.
"&en;\n"
"</doc>";
int i;
-#define ALLOC_TEST_MAX_REPEATS 50
+ const int alloc_test_max_repeats = 50;
- for (i = 0; i < ALLOC_TEST_MAX_REPEATS; i++) {
+ for (i = 0; i < alloc_test_max_repeats; i++) {
allocation_count = -1;
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
XML_SetExternalEntityRefHandler(parser,
allocation_count = -1;
if (i == 0)
fail("External entity parsed despite duff allocator");
- if (i == ALLOC_TEST_MAX_REPEATS)
+ if (i == alloc_test_max_repeats)
fail("External entity not parsed at max allocation count");
-#undef ALLOC_TEST_MAX_REPEATS
}
END_TEST
"]>\n"
"<doc>&en;</doc>";
int i;
-#define MAX_ALLOCATION_COUNT 30
+ const int max_allocation_count = 30;
- for (i = 0; i < MAX_ALLOCATION_COUNT; i++) {
+ for (i = 0; i < max_allocation_count; i++) {
XML_SetExternalEntityRefHandler(parser,
external_entity_alloc_set_encoding);
allocation_count = i;
}
if (i == 0)
fail("Encoding check succeeded despite failing allocator");
- if (i == MAX_ALLOCATION_COUNT)
+ if (i == max_allocation_count)
fail("Encoding failed at max allocation count");
-#undef MAX_ALLOCATION_COUNT
}
END_TEST
"<!DOCTYPE test [<!ENTITY foo 'bar'>]>\n"
"<test a='&foo;'/>";
unsigned int i;
-#define MAX_ALLOC_COUNT 20
+ const unsigned int max_alloc_count = 20;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetUnknownEncodingHandler(parser,
unknown_released_encoding_handler,
}
if (i == 0)
fail("Internal entity worked despite failing allocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Internal entity failed at max allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
const char *expected = "\n\n\n\n\n\n\n\n\n<doc>text in doc</doc>";
CharData storage;
int i;
-#define MAX_ALLOC_COUNT 25
+ const int max_alloc_count = 25;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
dummy_handler_flags = 0;
XML_SetDefaultHandler(parser, accumulate_characters);
}
if (i == 0)
fail("Default DTD parsed despite allocation failures");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Default DTD not parsed with maximum alloc count");
CharData_CheckXMLChars(&storage, expected);
if (dummy_handler_flags != (DUMMY_START_DOCTYPE_HANDLER_FLAG |
DUMMY_UNPARSED_ENTITY_DECL_HANDLER_FLAG))
fail("Not all handlers were called");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test robustness of XML_SetEncoding() with a failing allocator */
START_TEST(test_alloc_explicit_encoding)
{
int i;
-#define MAX_ALLOC_COUNT 5
+ const int max_alloc_count = 5;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
if (XML_SetEncoding(parser, "us-ascii") == XML_STATUS_OK)
break;
}
if (i == 0)
fail("Encoding set despite failing allocator");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Encoding not set at max allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test robustness of XML_SetBase against a failing allocator */
{
const XML_Char *new_base = "/local/file/name.xml";
int i;
-#define MAX_ALLOC_COUNT 5
+ const int max_alloc_count = 5;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
if (XML_SetBase(parser, new_base) == XML_STATUS_OK)
break;
}
if (i == 0)
fail("Base set despite failing allocator");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Base not set with max allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test buffer extension in the face of a duff reallocator */
const char *text = get_buffer_test_text;
void *buffer;
int i;
-#define MAX_REALLOC_COUNT 10
+ const int max_realloc_count = 10;
/* Get a smallish buffer */
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
buffer = XML_GetBuffer(parser, 1536);
if (buffer == NULL)
reallocation_count = -1;
if (i == 0)
fail("Parse succeeded with no reallocation");
- else if (i == MAX_REALLOC_COUNT)
+ else if (i == max_realloc_count)
fail("Parse failed with max reallocation count");
}
-#undef MAX_REALLOC_COUNT
END_TEST
/* Same test for external entity parsers */
"]>\n"
"<doc>&en;</doc>";
int i;
-#define MAX_REALLOC_COUNT 10
+ const int max_realloc_count = 10;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
XML_SetExternalEntityRefHandler(parser,
external_entity_reallocator);
XML_SetUserData(parser, (void *)(intptr_t)i);
}
if (i == 0)
fail("Succeeded with no reallocations");
- if (i == MAX_REALLOC_COUNT)
+ if (i == max_realloc_count)
fail("Failed with max reallocations");
}
-#undef MAX_REALLOC_COUNT
END_TEST
/* Test elements with many attributes are handled correctly */
" s='18'>"
"</doc>";
int i;
-#define MAX_REALLOC_COUNT 10
+ const int max_realloc_count = 10;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
XML_TRUE) != XML_STATUS_ERROR)
}
if (i == 0)
fail("Parse succeeded despite no reallocations");
- if (i == MAX_REALLOC_COUNT)
+ if (i == max_realloc_count)
fail("Parse failed at max reallocations");
-#undef MAX_REALLOC_COUNT
}
END_TEST
" '%e1;'>\n"
"%e1;\n";
int i;
-#define MAX_ALLOC_COUNT 50
+ const int max_alloc_count = 50;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
dummy_handler_flags = 0;
XML_SetUserData(parser, dtd_text);
}
if (i == 0)
fail("Parsing worked despite failing allocation");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parsing failed at max allocation count");
if (dummy_handler_flags != DUMMY_ENTITY_DECL_HANDLER_FLAG)
fail("Entity declaration handler not called");
}
-#undef MAX_ALLOC_COUNT
END_TEST
START_TEST(test_alloc_realloc_subst_public_entity_value)
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP;";
int i;
-#define MAX_REALLOC_COUNT 10
+ const int max_realloc_count = 10;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
XML_SetUserData(parser, dtd_text);
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
}
if (i == 0)
fail("Parsing worked despite failing reallocation");
- if (i == MAX_REALLOC_COUNT)
+ if (i == max_realloc_count)
fail("Parsing failed at max reallocation count");
}
-#undef MAX_REALLOC_COUNT
END_TEST
START_TEST(test_alloc_parse_public_doctype)
"' 'test'>\n"
"<doc></doc>";
int i;
-#define MAX_ALLOC_COUNT 25
+ const int max_alloc_count = 25;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
dummy_handler_flags = 0;
XML_SetDoctypeDeclHandler(parser,
}
if (i == 0)
fail("Parse succeeded despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed at maximum allocation count");
if (dummy_handler_flags != (DUMMY_START_DOCTYPE_DECL_HANDLER_FLAG |
DUMMY_END_DOCTYPE_DECL_HANDLER_FLAG))
fail("Doctype handler functions not called");
}
-#undef MAX_ALLOC_COUNT
END_TEST
START_TEST(test_alloc_parse_public_doctype_long_name)
"'>\n"
"<doc></doc>";
int i;
-#define MAX_ALLOC_COUNT 25
+ const int max_alloc_count = 25;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetDoctypeDeclHandler(parser,
dummy_start_doctype_decl_handler,
}
if (i == 0)
fail("Parse succeeded despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed at maximum allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
static int XMLCALL
"<doc>&entity;</doc>";
char text2[] = "<!ELEMENT doc (#PCDATA)*>";
int i;
-#define MAX_ALLOC_COUNT 25
+ const int max_alloc_count = 25;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
XML_SetUserData(parser, &text2);
}
if (i == 0)
fail("Parse succeeded despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed at maximum allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test based on ibm/valid/P32/ibm32v04.xml */
"<!ELEMENT a EMPTY>\n"
"<!ATTLIST animal xml:space (default|preserve) 'preserve'>";
int i;
-#define MAX_ALLOC_COUNT 30
+ const int max_alloc_count = 30;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetExternalEntityRefHandler(parser, external_entity_alloc);
XML_SetUserData(parser, dtd_text);
}
if (i == 0)
fail("Parse succeeded despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed at maximum allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test attribute enums sufficient to overflow the string pool */
"|PBCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNO)"
" 'default'>";
int i;
-#define MAX_REALLOC_COUNT 10
+ const int max_realloc_count = 10;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
XML_SetExternalEntityRefHandler(parser, external_entity_alloc);
XML_SetUserData(parser, dtd_text);
}
if (i == 0)
fail("Parse succeeded despite failing reallocator");
- if (i == MAX_REALLOC_COUNT)
+ if (i == max_realloc_count)
fail("Parse failed at maximum reallocation count");
}
-#undef MAX_REALLOC_COUNT
END_TEST
/* Test attribute enums in a #IMPLIED attribute forcing pool growth */
" #IMPLIED>\n"
"]><doc/>";
int i;
-#define MAX_REALLOC_COUNT 10
+ const int max_realloc_count = 10;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
XML_SetAttlistDeclHandler(parser, dummy_attlist_decl_handler);
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
}
if (i == 0)
fail("Parse succeeded despite failing reallocator");
- if (i == MAX_REALLOC_COUNT)
+ if (i == max_realloc_count)
fail("Parse failed at maximum reallocation count");
}
-#undef MAX_REALLOC_COUNT
END_TEST
/* Test attribute enums in a defaulted attribute forcing pool growth */
" 'ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNO'"
">\n]><doc/>";
int i;
-#define MAX_REALLOC_COUNT 10
+ const int max_realloc_count = 10;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
XML_SetAttlistDeclHandler(parser, dummy_attlist_decl_handler);
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
}
if (i == 0)
fail("Parse succeeded despite failing reallocator");
- if (i == MAX_REALLOC_COUNT)
+ if (i == max_realloc_count)
fail("Parse failed at maximum reallocation count");
}
-#undef MAX_REALLOC_COUNT
END_TEST
/* Test long notation name with dodgy allocator */
"<!ELEMENT doc EMPTY>\n"
"]>\n<doc/>";
int i;
-#define MAX_ALLOC_COUNT 20
+ const int max_alloc_count = 20;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
dummy_handler_flags = 0;
XML_SetNotationDeclHandler(parser, dummy_notation_decl_handler);
}
if (i == 0)
fail("Parse succeeded despite allocation failures");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed at maximum allocation count");
if (dummy_handler_flags != (DUMMY_ENTITY_DECL_HANDLER_FLAG |
DUMMY_NOTATION_DECL_HANDLER_FLAG))
fail("Entity declaration handler not called");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test public notation with dodgy allocator */
"<!ELEMENT doc EMPTY>\n"
"]>\n<doc/>";
int i;
-#define MAX_ALLOC_COUNT 20
+ const int max_alloc_count = 20;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
dummy_handler_flags = 0;
XML_SetNotationDeclHandler(parser, dummy_notation_decl_handler);
}
if (i == 0)
fail("Parse succeeded despite allocation failures");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed at maximum allocation count");
if (dummy_handler_flags != DUMMY_NOTATION_DECL_HANDLER_FLAG)
fail("Notation handler not called");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test public notation with dodgy allocator */
"<!ELEMENT doc EMPTY>\n"
"]>\n<doc/>";
int i;
-#define MAX_ALLOC_COUNT 20
+ const int max_alloc_count = 20;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
dummy_handler_flags = 0;
XML_SetNotationDeclHandler(parser, dummy_notation_decl_handler);
}
if (i == 0)
fail("Parse succeeded despite allocation failures");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed at maximum allocation count");
if (dummy_handler_flags != DUMMY_NOTATION_DECL_HANDLER_FLAG)
fail("Notation handler not called");
}
-#undef MAX_ALLOC_COUNT
END_TEST
START_TEST(test_alloc_nested_groups)
"<doc><e/></doc>";
CharData storage;
int i;
-#define MAX_ALLOC_COUNT 20
+ const int max_alloc_count = 20;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
CharData_Init(&storage);
XML_SetElementDeclHandler(parser, dummy_element_decl_handler);
if (i == 0)
fail("Parse succeeded despite failing reallocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed at maximum reallocation count");
CharData_CheckString(&storage, "doce");
if (dummy_handler_flags != DUMMY_ELEMENT_DECL_HANDLER_FLAG)
fail("Element handler not fired");
}
-#undef MAX_ALLOC_COUNT
END_TEST
START_TEST(test_alloc_realloc_nested_groups)
"<doc><e/></doc>";
CharData storage;
int i;
-#define MAX_REALLOC_COUNT 10
+ const int max_realloc_count = 10;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
CharData_Init(&storage);
XML_SetElementDeclHandler(parser, dummy_element_decl_handler);
if (i == 0)
fail("Parse succeeded despite failing reallocator");
- if (i == MAX_REALLOC_COUNT)
+ if (i == max_realloc_count)
fail("Parse failed at maximum reallocation count");
CharData_CheckString(&storage, "doce");
if (dummy_handler_flags != DUMMY_ELEMENT_DECL_HANDLER_FLAG)
fail("Element handler not fired");
}
-#undef MAX_REALLOC_COUNT
END_TEST
START_TEST(test_alloc_large_group)
"<a1/>\n"
"</doc>\n";
int i;
-#define MAX_ALLOC_COUNT 50
+ const int max_alloc_count = 50;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetElementDeclHandler(parser, dummy_element_decl_handler);
dummy_handler_flags = 0;
}
if (i == 0)
fail("Parse succeeded despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed at maximum allocation count");
if (dummy_handler_flags != DUMMY_ELEMENT_DECL_HANDLER_FLAG)
fail("Element handler flag not raised");
}
-#undef MAX_ALLOC_COUNT
END_TEST
START_TEST(test_alloc_realloc_group_choice)
"<c3></c3>\n"
"</doc>\n";
int i;
-#define MAX_REALLOC_COUNT 10
+ const int max_realloc_count = 10;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
XML_SetElementDeclHandler(parser, dummy_element_decl_handler);
dummy_handler_flags = 0;
}
if (i == 0)
fail("Parse succeeded despite failing reallocator");
- if (i == MAX_REALLOC_COUNT)
+ if (i == max_realloc_count)
fail("Parse failed at maximum reallocation count");
if (dummy_handler_flags != DUMMY_ELEMENT_DECL_HANDLER_FLAG)
fail("Element handler flag not raised");
}
-#undef MAX_REALLOC_COUNT
END_TEST
START_TEST(test_alloc_pi_in_epilog)
"<doc></doc>\n"
"<?pi in epilog?>";
int i;
-#define MAX_ALLOC_COUNT 15
+ const int max_alloc_count = 15;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetProcessingInstructionHandler(parser, dummy_pi_handler);
dummy_handler_flags = 0;
}
if (i == 0)
fail("Parse completed despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed at maximum allocation count");
if (dummy_handler_flags != DUMMY_PI_HANDLER_FLAG)
fail("Processing instruction handler not invoked");
}
-#undef MAX_ALLOC_COUNT
END_TEST
START_TEST(test_alloc_comment_in_epilog)
"<doc></doc>\n"
"<!-- comment in epilog -->";
int i;
-#define MAX_ALLOC_COUNT 15
+ const int max_alloc_count = 15;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetCommentHandler(parser, dummy_comment_handler);
dummy_handler_flags = 0;
}
if (i == 0)
fail("Parse completed despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed at maximum allocation count");
if (dummy_handler_flags != DUMMY_COMMENT_HANDLER_FLAG)
fail("Processing instruction handler not invoked");
}
-#undef MAX_ALLOC_COUNT
END_TEST
START_TEST(test_alloc_realloc_long_attribute_value)
"'>]>\n"
"<doc a='&foo;'></doc>";
int i;
-#define MAX_REALLOC_COUNT 10
+ const int max_realloc_count = 10;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
XML_TRUE) != XML_STATUS_ERROR)
}
if (i == 0)
fail("Parse succeeded despite failing reallocator");
- if (i == MAX_REALLOC_COUNT)
+ if (i == max_realloc_count)
fail("Parse failed at maximum reallocation count");
}
-#undef MAX_REALLOC_COUNT
END_TEST
START_TEST(test_alloc_attribute_whitespace)
{
const char *text = "<doc a=' '></doc>";
int i;
-#define MAX_ALLOC_COUNT 15
+ const int max_alloc_count = 15;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
XML_TRUE) != XML_STATUS_ERROR)
}
if (i == 0)
fail("Parse succeeded despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed at maximum allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
START_TEST(test_alloc_attribute_predefined_entity)
{
const char *text = "<doc a='&'></doc>";
int i;
-#define MAX_ALLOC_COUNT 15
+ const int max_alloc_count = 15;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
XML_TRUE) != XML_STATUS_ERROR)
}
if (i == 0)
fail("Parse succeeded despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed at maximum allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test that a character reference at the end of a suitably long
"1'>]>\n"
"<doc/>";
int i;
-#define MAX_ALLOC_COUNT 20
+ const int max_alloc_count = 20;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
XML_TRUE) != XML_STATUS_ERROR)
}
if (i == 0)
fail("Parse succeeded despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed at maximum allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test that a long character reference substitution triggers a pool
"'>]>\n"
"<test a='&foo;'/>";
int i;
-#define MAX_ALLOC_COUNT 25
+ const int max_alloc_count = 25;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
XML_TRUE) != XML_STATUS_ERROR)
}
if (i == 0)
fail("Parse succeeded despite failing allocator");
- if (i == MAX_ALLOC_COUNT)
+ if (i == max_alloc_count)
fail("Parse failed at maximum allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test that an error in a nested parameter entity substitution is
"\">\n'>"
"%pe;\n";
int i;
-#define MAX_REALLOC_COUNT 5
+ const int max_realloc_count = 5;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
XML_SetUserData(parser, dtd_text);
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
}
if (i == 0)
fail("Parse succeeded despite failing reallocator");
- if (i == MAX_REALLOC_COUNT)
+ if (i == max_realloc_count)
fail("Parse failed at maximum reallocation count");
}
-#undef MAX_REALLOC_COUNT
END_TEST
START_TEST(test_alloc_realloc_ce_extends_pe)
"\">\n'>"
"%pe;\n";
int i;
-#define MAX_REALLOC_COUNT 5
+ const int max_realloc_count = 5;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
XML_SetUserData(parser, dtd_text);
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
}
if (i == 0)
fail("Parse succeeded despite failing reallocator");
- if (i == MAX_REALLOC_COUNT)
+ if (i == max_realloc_count)
fail("Parse failed at maximum reallocation count");
}
-#undef MAX_REALLOC_COUNT
END_TEST
START_TEST(test_alloc_realloc_attributes)
" >]>\n"
"<doc>wombat</doc>\n";
int i;
-#define MAX_REALLOC_COUNT 5
+ const int max_realloc_count = 5;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
XML_TRUE) != XML_STATUS_ERROR)
if (i == 0)
fail("Parse succeeded despite failing reallocator");
- if (i == MAX_REALLOC_COUNT)
+ if (i == max_realloc_count)
fail("Parse failed at maximum reallocation count");
}
-#undef MAX_REALLOC_COUNT
END_TEST
START_TEST(test_alloc_long_doc_name)
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789AZ"
" a='1'/>";
int i;
-#define MAX_ALLOC_COUNT 20
+ const int max_alloc_count = 20;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
XML_TRUE) != XML_STATUS_ERROR)
}
if (i == 0)
fail("Parsing worked despite failing reallocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed even at max reallocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
START_TEST(test_alloc_long_base)
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789A/"
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789A/";
int i;
- #define MAX_ALLOC_COUNT 25
+ const int max_alloc_count = 25;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetUserData(parser, entity_text);
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
}
if (i == 0)
fail("Parsing worked despite failing allocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed even at max allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
START_TEST(test_alloc_long_public_id)
"<doc>&e;</doc>";
char entity_text[] = "Hello world";
int i;
-#define MAX_ALLOC_COUNT 40
+ const int max_alloc_count = 40;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetUserData(parser, entity_text);
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
}
if (i == 0)
fail("Parsing worked despite failing allocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed even at max allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
START_TEST(test_alloc_long_entity_value)
"<doc>&e2;</doc>";
char entity_text[] = "Hello world";
int i;
-#define MAX_ALLOC_COUNT 40
+ const int max_alloc_count = 40;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetUserData(parser, entity_text);
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
}
if (i == 0)
fail("Parsing worked despite failing allocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed even at max allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
START_TEST(test_alloc_long_notation)
{ NULL, NULL }
};
int i;
-#define MAX_ALLOC_COUNT 40
+ const int max_alloc_count = 40;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetUserData(parser, options);
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
}
if (i == 0)
fail("Parsing worked despite failing allocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed even at max allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
" <e xmlns=''/>\n"
"</doc>";
unsigned int i;
-#define MAX_ALLOC_COUNT 30
+ const unsigned int max_alloc_count = 30;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
/* Exercise more code paths with a default handler */
XML_SetDefaultHandler(parser, dummy_default_handler);
}
if (i == 0)
fail("Parsing worked despite failing allocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed even at maximum allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test XML_ParseBuffer interface with namespace and a dicky allocator */
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789AZ"
":foo>";
int i;
-#define MAX_ALLOC_COUNT 40
+ const int max_alloc_count = 40;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
XML_TRUE) != XML_STATUS_ERROR)
}
if (i == 0)
fail("Parsing worked despite failing allocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed even at max allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Check handling of long uri names (pool growth) */
"'>"
"</foo:e>";
int i;
-#define MAX_ALLOC_COUNT 40
+ const int max_alloc_count = 40;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
XML_TRUE) != XML_STATUS_ERROR)
}
if (i == 0)
fail("Parsing worked despite failing allocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed even at max allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test handling of long attribute names with prefixes */
"xmlns:bar='http://example.org/'>"
"</foo:e>";
int i;
-#define MAX_ALLOC_COUNT 40
+ const int max_alloc_count = 40;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
XML_TRUE) != XML_STATUS_ERROR)
}
if (i == 0)
fail("Parsing worked despite failing allocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed even at max allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test handling of an attribute name with a long namespace prefix */
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789AZ"
};
int i;
-#define MAX_ALLOC_COUNT 40
+ const int max_alloc_count = 40;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetReturnNSTriplet(parser, XML_TRUE);
XML_SetUserData(parser, elemstr);
}
if (i == 0)
fail("Parsing worked despite failing allocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed even at max allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test attribute handling in the face of a dodgy reallocator */
" xmlns:bar='http://example.org/'>"
"</foo:e>";
int i;
-#define MAX_REALLOC_COUNT 10
+ const int max_realloc_count = 10;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
XML_TRUE) != XML_STATUS_ERROR)
}
if (i == 0)
fail("Parsing worked despite failing reallocations");
- else if (i == MAX_REALLOC_COUNT)
+ else if (i == max_realloc_count)
fail("Parsing failed at max reallocation count");
}
-#undef MAX_REALLOC_COUNT
END_TEST
/* Test long element names with namespaces under a failing allocator */
"http://example.org/ a bar"
};
int i;
-#define MAX_ALLOC_COUNT 30
+ const int max_alloc_count = 30;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetReturnNSTriplet(parser, XML_TRUE);
XML_SetUserData(parser, elemstr);
}
if (i == 0)
fail("Parsing worked despite failing reallocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed at max reallocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Test the effects of reallocation failure when reassigning a
" <e xmlns='' />\n"
"</doc>";
unsigned i;
-#define MAX_REALLOC_COUNT 10
+ const unsigned max_realloc_count = 10;
/* First, do a full parse that will leave bindings around */
if (_XML_Parse_SINGLE_BYTES(parser, first, strlen(first),
xml_failure(parser);
/* Now repeat with a longer URI and a duff reallocator */
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
XML_ParserReset(parser, NULL);
reallocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, second, strlen(second),
}
if (i == 0)
fail("Parsing worked despite failing reallocation");
- else if (i == MAX_REALLOC_COUNT)
+ else if (i == max_realloc_count)
fail("Parsing failed at max reallocation count");
}
-#undef MAX_REALLOC_COUNT
END_TEST
/* Check handling of long prefix names (pool growth) */
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789AZ"
":foo>";
int i;
-#define MAX_REALLOC_COUNT 12
+ const int max_realloc_count = 12;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
XML_TRUE) != XML_STATUS_ERROR)
}
if (i == 0)
fail("Parsing worked despite failing reallocations");
- else if (i == MAX_REALLOC_COUNT)
+ else if (i == max_realloc_count)
fail("Parsing failed even at max reallocation count");
}
-#undef MAX_REALLOC_COUNT
END_TEST
/* Check handling of even long prefix names (different code path) */
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789AZ"
"Q:foo>";
int i;
-#define MAX_REALLOC_COUNT 12
+ const int max_realloc_count = 12;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
XML_TRUE) != XML_STATUS_ERROR)
}
if (i == 0)
fail("Parsing worked despite failing reallocations");
- else if (i == MAX_REALLOC_COUNT)
+ else if (i == max_realloc_count)
fail("Parsing failed even at max reallocation count");
}
-#undef MAX_REALLOC_COUNT
END_TEST
START_TEST(test_nsalloc_long_namespace)
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789AZ"
":e>";
int i;
-#define MAX_ALLOC_COUNT 40
+ const int max_alloc_count = 40;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
XML_TRUE) != XML_STATUS_ERROR)
}
if (i == 0)
fail("Parsing worked despite failing allocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed even at max allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
/* Using a slightly shorter namespace name provokes allocations in
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678"
":e>";
int i;
-#define MAX_ALLOC_COUNT 40
+ const int max_alloc_count = 40;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
XML_TRUE) != XML_STATUS_ERROR)
}
if (i == 0)
fail("Parsing worked despite failing allocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed even at max allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
START_TEST(test_nsalloc_long_context)
{ NULL, NULL }
};
int i;
-#define MAX_ALLOC_COUNT 70
+ const int max_alloc_count = 70;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetUserData(parser, options);
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
}
if (i == 0)
fail("Parsing worked despite failing allocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed even at max allocation count");
-#undef MAX_ALLOC_COUNT
}
END_TEST
{ NULL, NULL }
};
int i;
-#define MAX_REALLOC_COUNT 5
+ const int max_realloc_count = 5;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
XML_SetUserData(parser, options);
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
}
if (i == 0)
fail("Parsing worked despite failing reallocations");
- else if (i == MAX_REALLOC_COUNT)
+ else if (i == max_realloc_count)
fail("Parsing failed even at max reallocation count");
-#undef MAX_REALLOC_COUNT
}
START_TEST(test_nsalloc_realloc_long_context)
{ NULL, NULL }
};
int i;
-#define MAX_REALLOC_COUNT 10
+ const int max_realloc_count = 10;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
XML_SetUserData(parser, options);
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
}
if (i == 0)
fail("Parsing worked despite failing reallocations");
- else if (i == MAX_REALLOC_COUNT)
+ else if (i == max_realloc_count)
fail("Parsing failed even at max reallocation count");
-#undef MAX_REALLOC_COUNT
}
END_TEST
{ NULL, NULL }
};
int i;
-#define MAX_REALLOC_COUNT 20
+ const int max_realloc_count = 20;
- for (i = 0; i < MAX_REALLOC_COUNT; i++) {
+ for (i = 0; i < max_realloc_count; i++) {
reallocation_count = i;
XML_SetUserData(parser, options);
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
}
if (i == 0)
fail("Parsing worked despite failing reallocations");
- else if (i == MAX_REALLOC_COUNT)
+ else if (i == max_realloc_count)
fail("Parsing failed even at max reallocation count");
-#undef MAX_REALLOC_COUNT
}
END_TEST
{ NULL, NULL }
};
int i;
-#define MAX_ALLOC_COUNT 50
+ const int max_alloc_count = 50;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetUserData(parser, options);
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
}
if (i == 0)
fail("Parsing worked despite failing allocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed even at max allocation count");
-#undef MAX_ALLOC_COUNT
}
END_TEST
{ NULL, NULL }
};
int i;
-#define MAX_ALLOC_COUNT 55
+ const int max_alloc_count = 55;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetUserData(parser, options);
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
}
if (i == 0)
fail("Parsing worked despite failing allocations");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Parsing failed even at max allocation count");
-#undef MAX_ALLOC_COUNT
}
END_TEST
{ NULL, NULL }
};
int i;
-#define MAX_ALLOC_COUNT 70
+ const int max_alloc_count = 70;
- for (i = 0; i < MAX_ALLOC_COUNT; i++) {
+ for (i = 0; i < max_alloc_count; i++) {
allocation_count = i;
XML_SetUserData(parser, options);
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
}
if (i == 0)
fail("Success despite failing allocator");
- else if (i == MAX_ALLOC_COUNT)
+ else if (i == max_alloc_count)
fail("Failed even at full allocation count");
}
-#undef MAX_ALLOC_COUNT
END_TEST
static Suite *