blob: 9db35b9ca853986a2c5c157a841fd99c38bc4a41 [file] [log] [blame]
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use:
* Copyright (c) 2004-2010, International Business Machines Corporation and
* others. All Rights Reserved.
/* Created by grhoten 03/17/2004 */
/* Base class for data driven tests */
#include "unicode/errorcode.h"
#include "unicode/unistr.h"
#include "unicode/testtype.h"
/** Facilitates internal logging of data driven test service
* It would be interesting to develop this into a full
* fledged control system as in Java.
class T_CTEST_EXPORT_API TestLog {
virtual ~TestLog();
virtual void errln( const UnicodeString &message ) = 0;
virtual void logln( const UnicodeString &message ) = 0;
virtual void dataerrln( const UnicodeString &message ) = 0;
virtual const char* getTestDataPath(UErrorCode& err) = 0;
class T_CTEST_EXPORT_API IcuTestErrorCode : public ErrorCode {
IcuTestErrorCode(TestLog &callingTestClass, const char *callingTestName)
: testClass(callingTestClass), testName(callingTestName), scopeMessage() {}
virtual ~IcuTestErrorCode();
// Returns TRUE if isFailure().
UBool errIfFailureAndReset();
UBool errIfFailureAndReset(const char *fmt, ...);
UBool errDataIfFailureAndReset();
UBool errDataIfFailureAndReset(const char *fmt, ...);
UBool expectErrorAndReset(UErrorCode expectedError);
UBool expectErrorAndReset(UErrorCode expectedError, const char *fmt, ...);
/** Sets an additional message string to be appended to failure output. */
void setScope(const char* message);
void setScope(const UnicodeString& message);
virtual void handleFailure() const;
TestLog &testClass;
const char *const testName;
UnicodeString scopeMessage;
void errlog(UBool dataErr, const UnicodeString& mainMessage, const char* extraMessage) const;