示例#1
0
static int test_xprintf(struct test_printf_info *tpi, const char *expected,
                        int expectedLen, const char *format, va_list ap) {
    char *resultString;
    int resultLen = vasprintf(&resultString, format, ap);
    int result = compareResult(tpi, expected, expectedLen, format,
                               resultString, resultLen);
    free(resultString);
    return result;
}
static bool compareResults( const std::vector<strus::analyzer::PatternMatcherResult>& results, const std::vector<strus::analyzer::PatternMatcherResult>& expectedResults)
{
	if (results.size() != expectedResults.size()) return false;
	std::vector<strus::analyzer::PatternMatcherResult>::const_iterator ri = results.begin(), re = results.end();
	std::vector<strus::analyzer::PatternMatcherResult>::const_iterator xi = expectedResults.begin(), xe = expectedResults.end();
	for (; xi != xe && ri != re; ++ri,++xi)
	{
		if (!compareResult( *ri, *xi)) return false;
	}
	return true;
}
static std::vector<strus::analyzer::PatternMatcherResult>
	eliminateDuplicates( const std::vector<strus::analyzer::PatternMatcherResult>& results)
{
	std::vector<strus::analyzer::PatternMatcherResult> rt;
	std::vector<strus::analyzer::PatternMatcherResult>::const_iterator ri = results.begin(), re = results.end();
	const strus::analyzer::PatternMatcherResult* prev = 0;
	for (; ri != re; ++ri)
	{
		if (!prev || !compareResult( *ri, *prev)) rt.push_back( *ri);
		prev = &*ri;
	}
	return rt;
}