ICU-9655 Consolidate test code

X-SVN-Rev: 33193
This commit is contained in:
Michael Ow 2013-02-12 06:46:51 +00:00
parent ca88f9ccba
commit e33bccf0e8
2 changed files with 24 additions and 25 deletions
icu4c/source/test/intltest

View file

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2012, International Business Machines Corporation and
* Copyright (c) 1997-2013, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
@ -1639,28 +1639,28 @@ static UnicodeString& escape(const UnicodeString& s, UnicodeString& result) {
#define VERBOSE_ASSERTIONS
UBool IntlTest::assertTrue(const char* message, UBool condition, UBool quiet, UBool possibleDataError) {
if (!condition) {
if (possibleDataError) {
dataerrln("FAIL: assertTrue() failed: %s", message);
} else {
errln("FAIL: assertTrue() failed: %s", message);
UBool IntlTest::assertTrue(const char* message, UBool condition, UBool quiet, UBool possibleDataError, const char *file, int line) {
if (file != NULL) {
if (!condition) {
if (possibleDataError) {
dataerrln("%s:%d: FAIL: assertTrue() failed: %s", file, line, message);
} else {
errln("%s:%d: FAIL: assertTrue() failed: %s", file, line, message);
}
} else if (!quiet) {
logln("%s:%d: Ok: %s", file, line, message);
}
} else {
if (!condition) {
if (possibleDataError) {
dataerrln("FAIL: assertTrue() failed: %s", message);
} else {
errln("FAIL: assertTrue() failed: %s", message);
}
} else if (!quiet) {
logln("Ok: %s", message);
}
} else if (!quiet) {
logln("Ok: %s", message);
}
return condition;
}
UBool IntlTest::assertTrue(const char *file, int line, const char* message, UBool condition, UBool quiet, UBool possibleDataError) {
if (!condition) {
if (possibleDataError) {
dataerrln("%s:%d: FAIL: assertTrue() failed: %s", file, line, message);
} else {
errln("%s:%d: FAIL: assertTrue() failed: %s", file, line, message);
}
} else if (!quiet) {
logln("%s:%d: Ok: %s", file, line, message);
}
return condition;
}

View file

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2012, International Business Machines Corporation and
* Copyright (c) 1997-2013, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
@ -121,7 +121,7 @@ UnicodeString toString(int32_t n);
}
#define TEST_ASSERT_TRUE(x) \
assertTrue(__FILE__, __LINE__, #x, (x), FALSE, FALSE)
assertTrue(#x, (x), FALSE, FALSE, __FILE__, __LINE__)
class IntlTest : public TestLog {
public:
@ -234,8 +234,7 @@ public:
protected:
/* JUnit-like assertions. Each returns TRUE if it succeeds. */
UBool assertTrue(const char* message, UBool condition, UBool quiet=FALSE, UBool possibleDataError=FALSE);
UBool assertTrue(const char *file, int line, const char* message, UBool condition, UBool quiet=FALSE, UBool possibleDataError=FALSE);
UBool assertTrue(const char* message, UBool condition, UBool quiet=FALSE, UBool possibleDataError=FALSE, const char *file=NULL, int line=0);
UBool assertFalse(const char* message, UBool condition, UBool quiet=FALSE);
UBool assertSuccess(const char* message, UErrorCode ec, UBool possibleDataError=FALSE);
UBool assertEquals(const char* message, const UnicodeString& expected,