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"
26 * Performs various in-depth test on NumberFormat
28 class DataDrivenNumberFormatTestSuite
: public IntlTest
{
31 DataDrivenNumberFormatTestSuite() {
32 for (int32_t i
= 0; i
< UPRV_LENGTHOF(fPreviousFormatters
); ++i
) {
33 fPreviousFormatters
[i
] = NULL
;
38 * Runs the data driven test suite.
40 * @param fileName is the name of the file in the source/test/testdata.
41 * This should be just a filename such as "numberformattest.txt"
42 * @param runAllTests If TRUE, runs every test in fileName. if FALSE,
43 * skips the tests that are known to break for ICU4C.
45 void run(const char *fileName
, UBool runAllTests
);
46 virtual ~DataDrivenNumberFormatTestSuite();
49 * Subclasses override this method to test formatting numbers.
50 * Subclasses must not override both isFormatPass methods.
51 * @param tuple the test data for current test. The format method can
52 * assume that the format and output fields are populated.
53 * @param appendErrorMessage any message describing failures appended
55 * @param status any error returned here.
56 * @return TRUE if test passed or FALSE if test failed.
58 virtual UBool
isFormatPass(
59 const NumberFormatTestTuple
&tuple
,
60 UnicodeString
&appendErrorMessage
,
65 * Subclasses override this method to test formatting numbers.
66 * Along with copy and assignment operators.
67 * @param tuple the test data for current test. The format method can
68 * assume that the format and output fields are populated.
69 * @param somePreviousFormatter A pointer to a previous formatter
70 * that the test framework owns. This formatter changes as tests
71 * are run. Subclasses should initialize a formatter and assign
72 * the newly initialized formatter to this formatter. In this way,
73 * assignment gets tested with multiple previous states.
74 * @param appendErrorMessage any message describing failures appended
76 * @param status any error returned here.
77 * @return TRUE if test passed or FALSE if test failed.
79 virtual UBool
isFormatPass(
80 const NumberFormatTestTuple
&tuple
,
81 UObject
*somePreviousFormatter
,
82 UnicodeString
&appendErrorMessage
,
85 * If subclass is testing formatting with copy and assignmet, it
86 * needs to override this method to return a newly allocated formatter.
88 virtual UObject
*newFormatter(UErrorCode
&status
);
91 * Tests toPattern method.
93 virtual UBool
isToPatternPass(
94 const NumberFormatTestTuple
&tuple
,
95 UnicodeString
&appendErrorMessage
,
100 virtual UBool
isParsePass(
101 const NumberFormatTestTuple
&tuple
,
102 UnicodeString
&appendErrorMessage
,
106 * Test parsing with currency.
108 virtual UBool
isParseCurrencyPass(
109 const NumberFormatTestTuple
&tuple
,
110 UnicodeString
&appendErrorMessage
,
114 * Test plural selection.
116 virtual UBool
isSelectPass(
117 const NumberFormatTestTuple
&tuple
,
118 UnicodeString
&appendErrorMessage
,
121 UnicodeString fFileLine
;
122 int32_t fFileLineNumber
;
123 UnicodeString fFileTestName
;
124 NumberFormatTestTuple fTuple
;
125 int32_t fFormatTestNumber
;
126 UObject
*fPreviousFormatters
[13];
128 void setTupleField(UErrorCode
&);
130 UnicodeString
*columnValues
,
131 int32_t columnValueCount
,
133 void showError(const char *message
);
134 void showFailure(const UnicodeString
&message
);
137 UBool
readLine(UCHARBUF
*f
, UErrorCode
&);
139 const NumberFormatTestTuple
&tuple
,
140 UnicodeString
&appendErrorMessage
,
143 #endif /* !UCONFIG_NO_FORMATTING */
144 #endif // _DATADRIVENNUMBERFORMATTESTSUITE_