ContainsFailure::ContainsFailure(UtestShell* test, const char* fileName, int lineNumber, const SimpleString& expected, const SimpleString& actual, const SimpleString& text) : TestFailure(test, fileName, lineNumber) { message_ = createUserText(text); message_ += StringFromFormat("actual <%s>\n\tdid not contain <%s>", actual.asCharString(), expected.asCharString()); }
EqualsFailure::EqualsFailure(UtestShell* test, const char* fileName, int lineNumber, const SimpleString& expected, const SimpleString& actual, const SimpleString& text) : TestFailure(test, fileName, lineNumber) { message_ = createUserText(text); message_ += createButWasString(expected, actual); }
BitsEqualFailure::BitsEqualFailure(UtestShell* test, const char* fileName, int lineNumber, unsigned long expected, unsigned long actual, unsigned long mask, size_t byteCount, const SimpleString& text) : TestFailure(test, fileName, lineNumber) { message_ = createUserText(text); message_ += createButWasString(StringFromMaskedBits(expected, mask, byteCount), StringFromMaskedBits(actual, mask, byteCount)); }
FeatureUnsupportedFailure::FeatureUnsupportedFailure(UtestShell* test, const char* fileName, int lineNumber, const SimpleString& featureName, const SimpleString& text) : TestFailure(test, fileName, lineNumber) { message_ = createUserText(text); message_ += StringFromFormat("The feature \"%s\" is not supported in this environment or with the feature set selected when building the library.", featureName.asCharString());; }
CheckFailure::CheckFailure(UtestShell* test, const char* fileName, int lineNumber, const SimpleString& checkString, const SimpleString& conditionString, const SimpleString& text) : TestFailure(test, fileName, lineNumber) { message_ = createUserText(text); message_ += checkString; message_ += "("; message_ += conditionString; message_ += ") failed"; }
CheckEqualFailure::CheckEqualFailure(UtestShell* test, const char* fileName, int lineNumber, const SimpleString& expected, const SimpleString& actual, const SimpleString& text) : TestFailure(test, fileName, lineNumber) { message_ = createUserText(text); size_t failStart; for (failStart = 0; actual.asCharString()[failStart] == expected.asCharString()[failStart]; failStart++) ; message_ += createButWasString(expected, actual); message_ += createDifferenceAtPosString(actual, failStart); }
DoublesEqualFailure::DoublesEqualFailure(UtestShell* test, const char* fileName, int lineNumber, double expected, double actual, double threshold, const SimpleString& text) : TestFailure(test, fileName, lineNumber) { message_ = createUserText(text); message_ += createButWasString(StringFrom(expected, 7), StringFrom(actual, 7)); message_ += " threshold used was <"; message_ += StringFrom(threshold, 7); message_ += ">"; if (PlatformSpecificIsNan(expected) || PlatformSpecificIsNan(actual) || PlatformSpecificIsNan(threshold)) message_ += "\n\tCannot make comparisons with Nan"; }
StringEqualNoCaseFailure::StringEqualNoCaseFailure(UtestShell* test, const char* fileName, int lineNumber, const char* expected, const char* actual, const SimpleString& text) : TestFailure(test, fileName, lineNumber) { message_ = createUserText(text); message_ += createButWasString(StringFromOrNull(expected), StringFromOrNull(actual)); if((expected) && (actual)) { size_t failStart; for (failStart = 0; SimpleString::ToLower(actual[failStart]) == SimpleString::ToLower(expected[failStart]); failStart++) ; message_ += createDifferenceAtPosString(actual, failStart); } }
SignedBytesEqualFailure::SignedBytesEqualFailure (UtestShell* test, const char* fileName, int lineNumber, signed char expected, signed char actual, const SimpleString& text) : TestFailure(test, fileName, lineNumber) { message_ = createUserText(text); SimpleString aDecimal = StringFrom((int)actual); SimpleString eDecimal = StringFrom((int)expected); SimpleString::padStringsToSameLength(aDecimal, eDecimal, ' '); SimpleString actualReported = aDecimal + " " + BracketsFormattedHexStringFrom(actual); SimpleString expectedReported = eDecimal + " " + BracketsFormattedHexStringFrom(expected); message_ += createButWasString(expectedReported, actualReported); }
BinaryEqualFailure::BinaryEqualFailure(UtestShell* test, const char* fileName, int lineNumber, const unsigned char* expected, const unsigned char* actual, size_t size, const SimpleString& text) : TestFailure(test, fileName, lineNumber) { message_ = createUserText(text); message_ += createButWasString(StringFromBinaryOrNull(expected, size), StringFromBinaryOrNull(actual, size)); if ((expected) && (actual)) { size_t failStart; for (failStart = 0; actual[failStart] == expected[failStart]; failStart++) ; message_ += createDifferenceAtPosString(StringFromBinary(actual, size), failStart, DIFFERENCE_BINARY); } }
UnsignedLongsEqualFailure::UnsignedLongsEqualFailure(UtestShell* test, const char* fileName, int lineNumber, unsigned long expected, unsigned long actual, const SimpleString& text) : TestFailure(test, fileName, lineNumber) { message_ = createUserText(text); SimpleString aDecimal = StringFrom(actual); SimpleString aHex = HexStringFrom(actual); SimpleString eDecimal = StringFrom(expected); SimpleString eHex = HexStringFrom(expected); SimpleString::padStringsToSameLength(aDecimal, eDecimal, ' '); SimpleString::padStringsToSameLength(aHex, eHex, '0'); SimpleString actualReported = aDecimal + " 0x" + aHex; SimpleString expectedReported = eDecimal + " 0x" + eHex; message_ += createButWasString(expectedReported, actualReported); }