Beispiel #1
0
Failure::Failure (const SimpleString&	theTestName, 
			 	  const SimpleString&	theFileName, 
				  long					theLineNumber,
				  const SimpleString&	expected,
				  const SimpleString&	actual) 
: testName (theTestName), 
  fileName (theFileName), 
  lineNumber (theLineNumber)
{
	char *part1 = "expected ";
	char *part3 = " but was: ";

	char *stage = new char [strlen (part1) 
					+ expected.size () 
					+ strlen (part3)
					+ actual.size ()
					+ 1];

	sprintf(stage, "%s%s%s%s", 
		part1, 
		expected.asCharString(), 
		part3, 
		actual.asCharString());

	message = SimpleString(stage);

	delete stage;
}
Beispiel #2
0
Failure::Failure (const SimpleString&	theTestName, 
			 	  const SimpleString&	theFileName, 
				  long					theLineNumber,
				  const SimpleString&	expected,
				  const SimpleString&	actual) 
: testName (theTestName), 
  fileName (theFileName), 
  lineNumber (theLineNumber)
{
	TCHAR *part1 = TEXT("expected ");
	TCHAR *part3 = TEXT(" but was: ");

	//[guyu modify
	size_t buflen = _tcslen (part1) 
					+ expected.size () 
					+ _tcslen (part3)
					+ actual.size ()
					+ 1;
	TCHAR *stage = new TCHAR [buflen];

	_stprintf_s (stage, buflen, TEXT("%s%s%s%s"), 
		part1, 
		expected.asCharString(), 
		part3, 
		actual.asCharString());
	//]guyu

	message = SimpleString(stage);

	delete stage;
}
Beispiel #3
0
void SimpleString::padStringsToSameLength(SimpleString& str1, SimpleString& str2, char padCharacter)
{
    if (str1.size() > str2.size()) {
        padStringsToSameLength(str2, str1, padCharacter);
        return;
    }

    char pad[2];
    pad[0] = padCharacter;
    pad[1] = 0;
    str1 = SimpleString(pad, str2.size() - str1.size()) + str1;
}
Beispiel #4
0
SimpleString SimpleString::operator= (const SimpleString& other)
{
	delete buffer;
	buffer = new char [other.size() + 1];
	strcpy(buffer, other.buffer);	
	return *this;
}
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());
}
SimpleString SimpleString::operator= (const SimpleString& other)
{
	delete buffer;
	buffer = NEW_BUFFER(other.size() + 1);
	strcpy(buffer, other.buffer);	
	return *this;
}
SimpleString SimpleString::operator+ (const SimpleString& other)
{
	SimpleString newS;
	free(newS.buffer);
	newS.buffer = NEW_BUFFER(this->size()+other.size()+1);
	strcpy(newS.buffer,this->asCharString());
	newS.buffer= strcat(newS.buffer,other.asCharString());
	return newS;
}
Beispiel #8
0
SimpleString HexStringFrom(signed char value)
{
    SimpleString result = StringFromFormat("%x", value);
    if(value < 0) {
        size_t size = result.size();
        result = result.subString(size-(CPPUTEST_CHAR_BIT/4));
    }
    return result;
}
Beispiel #9
0
SimpleString StringFromBinary(const unsigned char* value, size_t size)
{
    SimpleString result;

    for (size_t i = 0; i < size; i++) {
        result += StringFromFormat("%02X ", value[i]);
    }
    result = result.subString(0, result.size() - 1);

    return result;
}
Beispiel #10
0
SimpleString SimpleString::subString(size_t beginPos, size_t amount) const
{
    if (beginPos > size()-1) return "";

    SimpleString newString = buffer_ + beginPos;

    if (newString.size() > amount)
        newString.buffer_[amount] = '\0';

    return newString;
}
Beispiel #11
0
void NormalMemoryReportFormatter::report_testgroup_start(TestResult* result, UtestShell& test)
{
	const size_t line_size = 80;

	SimpleString groupName = StringFromFormat("TEST GROUP(%s)", test.getGroup().asCharString());
	size_t beginPos = (line_size/2) - (groupName.size()/2);

	SimpleString line("-", beginPos);
	line += groupName;
	line += SimpleString("-", line_size - line.size());
	line += "\n";
	result->print(line.asCharString());
}
Beispiel #12
0
static SimpleString addMarkerToString(const SimpleString& str, int markerPos)
{
	size_t bufferSize = str.size()+1;
	char* buffer = (char*) PlatformSpecificMalloc(bufferSize);
	str.copyToBuffer(buffer, bufferSize);

	buffer[markerPos] = '^';

	SimpleString result(buffer);
	PlatformSpecificFree(buffer);
	return result;

}
Beispiel #13
0
static SimpleString removeAllPrintableCharactersFrom(const SimpleString& str)
{
	size_t bufferSize = str.size()+1;
	char* buffer = (char*) PlatformSpecificMalloc(bufferSize);
	str.copyToBuffer(buffer, bufferSize);

	for (size_t i = 0; i < bufferSize-1; i++)
		if (buffer[i] != '\t' && buffer[i] != '\n')
			buffer[i] = ' ';

	SimpleString result(buffer);
	PlatformSpecificFree(buffer);
	return result;
}
bool CommandLineArguments::SetOutputType(int ac, const char** av, int& i)
{
	SimpleString outputType = getParameterField(ac, av, i);
	if (outputType.size() == 0) return false;

	if (outputType == "normal" || outputType == "eclipse") {
		outputType_ = OUTPUT_ECLIPSE;
		return true;
	}
	if (outputType == "junit") {
		outputType_ = OUTPUT_JUNIT;
		return true;
	}
	return false;
}
void CommandLineArguments::SetRepeatCount(int ac, const char** av, int& i)
{
  repeat_ = 0;

  SimpleString repeatParameter (av[i]);
  if (repeatParameter.size() > 2)
    repeat_ = PlatformSpecificAtoI(av[i] + 2);
  else if (i + 1 < ac)
    {
      repeat_ = PlatformSpecificAtoI(av[i+1]);
      if (repeat_ != 0)
        i++;
    }

  if (0 == repeat_)
    repeat_ = 2;

}
Beispiel #16
0
SimpleString TestFailure::createDifferenceAtPosString(const SimpleString& actual, size_t position)
{
	SimpleString result;
	const size_t extraCharactersWindow = 20;
	const size_t halfOfExtraCharactersWindow = extraCharactersWindow / 2;

	SimpleString paddingForPreventingOutOfBounds (" ", halfOfExtraCharactersWindow);
	SimpleString actualString = paddingForPreventingOutOfBounds + actual + paddingForPreventingOutOfBounds;
	SimpleString differentString = StringFromFormat("difference starts at position %lu at: <", (unsigned long) position);

	result += "\n";
	result += StringFromFormat("\t%s%s>\n", differentString.asCharString(), actualString.subString(position, extraCharactersWindow).asCharString());

	SimpleString markString = actualString.subString(position, halfOfExtraCharactersWindow+1);
	markString = removeAllPrintableCharactersFrom(markString);
	markString = addMarkerToString(markString, halfOfExtraCharactersWindow);

	result += StringFromFormat("\t%s%s", SimpleString(" ", differentString.size()).asCharString(), markString.asCharString());
	return result;
}
SimpleString::SimpleString(const SimpleString& other)
{
	size_t len = other.size() + 1;
	buffer_ = allocStringBuffer(len);
	PlatformSpecificStrCpy(buffer_, other.buffer_);
}
Beispiel #18
0
SimpleString::SimpleString (const SimpleString& other)
{
    int len = other.size() + 1;
    buffer = allocString(len);
    PlatformSpecificStrCpy(buffer, other.buffer);
}
Beispiel #19
0
SimpleString::SimpleString (const SimpleString& other)
{
	buffer = new char [other.size() + 1];
	strcpy(buffer, other.buffer);
}
SimpleString::SimpleString (const SimpleString& other)
{
	buffer = NEW_BUFFER(other.size() + 1);
	strcpy(buffer, other.buffer);
}