1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2015, International Business Machines Corporation and *
6 * others. All Rights Reserved. *
7 *******************************************************************************
9 #ifndef _NUMBER_FORMAT_TEST_TUPLE
10 #define _NUMBER_FORMAT_TEST_TUPLE
12 #include "unicode/utypes.h"
14 #if !UCONFIG_NO_FORMATTING
16 #include "unicode/decimfmt.h"
17 #include "unicode/ucurr.h"
19 #define NFTT_GET_FIELD(tuple, fieldName, defaultValue) ((tuple).fieldName##Flag ? (tuple).fieldName : (defaultValue))
23 enum ENumberFormatTestTupleField
{
49 kMinimumExponentDigits
,
50 kExponentSignAlwaysShown
,
51 kDecimalSeparatorAlwaysShown
,
66 kDecimalPatternMatchRequired
,
70 kNumberFormatTestTupleFieldCount
74 * NumberFormatTestTuple represents the data for a single data driven test.
75 * It consist of named fields each of which may or may not be set. Each field
76 * has a particular meaning in the test. For more information on what each
77 * field means and how the data drive tests work, please see
78 * https://docs.google.com/document/d/1T2P0p953_Lh1pRwo-5CuPVrHlIBa_wcXElG-Hhg_WHM/edit?usp=sharing
79 * Each field is optional. That is, a certain field may be unset for a given
80 * test. The UBool fields ending in "Flag" indicate whether the corrresponding
81 * field is set or not. TRUE means set; FALSE means unset. An unset field
82 * generally means that the corresponding setter method is not called on
83 * the NumberFormat object.
86 class NumberFormatTestTuple
{
89 UnicodeString currency
;
90 UnicodeString pattern
;
93 UnicodeString comment
;
94 int32_t minIntegerDigits
;
95 int32_t maxIntegerDigits
;
96 int32_t minFractionDigits
;
97 int32_t maxFractionDigits
;
98 int32_t minGroupingDigits
;
100 int32_t useSigDigits
;
101 int32_t minSigDigits
;
102 int32_t maxSigDigits
;
105 double roundingIncrement
;
107 UnicodeString padCharacter
;
108 int32_t useScientific
;
111 DecimalFormat::ERoundingMode roundingMode
;
112 UCurrencyUsage currencyUsage
;
113 int32_t minimumExponentDigits
;
114 int32_t exponentSignAlwaysShown
;
115 int32_t decimalSeparatorAlwaysShown
;
116 DecimalFormat::EPadPosition padPosition
;
117 UnicodeString positivePrefix
;
118 UnicodeString positiveSuffix
;
119 UnicodeString negativePrefix
;
120 UnicodeString negativeSuffix
;
121 int32_t signAlwaysShown
;
122 UnicodeString localizedPattern
;
123 UnicodeString toPattern
;
124 UnicodeString toLocalizedPattern
;
125 UNumberFormatStyle style
;
128 UnicodeString plural
;
129 int32_t parseIntegerOnly
;
130 int32_t decimalPatternMatchRequired
;
131 int32_t parseNoExponent
;
132 int32_t parseCaseSensitive
;
133 UnicodeString outputCurrency
;
141 UBool minIntegerDigitsFlag
;
142 UBool maxIntegerDigitsFlag
;
143 UBool minFractionDigitsFlag
;
144 UBool maxFractionDigitsFlag
;
145 UBool minGroupingDigitsFlag
;
147 UBool useSigDigitsFlag
;
148 UBool minSigDigitsFlag
;
149 UBool maxSigDigitsFlag
;
150 UBool useGroupingFlag
;
151 UBool multiplierFlag
;
152 UBool roundingIncrementFlag
;
153 UBool formatWidthFlag
;
154 UBool padCharacterFlag
;
155 UBool useScientificFlag
;
158 UBool roundingModeFlag
;
159 UBool currencyUsageFlag
;
160 UBool minimumExponentDigitsFlag
;
161 UBool exponentSignAlwaysShownFlag
;
162 UBool decimalSeparatorAlwaysShownFlag
;
163 UBool padPositionFlag
;
164 UBool positivePrefixFlag
;
165 UBool positiveSuffixFlag
;
166 UBool negativePrefixFlag
;
167 UBool negativeSuffixFlag
;
168 UBool signAlwaysShownFlag
;
169 UBool localizedPatternFlag
;
171 UBool toLocalizedPatternFlag
;
176 UBool parseIntegerOnlyFlag
;
177 UBool decimalPatternMatchRequiredFlag
;
178 UBool parseNoExponentFlag
;
179 UBool parseCaseSensitiveFlag
;
180 UBool outputCurrencyFlag
;
182 NumberFormatTestTuple() {
187 * Sets a particular field using the string representation of that field.
188 * @param field the field to set.
189 * @param fieldValue the string representation of the field value.
190 * @param status error returned here such as when the string representation
191 * of the field value cannot be parsed.
192 * @return TRUE on success or FALSE if an error was set in status.
195 ENumberFormatTestTupleField field
,
196 const UnicodeString
&fieldValue
,
199 * Clears a particular field.
200 * @param field the field to clear.
201 * @param status error set here.
202 * @return TRUE on success or FALSE if error was set.
205 ENumberFormatTestTupleField field
,
208 * Clears every field.
213 * Returns the string representation of the test case this object
214 * currently represents.
215 * @param appendTo the result appended here.
218 UnicodeString
&toString(UnicodeString
&appendTo
) const;
221 * Converts the name of a field to the corresponding enum value.
222 * @param name the name of the field as a string.
223 * @return the corresponding enum value or kNumberFormatTestFieldCount
224 * if name does not map to any recognized field name.
226 static ENumberFormatTestTupleField
getFieldByName(const UnicodeString
&name
);
228 const void *getFieldAddress(int32_t fieldId
) const;
229 void *getMutableFieldAddress(int32_t fieldId
);
230 void setFlag(int32_t fieldId
, UBool value
);
231 UBool
isFlag(int32_t fieldId
) const;
234 #endif /* !UCONFIG_NO_FORMATTING */