1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /************************************************************************
5 * Copyright (c) 2015, International Business Machines Corporation
6 * and others. All Rights Reserved.
7 ************************************************************************/
9 #ifndef _DATADRIVENNUMBERFORMATTESTSUITE_H__
10 #define _DATADRIVENNUMBERFORMATTESTSUITE_H__
12 #include "unicode/utypes.h"
14 #if !UCONFIG_NO_FORMATTING
16 #include "unicode/uobject.h"
17 #include "unicode/unistr.h"
18 #include "numberformattesttuple.h"
25 * Performs various in-depth test on NumberFormat
27 class DataDrivenNumberFormatTestSuite
: public IntlTest
{
30 DataDrivenNumberFormatTestSuite() {
31 for (int32_t i
= 0; i
< UPRV_LENGTHOF(fPreviousFormatters
); ++i
) {
32 fPreviousFormatters
[i
] = NULL
;
37 * Runs the data driven test suite.
39 * @param fileName is the name of the file in the source/test/testdata.
40 * This should be just a filename such as "numberformattest.txt"
41 * @param runAllTests If TRUE, runs every test in fileName. if FALSE,
42 * skips the tests that are known to break for ICU4C.
44 void run(const char *fileName
, UBool runAllTests
);
45 virtual ~DataDrivenNumberFormatTestSuite();
48 * Subclasses override this method to test formatting numbers.
49 * Subclasses must not override both isFormatPass methods.
50 * @param tuple the test data for current test. The format method can
51 * assume that the format and output fields are populated.
52 * @param appendErrorMessage any message describing failures appended
54 * @param status any error returned here.
55 * @return TRUE if test passed or FALSE if test failed.
57 virtual UBool
isFormatPass(
58 const NumberFormatTestTuple
&tuple
,
59 UnicodeString
&appendErrorMessage
,
64 * Subclasses override this method to test formatting numbers.
65 * Along with copy and assignment operators.
66 * @param tuple the test data for current test. The format method can
67 * assume that the format and output fields are populated.
68 * @param somePreviousFormatter A pointer to a previous formatter
69 * that the test framework owns. This formatter changes as tests
70 * are run. Subclasses should initialize a formatter and assign
71 * the newly initialized formatter to this formatter. In this way,
72 * assignment gets tested with multiple previous states.
73 * @param appendErrorMessage any message describing failures appended
75 * @param status any error returned here.
76 * @return TRUE if test passed or FALSE if test failed.
78 virtual UBool
isFormatPass(
79 const NumberFormatTestTuple
&tuple
,
80 UObject
*somePreviousFormatter
,
81 UnicodeString
&appendErrorMessage
,
84 * If subclass is testing formatting with copy and assignmet, it
85 * needs to override this method to return a newly allocated formatter.
87 virtual UObject
*newFormatter(UErrorCode
&status
);
90 * Tests toPattern method.
92 virtual UBool
isToPatternPass(
93 const NumberFormatTestTuple
&tuple
,
94 UnicodeString
&appendErrorMessage
,
99 virtual UBool
isParsePass(
100 const NumberFormatTestTuple
&tuple
,
101 UnicodeString
&appendErrorMessage
,
105 * Test parsing with currency.
107 virtual UBool
isParseCurrencyPass(
108 const NumberFormatTestTuple
&tuple
,
109 UnicodeString
&appendErrorMessage
,
113 * Test plural selection.
115 virtual UBool
isSelectPass(
116 const NumberFormatTestTuple
&tuple
,
117 UnicodeString
&appendErrorMessage
,
120 UnicodeString fFileLine
;
121 int32_t fFileLineNumber
;
122 UnicodeString fFileTestName
;
123 NumberFormatTestTuple fTuple
;
124 int32_t fFormatTestNumber
;
125 UObject
*fPreviousFormatters
[13];
127 void setTupleField(UErrorCode
&);
129 UnicodeString
*columnValues
,
130 int32_t columnValueCount
,
132 void showError(const char *message
);
133 void showFailure(const UnicodeString
&message
);
136 UBool
readLine(UCHARBUF
*f
, UErrorCode
&);
138 const NumberFormatTestTuple
&tuple
,
139 UnicodeString
&appendErrorMessage
,
142 #endif /* !UCONFIG_NO_FORMATTING */
143 #endif // _DATADRIVENNUMBERFORMATTESTSUITE_