1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
5 * Copyright (c) 2004-2010, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
9 /* Created by grhoten 03/17/2004 */
11 /* Base class for data driven tests */
13 #ifndef U_TESTFW_TESTLOG
14 #define U_TESTFW_TESTLOG
16 #include "unicode/errorcode.h"
17 #include "unicode/unistr.h"
18 #include "unicode/testtype.h"
20 /** Facilitates internal logging of data driven test service
21 * It would be interesting to develop this into a full
22 * fledged control system as in Java.
24 class T_CTEST_EXPORT_API TestLog
{
27 virtual void errln( const UnicodeString
&message
) = 0;
28 virtual void logln( const UnicodeString
&message
) = 0;
29 virtual void dataerrln( const UnicodeString
&message
) = 0;
30 virtual const char* getTestDataPath(UErrorCode
& err
) = 0;
33 class T_CTEST_EXPORT_API IcuTestErrorCode
: public ErrorCode
{
35 IcuTestErrorCode(TestLog
&callingTestClass
, const char *callingTestName
)
36 : testClass(callingTestClass
), testName(callingTestName
), scopeMessage() {}
37 virtual ~IcuTestErrorCode();
39 // Returns TRUE if isFailure().
40 UBool
errIfFailureAndReset();
41 UBool
errIfFailureAndReset(const char *fmt
, ...);
42 UBool
errDataIfFailureAndReset();
43 UBool
errDataIfFailureAndReset(const char *fmt
, ...);
44 UBool
expectErrorAndReset(UErrorCode expectedError
);
45 UBool
expectErrorAndReset(UErrorCode expectedError
, const char *fmt
, ...);
47 /** Sets an additional message string to be appended to failure output. */
48 void setScope(const char* message
);
49 void setScope(const UnicodeString
& message
);
52 virtual void handleFailure() const;
56 const char *const testName
;
57 UnicodeString scopeMessage
;
59 void errlog(UBool dataErr
, const UnicodeString
& mainMessage
, const char* extraMessage
) const;