]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
374ca955 A |
3 | /******************************************************************** |
4 | * COPYRIGHT: | |
729e4ab9 | 5 | * Copyright (c) 2004-2010, International Business Machines Corporation and |
374ca955 A |
6 | * others. All Rights Reserved. |
7 | ********************************************************************/ | |
8 | ||
9 | /* Created by grhoten 03/17/2004 */ | |
10 | ||
11 | /* Base class for data driven tests */ | |
12 | ||
13 | #ifndef U_TESTFW_TESTLOG | |
14 | #define U_TESTFW_TESTLOG | |
15 | ||
729e4ab9 | 16 | #include "unicode/errorcode.h" |
374ca955 | 17 | #include "unicode/unistr.h" |
73c04bcf | 18 | #include "unicode/testtype.h" |
374ca955 A |
19 | |
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. | |
23 | */ | |
73c04bcf | 24 | class T_CTEST_EXPORT_API TestLog { |
374ca955 | 25 | public: |
73c04bcf | 26 | virtual ~TestLog(); |
374ca955 | 27 | virtual void errln( const UnicodeString &message ) = 0; |
729e4ab9 | 28 | virtual void logln( const UnicodeString &message ) = 0; |
46f4442e | 29 | virtual void dataerrln( const UnicodeString &message ) = 0; |
374ca955 A |
30 | virtual const char* getTestDataPath(UErrorCode& err) = 0; |
31 | }; | |
32 | ||
729e4ab9 A |
33 | class T_CTEST_EXPORT_API IcuTestErrorCode : public ErrorCode { |
34 | public: | |
0f5d89e8 A |
35 | IcuTestErrorCode(TestLog &callingTestClass, const char *callingTestName) |
36 | : testClass(callingTestClass), testName(callingTestName), scopeMessage() {} | |
729e4ab9 | 37 | virtual ~IcuTestErrorCode(); |
0f5d89e8 | 38 | |
729e4ab9 | 39 | // Returns TRUE if isFailure(). |
0f5d89e8 A |
40 | UBool errIfFailureAndReset(); |
41 | UBool errIfFailureAndReset(const char *fmt, ...); | |
42 | UBool errDataIfFailureAndReset(); | |
43 | UBool errDataIfFailureAndReset(const char *fmt, ...); | |
44 | ||
45 | /** Sets an additional message string to be appended to failure output. */ | |
46 | void setScope(const char* message); | |
47 | void setScope(const UnicodeString& message); | |
48 | ||
729e4ab9 A |
49 | protected: |
50 | virtual void handleFailure() const; | |
0f5d89e8 | 51 | |
729e4ab9 A |
52 | private: |
53 | TestLog &testClass; | |
54 | const char *const testName; | |
0f5d89e8 A |
55 | UnicodeString scopeMessage; |
56 | ||
57 | void errlog(UBool dataErr, const char* extraMessage) const; | |
729e4ab9 | 58 | }; |
374ca955 A |
59 | |
60 | #endif |