1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/tools/ctestfw/unicode/testlog.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,46 @@ 1.4 +/******************************************************************** 1.5 + * COPYRIGHT: 1.6 + * Copyright (c) 2004-2010, International Business Machines Corporation and 1.7 + * others. All Rights Reserved. 1.8 + ********************************************************************/ 1.9 + 1.10 +/* Created by grhoten 03/17/2004 */ 1.11 + 1.12 +/* Base class for data driven tests */ 1.13 + 1.14 +#ifndef U_TESTFW_TESTLOG 1.15 +#define U_TESTFW_TESTLOG 1.16 + 1.17 +#include "unicode/errorcode.h" 1.18 +#include "unicode/unistr.h" 1.19 +#include "unicode/testtype.h" 1.20 + 1.21 +/** Facilitates internal logging of data driven test service 1.22 + * It would be interesting to develop this into a full 1.23 + * fledged control system as in Java. 1.24 + */ 1.25 +class T_CTEST_EXPORT_API TestLog { 1.26 +public: 1.27 + virtual ~TestLog(); 1.28 + virtual void errln( const UnicodeString &message ) = 0; 1.29 + virtual void logln( const UnicodeString &message ) = 0; 1.30 + virtual void dataerrln( const UnicodeString &message ) = 0; 1.31 + virtual const char* getTestDataPath(UErrorCode& err) = 0; 1.32 +}; 1.33 + 1.34 +class T_CTEST_EXPORT_API IcuTestErrorCode : public ErrorCode { 1.35 +public: 1.36 + IcuTestErrorCode(TestLog &callingTestClass, const char *callingTestName) : 1.37 + testClass(callingTestClass), testName(callingTestName) {} 1.38 + virtual ~IcuTestErrorCode(); 1.39 + // Returns TRUE if isFailure(). 1.40 + UBool logIfFailureAndReset(const char *fmt, ...); 1.41 + UBool logDataIfFailureAndReset(const char *fmt, ...); 1.42 +protected: 1.43 + virtual void handleFailure() const; 1.44 +private: 1.45 + TestLog &testClass; 1.46 + const char *const testName; 1.47 +}; 1.48 + 1.49 +#endif