Exemplo n.º 1
0
static void
_expect_failure(char *text, enum XML_Error errorCode, char *errorMessage,
                char *file, int lineno)
{
    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_OK)
        /* Hackish use of _fail_unless() macro, but let's us report
           the right filename and line number. */
        _fail_unless(0, file, lineno, errorMessage);
    if (XML_GetErrorCode(parser) != errorCode)
        _xml_failure(parser, file, lineno);
}
Exemplo n.º 2
0
/* Generate a failure using the parser state to create an error message;
   this should be used when the parser reports an error we weren't
   expecting.
*/
static void
_xml_failure(XML_Parser parser, const char *file, int line)
{
    char buffer[1024];
    sprintf(buffer,
            "\n    %s (line %d, offset %d)\n    reported from %s, line %d",
            XML_ErrorString(XML_GetErrorCode(parser)),
            XML_GetCurrentLineNumber(parser),
            XML_GetCurrentColumnNumber(parser),
            file, line);
    _fail_unless(0, file, line, buffer);
}
Exemplo n.º 3
0
static
void	_assert_scores(char *file, int line, int expected_score, char *string, char *pattern, unsigned *expected_match)
{
	int pat_len = strlen(pattern);
	int real_score;
	int i;
	unsigned match[pat_len];

	qry.pattern = pattern;
	real_score = score_string(string, &qry, strlen(string), match);
	if (real_score != expected_score) {
		_fail_unless(0, file, line, 0, "scoring %s against pattern %s should score 0x%x, not 0x%x",
			     string, pattern, expected_score, real_score,
			     0);
		return;
	}
	if (expected_match)
		for (i=0;i<pat_len;i++)
			if (expected_match[i] != match[i])
				_fail_unless(0, file, line, 0,
					     "match differs in pos %d. Expected %d, got %d",
					     i, expected_match[i], match[i], 0);
	_fail_unless(1, __FILE__, __LINE__, "cannot happen", 0);
}
Exemplo n.º 4
0
/* Generate a failure using the parser state to create an error message;
   this should be used when the parser reports an error we weren't
   expecting.
*/
static void
_xml_failure(XML_Parser parser, const char *file, int line)
{
    char buffer[1024];
    enum XML_Error err = XML_GetErrorCode(parser);
    sprintf(buffer,
            "    %d: %s (line %" XML_FMT_INT_MOD "u, offset %"\
                XML_FMT_INT_MOD "u)\n    reported from %s, line %d\n",
            err,
            XML_ErrorString(err),
            XML_GetCurrentLineNumber(parser),
            XML_GetCurrentColumnNumber(parser),
            file, line);
    _fail_unless(0, file, line, buffer);
}
Exemplo n.º 5
0
static void
measure_effective_prio(L4_Word_t expect_prio)
{
    L4_Word_t label, prio;
    L4_ThreadId_t any_thread;
    L4_MsgTag_t tag;

    prio = 9;
    do {
        prio--;
        L4_Set_Priority(measure_thread, prio);
        tag = L4_Wait(&any_thread);
        label = L4_Label(tag);
    } while ((label != 0x1) && (prio > 1));
    _fail_unless(prio == expect_prio, __FILE__, __LINE__, "Wrong effective priority: %lu", prio);
}
Exemplo n.º 6
0
static void _assertTrue(const char *msg, gboolean expression, const char *file, int line)
{
        _fail_unless(expression, file, line, "failure", msg, NULL);
}