2 *******************************************************************************
3 * Copyright (C) 2015, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
7 #ifndef _NUMBER_FORMAT_TEST_TUPLE
8 #define _NUMBER_FORMAT_TEST_TUPLE
10 #include "unicode/utypes.h"
12 #if !UCONFIG_NO_FORMATTING
14 #include "decimalformatpattern.h"
15 #include "unicode/decimfmt.h"
16 #include "unicode/ucurr.h"
18 #define NFTT_GET_FIELD(tuple, fieldName, defaultValue) ((tuple).fieldName##Flag ? (tuple).fieldName : (defaultValue))
22 enum ENumberFormatTestTupleField
{
48 kMinimumExponentDigits
,
49 kExponentSignAlwaysShown
,
50 kDecimalSeparatorAlwaysShown
,
64 kDecimalPatternMatchRequired
,
67 kNumberFormatTestTupleFieldCount
71 * NumberFormatTestTuple represents the data for a single data driven test.
72 * It consist of named fields each of which may or may not be set. Each field
73 * has a particular meaning in the test. For more information on what each
74 * field means and how the data drive tests work, please see
75 * https://docs.google.com/document/d/1T2P0p953_Lh1pRwo-5CuPVrHlIBa_wcXElG-Hhg_WHM/edit?usp=sharing
76 * Each field is optional. That is, a certain field may be unset for a given
77 * test. The UBool fields ending in "Flag" indicate whether the corrresponding
78 * field is set or not. TRUE means set; FALSE means unset. An unset field
79 * generally means that the corresponding setter method is not called on
80 * the NumberFormat object.
83 class NumberFormatTestTuple
{
86 UnicodeString currency
;
87 UnicodeString pattern
;
90 UnicodeString comment
;
91 int32_t minIntegerDigits
;
92 int32_t maxIntegerDigits
;
93 int32_t minFractionDigits
;
94 int32_t maxFractionDigits
;
95 int32_t minGroupingDigits
;
102 double roundingIncrement
;
104 UnicodeString padCharacter
;
105 int32_t useScientific
;
108 DecimalFormat::ERoundingMode roundingMode
;
109 UCurrencyUsage currencyUsage
;
110 int32_t minimumExponentDigits
;
111 int32_t exponentSignAlwaysShown
;
112 int32_t decimalSeparatorAlwaysShown
;
113 DecimalFormat::EPadPosition padPosition
;
114 UnicodeString positivePrefix
;
115 UnicodeString positiveSuffix
;
116 UnicodeString negativePrefix
;
117 UnicodeString negativeSuffix
;
118 UnicodeString localizedPattern
;
119 UnicodeString toPattern
;
120 UnicodeString toLocalizedPattern
;
121 UNumberFormatStyle style
;
124 UnicodeString plural
;
125 int32_t parseIntegerOnly
;
126 int32_t decimalPatternMatchRequired
;
127 int32_t parseNoExponent
;
128 UnicodeString outputCurrency
;
136 UBool minIntegerDigitsFlag
;
137 UBool maxIntegerDigitsFlag
;
138 UBool minFractionDigitsFlag
;
139 UBool maxFractionDigitsFlag
;
140 UBool minGroupingDigitsFlag
;
142 UBool useSigDigitsFlag
;
143 UBool minSigDigitsFlag
;
144 UBool maxSigDigitsFlag
;
145 UBool useGroupingFlag
;
146 UBool multiplierFlag
;
147 UBool roundingIncrementFlag
;
148 UBool formatWidthFlag
;
149 UBool padCharacterFlag
;
150 UBool useScientificFlag
;
153 UBool roundingModeFlag
;
154 UBool currencyUsageFlag
;
155 UBool minimumExponentDigitsFlag
;
156 UBool exponentSignAlwaysShownFlag
;
157 UBool decimalSeparatorAlwaysShownFlag
;
158 UBool padPositionFlag
;
159 UBool positivePrefixFlag
;
160 UBool positiveSuffixFlag
;
161 UBool negativePrefixFlag
;
162 UBool negativeSuffixFlag
;
163 UBool localizedPatternFlag
;
165 UBool toLocalizedPatternFlag
;
170 UBool parseIntegerOnlyFlag
;
171 UBool decimalPatternMatchRequiredFlag
;
172 UBool parseNoExponentFlag
;
173 UBool outputCurrencyFlag
;
175 NumberFormatTestTuple() {
180 * Sets a particular field using the string representation of that field.
181 * @param field the field to set.
182 * @param fieldValue the string representation of the field value.
183 * @param status error returned here such as when the string representation
184 * of the field value cannot be parsed.
185 * @return TRUE on success or FALSE if an error was set in status.
188 ENumberFormatTestTupleField field
,
189 const UnicodeString
&fieldValue
,
192 * Clears a particular field.
193 * @param field the field to clear.
194 * @param status error set here.
195 * @return TRUE on success or FALSE if error was set.
198 ENumberFormatTestTupleField field
,
201 * Clears every field.
206 * Returns the string representation of the test case this object
207 * currently represents.
208 * @param appendTo the result appended here.
211 UnicodeString
&toString(UnicodeString
&appendTo
) const;
214 * Converts the name of a field to the corresponding enum value.
215 * @param name the name of the field as a string.
216 * @return the corresponding enum value or kNumberFormatTestFieldCount
217 * if name does not map to any recognized field name.
219 static ENumberFormatTestTupleField
getFieldByName(const UnicodeString
&name
);
221 const void *getFieldAddress(int32_t fieldId
) const;
222 void *getMutableFieldAddress(int32_t fieldId
);
223 void setFlag(int32_t fieldId
, UBool value
);
224 UBool
isFlag(int32_t fieldId
) const;
227 #endif /* !UCONFIG_NO_FORMATTING */