UnicodeString&
LocaleDisplayNamesImpl::localeDisplayName(const Locale& locale,
UnicodeString& result) const {
+ if (locale.isBogus()) {
+ result.setToBogus();
+ return result;
+ }
UnicodeString resultName;
const char* lang = locale.getLanguage();
}
UnicodeString temp(result, 0, maxResultSize);
((const LocaleDisplayNames *)ldn)->localeDisplayName(locale, temp);
+ if (temp.isBogus()) {
+ *pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
+ return 0;
+ }
return temp.extract(result, maxResultSize, *pErrorCode);
}
TESTCASE(10, TestUntranslatedKeywords);
TESTCASE(11, TestPrivateUse);
TESTCASE(12, TestUldnDisplayContext);
+ TESTCASE(13, TestUldnWithGarbage);
#endif
default:
name = "";
test_assert_equal("British English", str);
}
+void LocaleDisplayNamesTest::TestUldnWithGarbage() {
+ UErrorCode status = U_ZERO_ERROR;
+ const int32_t kMaxResultSize = 150; // long enough
+ UChar result[150];
+ ULocaleDisplayNames *ldn = uldn_open(Locale::getUS().getName(), ULDN_DIALECT_NAMES, &status);
+ int32_t len = uldn_localeDisplayName(ldn, "english (United States) [w", result, kMaxResultSize, &status);
+ uldn_close(ldn);
+ test_assert(U_FAILURE(status));
+}
+
void LocaleDisplayNamesTest::TestUldnWithKeywordsAndEverything() {
UErrorCode status = U_ZERO_ERROR;
const int32_t kMaxResultSize = 150; // long enough
/********************************************************************
- * COPYRIGHT:
- * Copyright (c) 2010-2014, International Business Machines Corporation
+ * COPYRIGHT:
+ * Copyright (c) 2010-2016, International Business Machines Corporation
* and others. All Rights Reserved.
********************************************************************/
public:
LocaleDisplayNamesTest();
virtual ~LocaleDisplayNamesTest();
-
+
void runIndexedTest(int32_t index, UBool exec, const char* &name, char* par = NULL);
#if !UCONFIG_NO_FORMATTING
void TestUntranslatedKeywords(void);
void TestPrivateUse(void);
void TestUldnDisplayContext(void);
+ void TestUldnWithGarbage(void);
#endif
};