ICU-13597 Replying to UNumberFormatter code recatew comments.

X-SVN-Rev: 41321
This commit is contained in:
Shane Carr 2018-05-04 06:58:44 +00:00
parent 23bacf40c8
commit a52fcd20f2
5 changed files with 15 additions and 14 deletions

View File

@ -9,8 +9,8 @@
// Helpful in toString methods and elsewhere.
#define UNISTR_FROM_STRING_EXPLICIT
#include "numparse_types.h"
#include "number_utypes.h"
#include "numparse_types.h"
#include "unicode/numberformatter.h"
#include "unicode/unumberformatter.h"
@ -159,14 +159,14 @@ unumf_resultToString(const UFormattedNumber* uresult, UChar* buffer, int32_t buf
U_CAPI UBool U_EXPORT2
unumf_resultNextFieldPosition(const UFormattedNumber* uresult, UFieldPosition* ufpos, UErrorCode* ec) {
const UFormattedNumberData* result = UFormattedNumberData::validate(uresult, *ec);
if (U_FAILURE(*ec)) { return FALSE; }
if (ufpos == nullptr) {
*ec = U_ILLEGAL_ARGUMENT_ERROR;
return FALSE;
}
const UFormattedNumberData* result = UFormattedNumberData::validate(uresult, *ec);
if (U_FAILURE(*ec)) { return FALSE; }
FieldPosition fp;
fp.setField(ufpos->field);
fp.setBeginIndex(ufpos->beginIndex);
@ -181,14 +181,14 @@ unumf_resultNextFieldPosition(const UFormattedNumber* uresult, UFieldPosition* u
U_CAPI void U_EXPORT2
unumf_resultGetAllFieldPositions(const UFormattedNumber* uresult, UFieldPositionIterator* ufpositer,
UErrorCode* ec) {
const UFormattedNumberData* result = UFormattedNumberData::validate(uresult, *ec);
if (U_FAILURE(*ec)) { return; }
if (ufpositer == nullptr) {
*ec = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
const UFormattedNumberData* result = UFormattedNumberData::validate(uresult, *ec);
if (U_FAILURE(*ec)) { return; }
auto* helper = reinterpret_cast<FieldPositionIterator*>(ufpositer);
result->string.getAllFieldPositions(*helper, *ec);
}
@ -197,7 +197,6 @@ U_CAPI void U_EXPORT2
unumf_closeResult(UFormattedNumber* uresult) {
UErrorCode localStatus = U_ZERO_ERROR;
const UFormattedNumberData* impl = UFormattedNumberData::validate(uresult, localStatus);
if (U_FAILURE(localStatus)) { return; }
delete impl;
}
@ -205,7 +204,6 @@ U_CAPI void U_EXPORT2
unumf_close(UNumberFormatter* f) {
UErrorCode localStatus = U_ZERO_ERROR;
const UNumberFormatterData* impl = UNumberFormatterData::validate(f, localStatus);
if (U_FAILURE(localStatus)) { return; }
delete impl;
}

View File

@ -106,7 +106,7 @@ static const UChar LOW_W = ((UChar) 0x0077);
static const UChar LOW_Y = ((UChar) 0x0079);
static const UChar LOW_Z = ((UChar) 0x007A);
};
}
static const int32_t PLURAL_RANGE_HIGH = 0x7fffffff;

View File

@ -13,11 +13,11 @@
#include "unicode/fieldpos.h"
#include "unicode/fpositer.h"
#include "unicode/measunit.h"
#include "unicode/unumberformatter.h"
#include "unicode/nounit.h"
#include "unicode/plurrule.h"
#include "unicode/ucurr.h"
#include "unicode/unum.h"
#include "unicode/unumberformatter.h"
#include "unicode/uobject.h"
#ifndef U_HIDE_DRAFT_API

View File

@ -76,7 +76,8 @@ static void TestSkeletonFormatToFields() {
// setup:
UNumberFormatter* uformatter = unumf_openFromSkeletonAndLocale(
u".00 measure-unit/length-meter sign-always", -1, "en", &ec);
assertSuccess("Should create without error", &ec);
assertSuccessCheck("Should create without error", &ec, TRUE);
if (U_FAILURE(ec)) { return; }
UFormattedNumber* uresult = unumf_openResult(&ec);
assertSuccess("Should create result without error", &ec);
unumf_formatInt(uformatter, 9876543210L, uresult, &ec); // "+9,876,543,210.00 m"
@ -154,7 +155,8 @@ static void TestExampleCode() {
UErrorCode ec = U_ZERO_ERROR;
UNumberFormatter* uformatter = unumf_openFromSkeletonAndLocale(u"round-integer", -1, "en", &ec);
UFormattedNumber* uresult = unumf_openResult(&ec);
assertSuccess("There should not be a failure in the example code", &ec);
assertSuccessCheck("There should not be a failure in the example code", &ec, TRUE);
if (U_FAILURE(ec)) { return; }
// Format a double:
unumf_formatDouble(uformatter, 5142.3, uresult, &ec);

View File

@ -2374,7 +2374,8 @@ void NumberFormatterApiTest::localPointerCAPI() {
// Setup:
LocalUNumberFormatterPointer uformatter(unumf_openFromSkeletonAndLocale(u"percent", -1, "en", &ec));
LocalUFormattedNumberPointer uresult(unumf_openResult(&ec));
assertSuccess("", ec);
assertSuccess("", ec, TRUE);
if (U_FAILURE(ec)) { return; }
// Format a decimal number:
unumf_formatDecimal(uformatter.getAlias(), "9.87E-3", -1, uresult.getAlias(), &ec);