Beispiel #1
0
SimpleString JUnitTestOutput::encodeXmlText(const SimpleString& textbody)
{
    SimpleString buf = textbody.asCharString();
    buf.replace("&", "&");
    buf.replace("\"", """);
    buf.replace("<", "&lt;");
    buf.replace(">", "&gt;");
    buf.replace("\n", "{newline}");
    return buf;
}
void JUnitTestOutput::writeFailure(JUnitTestCaseResultNode* node)
{
	SimpleString message = node->failure_->getMessage().asCharString();
	message.replace('"', '\'');
	message.replace('<', '[');
	message.replace('>', ']');
	message.replace("\n", "{newline}");
	SimpleString buf = StringFromFormat(
			"<failure message=\"%s:%d: %s\" type=\"AssertionFailedError\">\n",
			node->failure_->getFileName().asCharString(),
			node->failure_->getFailureLineNumber(), message.asCharString());
	writeToFile(buf.asCharString());
	writeToFile("</failure>\n");
}
void TestRegistry::listTestGroupAndCaseNames(TestResult& result)
{
    SimpleString groupAndNameList;

    for (UtestShell *test = tests_; test != NULL; test = test->getNext()) {
        if (testShouldRun(test, result)) {
            SimpleString groupAndName;
            groupAndName += "#";
            groupAndName += test->getGroup();
            groupAndName += ".";
            groupAndName += test->getName();
            groupAndName += "#";

            if (!groupAndNameList.contains(groupAndName)) {
                groupAndNameList += groupAndName;
                groupAndNameList += " ";
            }
        }
    }

    groupAndNameList.replace("#", "");

    if (groupAndNameList.endsWith(" "))
        groupAndNameList = groupAndNameList.subString(0, groupAndNameList.size() - 1);
    result.print(groupAndNameList.asCharString());
}
Beispiel #4
0
void JUnitTestOutput::writeFailure(JUnitTestCaseResultNode* node)
{
	const int buf_size = 1024;
	static char buf[buf_size];

	SimpleString message = node->failure_->getMessage().asCharString();
	message.replace('"', '\'');
	message.replace('<','[');
	message.replace('>',']');
	message.replace("\n","{newline}");
	cpputest_snprintf(buf, buf_size, "<failure message=\"%s:%d: %s\" type=\"AssertionFailedError\">\n", 
		node->failure_->getFileName().asCharString(), node->failure_->getLineNumber(), message.asCharString());

	writeToFile(buf);
	writeToFile("</failure>\n");
}
Beispiel #5
0
SimpleString JUnitTestOutput::createFileName(const SimpleString& group)
{
    SimpleString fileName = "cpputest_";
    fileName += group;
    fileName.replace('/', '_');
    fileName += ".xml";
    return fileName;
}
SimpleString CodeMemoryReportFormatter::createVariableNameFromFileLineInfo(const char *file, int line)
{
    SimpleString fileNameOnly = extractFileNameFromPath(file);
    fileNameOnly.replace(".", "_");

    for (int i = 1; i < 100000; i++) {
		SimpleString variableName = StringFromFormat("%s_%d_%d", fileNameOnly.asCharString(), line, i);
		if (!variableExists(variableName))
			return variableName;
    }
    return "";
}
Beispiel #7
0
bool MemoryReporterPlugin::parseArguments(int /* ac */, const char** av, int index)
{
	SimpleString argument (av[index]);
	if (argument.contains("-pmemoryreport=")) {
		argument.replace("-pmemoryreport=", "");

		destroyMemoryFormatter(formatter_);
		formatter_ = createMemoryFormatter(argument);
		return true;
	}
	return false;
}