michael@0: /******************************************************************** michael@0: * COPYRIGHT: michael@0: * Copyright (c) 2004-2010, International Business Machines Corporation and michael@0: * others. All Rights Reserved. michael@0: ********************************************************************/ michael@0: michael@0: /* Created by grhoten 03/17/2004 */ michael@0: michael@0: /* Base class for data driven tests */ michael@0: michael@0: #ifndef U_TESTFW_TESTLOG michael@0: #define U_TESTFW_TESTLOG michael@0: michael@0: #include "unicode/errorcode.h" michael@0: #include "unicode/unistr.h" michael@0: #include "unicode/testtype.h" michael@0: michael@0: /** Facilitates internal logging of data driven test service michael@0: * It would be interesting to develop this into a full michael@0: * fledged control system as in Java. michael@0: */ michael@0: class T_CTEST_EXPORT_API TestLog { michael@0: public: michael@0: virtual ~TestLog(); michael@0: virtual void errln( const UnicodeString &message ) = 0; michael@0: virtual void logln( const UnicodeString &message ) = 0; michael@0: virtual void dataerrln( const UnicodeString &message ) = 0; michael@0: virtual const char* getTestDataPath(UErrorCode& err) = 0; michael@0: }; michael@0: michael@0: class T_CTEST_EXPORT_API IcuTestErrorCode : public ErrorCode { michael@0: public: michael@0: IcuTestErrorCode(TestLog &callingTestClass, const char *callingTestName) : michael@0: testClass(callingTestClass), testName(callingTestName) {} michael@0: virtual ~IcuTestErrorCode(); michael@0: // Returns TRUE if isFailure(). michael@0: UBool logIfFailureAndReset(const char *fmt, ...); michael@0: UBool logDataIfFailureAndReset(const char *fmt, ...); michael@0: protected: michael@0: virtual void handleFailure() const; michael@0: private: michael@0: TestLog &testClass; michael@0: const char *const testName; michael@0: }; michael@0: michael@0: #endif