1 /************************************************************************
3 * Copyright (c) 2015, International Business Machines Corporation
4 * and others. All Rights Reserved.
5 ************************************************************************/
7 #ifndef _DATADRIVENNUMBERFORMATTESTSUITE_H__
8 #define _DATADRIVENNUMBERFORMATTESTSUITE_H__
10 #include "unicode/utypes.h"
12 #if !UCONFIG_NO_FORMATTING
14 #include "unicode/uobject.h"
15 #include "unicode/unistr.h"
16 #include "numberformattesttuple.h"
23 * Performs various in-depth test on NumberFormat
25 class DataDrivenNumberFormatTestSuite
: public IntlTest
{
28 DataDrivenNumberFormatTestSuite() {
29 for (int32_t i
= 0; i
< UPRV_LENGTHOF(fPreviousFormatters
); ++i
) {
30 fPreviousFormatters
[i
] = NULL
;
35 * Runs the data driven test suite.
37 * @param fileName is the name of the file in the source/test/testdata.
38 * This should be just a filename such as "numberformattest.txt"
39 * @param runAllTests If TRUE, runs every test in fileName. if FALSE,
40 * skips the tests that are known to break for ICU4C.
42 void run(const char *fileName
, UBool runAllTests
);
43 virtual ~DataDrivenNumberFormatTestSuite();
46 * Subclasses override this method to test formatting numbers.
47 * Subclasses must not override both isFormatPass methods.
48 * @param tuple the test data for current test. The format method can
49 * assume that the format and output fields are populated.
50 * @param appendErrorMessage any message describing failures appended
52 * @param status any error returned here.
53 * @return TRUE if test passed or FALSE if test failed.
55 virtual UBool
isFormatPass(
56 const NumberFormatTestTuple
&tuple
,
57 UnicodeString
&appendErrorMessage
,
62 * Subclasses override this method to test formatting numbers.
63 * Along with copy and assignment operators.
64 * @param tuple the test data for current test. The format method can
65 * assume that the format and output fields are populated.
66 * @param somePreviousFormatter A pointer to a previous formatter
67 * that the test framework owns. This formatter changes as tests
68 * are run. Subclasses should initialize a formatter and assign
69 * the newly initialized formatter to this formatter. In this way,
70 * assignment gets tested with multiple previous states.
71 * @param appendErrorMessage any message describing failures appended
73 * @param status any error returned here.
74 * @return TRUE if test passed or FALSE if test failed.
76 virtual UBool
isFormatPass(
77 const NumberFormatTestTuple
&tuple
,
78 UObject
*somePreviousFormatter
,
79 UnicodeString
&appendErrorMessage
,
82 * If subclass is testing formatting with copy and assignmet, it
83 * needs to override this method to return a newly allocated formatter.
85 virtual UObject
*newFormatter(UErrorCode
&status
);
88 * Tests toPattern method.
90 virtual UBool
isToPatternPass(
91 const NumberFormatTestTuple
&tuple
,
92 UnicodeString
&appendErrorMessage
,
97 virtual UBool
isParsePass(
98 const NumberFormatTestTuple
&tuple
,
99 UnicodeString
&appendErrorMessage
,
103 * Test parsing with currency.
105 virtual UBool
isParseCurrencyPass(
106 const NumberFormatTestTuple
&tuple
,
107 UnicodeString
&appendErrorMessage
,
111 * Test plural selection.
113 virtual UBool
isSelectPass(
114 const NumberFormatTestTuple
&tuple
,
115 UnicodeString
&appendErrorMessage
,
118 UnicodeString fFileLine
;
119 int32_t fFileLineNumber
;
120 UnicodeString fFileTestName
;
121 NumberFormatTestTuple fTuple
;
122 int32_t fFormatTestNumber
;
123 UObject
*fPreviousFormatters
[13];
125 void setTupleField(UErrorCode
&);
127 UnicodeString
*columnValues
,
128 int32_t columnValueCount
,
130 void showError(const char *message
);
131 void showFailure(const UnicodeString
&message
);
134 UBool
readLine(UCHARBUF
*f
, UErrorCode
&);
136 const NumberFormatTestTuple
&tuple
,
137 UnicodeString
&appendErrorMessage
,
140 #endif /* !UCONFIG_NO_FORMATTING */
141 #endif // _DATADRIVENNUMBERFORMATTESTSUITE_