ICU-13661 IcuTestErrorCode code review feedback.
X-SVN-Rev: 41369
This commit is contained in:
parent
31ead7f739
commit
035a2aae0e
@ -259,6 +259,8 @@ void ErrorCodeTest::TestSubclass() {
|
|||||||
class IcuTestErrorCodeTestHelper : public IntlTest {
|
class IcuTestErrorCodeTestHelper : public IntlTest {
|
||||||
public:
|
public:
|
||||||
void errln( const UnicodeString &message ) U_OVERRIDE {
|
void errln( const UnicodeString &message ) U_OVERRIDE {
|
||||||
|
test->assertFalse("Already saw an error", seenError);
|
||||||
|
seenError = TRUE;
|
||||||
test->assertEquals("Message for Error", expectedErrln, message);
|
test->assertEquals("Message for Error", expectedErrln, message);
|
||||||
if (expectedDataErr) {
|
if (expectedDataErr) {
|
||||||
test->errln("Got non-data error, but expected data error");
|
test->errln("Got non-data error, but expected data error");
|
||||||
@ -266,6 +268,8 @@ class IcuTestErrorCodeTestHelper : public IntlTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void dataerrln( const UnicodeString &message ) U_OVERRIDE {
|
void dataerrln( const UnicodeString &message ) U_OVERRIDE {
|
||||||
|
test->assertFalse("Already saw an error", seenError);
|
||||||
|
seenError = TRUE;
|
||||||
test->assertEquals("Message for Error", expectedErrln, message);
|
test->assertEquals("Message for Error", expectedErrln, message);
|
||||||
if (!expectedDataErr) {
|
if (!expectedDataErr) {
|
||||||
test->errln("Got data error, but expected non-data error");
|
test->errln("Got data error, but expected non-data error");
|
||||||
@ -275,6 +279,7 @@ class IcuTestErrorCodeTestHelper : public IntlTest {
|
|||||||
IntlTest* test;
|
IntlTest* test;
|
||||||
UBool expectedDataErr;
|
UBool expectedDataErr;
|
||||||
UnicodeString expectedErrln;
|
UnicodeString expectedErrln;
|
||||||
|
UBool seenError;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ErrorCodeTest::TestIcuTestErrorCode() {
|
void ErrorCodeTest::TestIcuTestErrorCode() {
|
||||||
@ -284,43 +289,55 @@ void ErrorCodeTest::TestIcuTestErrorCode() {
|
|||||||
// Test destructor message
|
// Test destructor message
|
||||||
helper.expectedErrln = u"AAA failure: U_ILLEGAL_PAD_POSITION";
|
helper.expectedErrln = u"AAA failure: U_ILLEGAL_PAD_POSITION";
|
||||||
helper.expectedDataErr = FALSE;
|
helper.expectedDataErr = FALSE;
|
||||||
|
helper.seenError = FALSE;
|
||||||
{
|
{
|
||||||
IcuTestErrorCode testStatus(helper, "AAA");
|
IcuTestErrorCode testStatus(helper, "AAA");
|
||||||
testStatus.set(U_ILLEGAL_PAD_POSITION);
|
testStatus.set(U_ILLEGAL_PAD_POSITION);
|
||||||
}
|
}
|
||||||
|
assertTrue("Should have seen an error", helper.seenError);
|
||||||
|
|
||||||
// Test destructor message with scope
|
// Test destructor message with scope
|
||||||
helper.expectedErrln = u"BBB failure: U_ILLEGAL_PAD_POSITION scope: foo";
|
helper.expectedErrln = u"BBB failure: U_ILLEGAL_PAD_POSITION scope: foo";
|
||||||
helper.expectedDataErr = FALSE;
|
helper.expectedDataErr = FALSE;
|
||||||
|
helper.seenError = FALSE;
|
||||||
{
|
{
|
||||||
IcuTestErrorCode testStatus(helper, "BBB");
|
IcuTestErrorCode testStatus(helper, "BBB");
|
||||||
testStatus.setScope("foo");
|
testStatus.setScope("foo");
|
||||||
testStatus.set(U_ILLEGAL_PAD_POSITION);
|
testStatus.set(U_ILLEGAL_PAD_POSITION);
|
||||||
}
|
}
|
||||||
|
assertTrue("Should have seen an error", helper.seenError);
|
||||||
|
|
||||||
// Check errIfFailure message with scope
|
// Check errIfFailure message with scope
|
||||||
helper.expectedErrln = u"CCC failure: U_ILLEGAL_PAD_POSITION scope: foo";
|
helper.expectedErrln = u"CCC failure: U_ILLEGAL_PAD_POSITION scope: foo";
|
||||||
helper.expectedDataErr = FALSE;
|
helper.expectedDataErr = FALSE;
|
||||||
|
helper.seenError = FALSE;
|
||||||
{
|
{
|
||||||
IcuTestErrorCode testStatus(helper, "CCC");
|
IcuTestErrorCode testStatus(helper, "CCC");
|
||||||
testStatus.setScope("foo");
|
testStatus.setScope("foo");
|
||||||
testStatus.set(U_ILLEGAL_PAD_POSITION);
|
testStatus.set(U_ILLEGAL_PAD_POSITION);
|
||||||
testStatus.errIfFailureAndReset();
|
testStatus.errIfFailureAndReset();
|
||||||
|
assertTrue("Should have seen an error", helper.seenError);
|
||||||
|
helper.seenError = FALSE;
|
||||||
helper.expectedErrln = u"CCC failure: U_ILLEGAL_CHAR_FOUND scope: foo - 5.4300";
|
helper.expectedErrln = u"CCC failure: U_ILLEGAL_CHAR_FOUND scope: foo - 5.4300";
|
||||||
testStatus.set(U_ILLEGAL_CHAR_FOUND);
|
testStatus.set(U_ILLEGAL_CHAR_FOUND);
|
||||||
testStatus.errIfFailureAndReset("%6.4f", 5.43);
|
testStatus.errIfFailureAndReset("%6.4f", 5.43);
|
||||||
|
assertTrue("Should have seen an error", helper.seenError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check errDataIfFailure message without scope
|
// Check errDataIfFailure message without scope
|
||||||
helper.expectedErrln = u"DDD failure: U_ILLEGAL_PAD_POSITION";
|
helper.expectedErrln = u"DDD failure: U_ILLEGAL_PAD_POSITION";
|
||||||
helper.expectedDataErr = TRUE;
|
helper.expectedDataErr = TRUE;
|
||||||
|
helper.seenError = FALSE;
|
||||||
{
|
{
|
||||||
IcuTestErrorCode testStatus(helper, "DDD");
|
IcuTestErrorCode testStatus(helper, "DDD");
|
||||||
testStatus.set(U_ILLEGAL_PAD_POSITION);
|
testStatus.set(U_ILLEGAL_PAD_POSITION);
|
||||||
testStatus.errDataIfFailureAndReset();
|
testStatus.errDataIfFailureAndReset();
|
||||||
|
assertTrue("Should have seen an error", helper.seenError);
|
||||||
|
helper.seenError = FALSE;
|
||||||
helper.expectedErrln = u"DDD failure: U_ILLEGAL_CHAR_FOUND - 5.4300";
|
helper.expectedErrln = u"DDD failure: U_ILLEGAL_CHAR_FOUND - 5.4300";
|
||||||
testStatus.set(U_ILLEGAL_CHAR_FOUND);
|
testStatus.set(U_ILLEGAL_CHAR_FOUND);
|
||||||
testStatus.errDataIfFailureAndReset("%6.4f", 5.43);
|
testStatus.errDataIfFailureAndReset("%6.4f", 5.43);
|
||||||
|
assertTrue("Should have seen an error", helper.seenError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
TestLog::~TestLog() {}
|
TestLog::~TestLog() {}
|
||||||
|
|
||||||
IcuTestErrorCode::~IcuTestErrorCode() {
|
IcuTestErrorCode::~IcuTestErrorCode() {
|
||||||
// Safe because our handleFailure() does not throw exceptions.
|
// Safe because our errlog() does not throw exceptions.
|
||||||
if(isFailure()) {
|
if(isFailure()) {
|
||||||
errlog(FALSE, nullptr);
|
errlog(FALSE, nullptr);
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ void IcuTestErrorCode::setScope(const char* message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IcuTestErrorCode::setScope(const UnicodeString& message) {
|
void IcuTestErrorCode::setScope(const UnicodeString& message) {
|
||||||
scopeMessage.remove().append(message);
|
scopeMessage = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IcuTestErrorCode::handleFailure() const {
|
void IcuTestErrorCode::handleFailure() const {
|
||||||
|
Loading…
Reference in New Issue
Block a user