ICU-13644 Returning bogus string when toSkeleton() fails.

X-SVN-Rev: 41367
This commit is contained in:
Shane Carr 2018-05-09 02:26:14 +00:00
parent 3eb414943e
commit f86a35be55
2 changed files with 13 additions and 3 deletions

View file

@ -320,7 +320,7 @@ Derived NumberFormatterSettings<Derived>::macros(impl::MacroProps&& macros)&& {
template<typename Derived>
UnicodeString NumberFormatterSettings<Derived>::toSkeleton(UErrorCode& status) const {
if (fMacros.copyErrorTo(status)) {
return {};
return ICU_Utility::makeBogusString();
}
return skeleton::generate(fMacros, status);
}

View file

@ -2192,6 +2192,17 @@ void NumberFormatterApiTest::errors() {
U_NUMBER_ARG_OUTOFBOUNDS_ERROR,
status);
// Skeleton string
status = U_ZERO_ERROR;
UnicodeString output = lnf.toSkeleton(status);
assertEquals(
"Should fail on toSkeleton terminal method with correct error code",
U_NUMBER_ARG_OUTOFBOUNDS_ERROR,
status);
assertTrue(
"Terminal toSkeleton on error object should be bogus",
output.isBogus());
// FieldPosition
status = U_ZERO_ERROR;
FieldPosition fp;
@ -2212,8 +2223,7 @@ void NumberFormatterApiTest::errors() {
// Appendable
status = U_ZERO_ERROR;
UnicodeString output;
UnicodeStringAppendable appendable(output);
UnicodeStringAppendable appendable(output.remove());
fn.appendTo(appendable, status);
assertEquals(
"Should fail on Appendable terminal method with correct error code",