]> git.saurik.com Git - apple/icu.git/blob - icuSources/tools/ctestfw/unicode/testlog.h
ICU-57166.0.1.tar.gz
[apple/icu.git] / icuSources / tools / ctestfw / unicode / testlog.h
1 /********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 2004-2010, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6
7 /* Created by grhoten 03/17/2004 */
8
9 /* Base class for data driven tests */
10
11 #ifndef U_TESTFW_TESTLOG
12 #define U_TESTFW_TESTLOG
13
14 #include "unicode/errorcode.h"
15 #include "unicode/unistr.h"
16 #include "unicode/testtype.h"
17
18 /** Facilitates internal logging of data driven test service
19 * It would be interesting to develop this into a full
20 * fledged control system as in Java.
21 */
22 class T_CTEST_EXPORT_API TestLog {
23 public:
24 virtual ~TestLog();
25 virtual void errln( const UnicodeString &message ) = 0;
26 virtual void logln( const UnicodeString &message ) = 0;
27 virtual void dataerrln( const UnicodeString &message ) = 0;
28 virtual const char* getTestDataPath(UErrorCode& err) = 0;
29 };
30
31 class T_CTEST_EXPORT_API IcuTestErrorCode : public ErrorCode {
32 public:
33 IcuTestErrorCode(TestLog &callingTestClass, const char *callingTestName) :
34 testClass(callingTestClass), testName(callingTestName) {}
35 virtual ~IcuTestErrorCode();
36 // Returns TRUE if isFailure().
37 UBool logIfFailureAndReset(const char *fmt, ...);
38 UBool logDataIfFailureAndReset(const char *fmt, ...);
39 protected:
40 virtual void handleFailure() const;
41 private:
42 TestLog &testClass;
43 const char *const testName;
44 };
45
46 #endif