Index: icu4c/source/common/Makefile.in
===================================================================
--- icu4c/source/common/Makefile.in (revision 41377)
+++ icu4c/source/common/Makefile.in (working copy)
@@ -112,7 +112,7 @@
sharedobject.o simpleformatter.o unifiedcache.o uloc_keytype.o \
ubiditransform.o \
pluralmap.o \
-numparse_unisets.o
+static_unicode_sets.o
## Header files to install
HEADERS = $(srcdir)/unicode/*.h
Index: icu4c/source/common/common.vcxproj
===================================================================
--- icu4c/source/common/common.vcxproj (revision 41377)
+++ icu4c/source/common/common.vcxproj (working copy)
@@ -334,7 +334,7 @@
-
+
@@ -440,7 +440,7 @@
-
+
Index: icu4c/source/common/common.vcxproj.filters
===================================================================
--- icu4c/source/common/common.vcxproj.filters (revision 41377)
+++ icu4c/source/common/common.vcxproj.filters (working copy)
@@ -607,7 +607,7 @@
bidi
-
+
formatting
@@ -939,7 +939,7 @@
bidi
-
+
formatting
Index: icu4c/source/common/common_uwp.vcxproj
===================================================================
--- icu4c/source/common/common_uwp.vcxproj (revision 41377)
+++ icu4c/source/common/common_uwp.vcxproj (working copy)
@@ -459,7 +459,7 @@
-
+
@@ -566,7 +566,7 @@
-
+
Index: icu4c/source/common/numparse_unisets.cpp
===================================================================
--- icu4c/source/common/numparse_unisets.cpp (revision 41377)
+++ icu4c/source/common/numparse_unisets.cpp (nonexistent)
@@ -1,201 +0,0 @@
-// © 2018 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html
-
-#include "unicode/utypes.h"
-
-#if !UCONFIG_NO_FORMATTING
-
-// Allow implicit conversion from char16_t* to UnicodeString for this file:
-// Helpful in toString methods and elsewhere.
-#define UNISTR_FROM_STRING_EXPLICIT
-
-#include "numparse_unisets.h"
-#include "umutex.h"
-#include "ucln_cmn.h"
-#include "unicode/uniset.h"
-#include "uresimp.h"
-#include "cstring.h"
-#include "uassert.h"
-
-using namespace icu;
-using namespace icu::numparse;
-using namespace icu::numparse::impl;
-using namespace icu::numparse::impl::unisets;
-
-
-namespace {
-
-static UnicodeSet* gUnicodeSets[COUNT] = {};
-
-UnicodeSet* computeUnion(Key k1, Key k2) {
- UnicodeSet* result = new UnicodeSet();
- if (result == nullptr) {
- return nullptr;
- }
- result->addAll(*gUnicodeSets[k1]);
- result->addAll(*gUnicodeSets[k2]);
- result->freeze();
- return result;
-}
-
-UnicodeSet* computeUnion(Key k1, Key k2, Key k3) {
- UnicodeSet* result = new UnicodeSet();
- if (result == nullptr) {
- return nullptr;
- }
- result->addAll(*gUnicodeSets[k1]);
- result->addAll(*gUnicodeSets[k2]);
- result->addAll(*gUnicodeSets[k3]);
- result->freeze();
- return result;
-}
-
-
-void saveSet(Key key, const UnicodeString& unicodeSetPattern, UErrorCode& status) {
- // assert unicodeSets.get(key) == null;
- gUnicodeSets[key] = new UnicodeSet(unicodeSetPattern, status);
-}
-
-class ParseDataSink : public ResourceSink {
- public:
- void put(const char* key, ResourceValue& value, UBool /*noFallback*/, UErrorCode& status) U_OVERRIDE {
- ResourceTable contextsTable = value.getTable(status);
- if (U_FAILURE(status)) { return; }
- for (int i = 0; contextsTable.getKeyAndValue(i, key, value); i++) {
- if (uprv_strcmp(key, "date") == 0) {
- // ignore
- } else {
- ResourceTable strictnessTable = value.getTable(status);
- if (U_FAILURE(status)) { return; }
- for (int j = 0; strictnessTable.getKeyAndValue(j, key, value); j++) {
- bool isLenient = (uprv_strcmp(key, "lenient") == 0);
- ResourceArray array = value.getArray(status);
- if (U_FAILURE(status)) { return; }
- for (int k = 0; k < array.getSize(); k++) {
- array.getValue(k, value);
- UnicodeString str = value.getUnicodeString(status);
- if (U_FAILURE(status)) { return; }
- // There is both lenient and strict data for comma/period,
- // but not for any of the other symbols.
- if (str.indexOf(u'.') != -1) {
- saveSet(isLenient ? PERIOD : STRICT_PERIOD, str, status);
- } else if (str.indexOf(u',') != -1) {
- saveSet(isLenient ? COMMA : STRICT_COMMA, str, status);
- } else if (str.indexOf(u'+') != -1) {
- saveSet(PLUS_SIGN, str, status);
- } else if (str.indexOf(u'‒') != -1) {
- saveSet(MINUS_SIGN, str, status);
- } else if (str.indexOf(u'$') != -1) {
- saveSet(DOLLAR_SIGN, str, status);
- } else if (str.indexOf(u'£') != -1) {
- saveSet(POUND_SIGN, str, status);
- } else if (str.indexOf(u'₨') != -1) {
- saveSet(RUPEE_SIGN, str, status);
- }
- if (U_FAILURE(status)) { return; }
- }
- }
- }
- }
- }
-};
-
-
-icu::UInitOnce gNumberParseUniSetsInitOnce = U_INITONCE_INITIALIZER;
-
-UBool U_CALLCONV cleanupNumberParseUniSets() {
- for (int32_t i = 0; i < COUNT; i++) {
- delete gUnicodeSets[i];
- gUnicodeSets[i] = nullptr;
- }
- gNumberParseUniSetsInitOnce.reset();
- return TRUE;
-}
-
-void U_CALLCONV initNumberParseUniSets(UErrorCode& status) {
- ucln_common_registerCleanup(UCLN_COMMON_NUMPARSE_UNISETS, cleanupNumberParseUniSets);
-
- gUnicodeSets[EMPTY] = new UnicodeSet();
-
- // These sets were decided after discussion with icu-design@. See tickets #13084 and #13309.
- // Zs+TAB is "horizontal whitespace" according to UTS #18 (blank property).
- gUnicodeSets[DEFAULT_IGNORABLES] = new UnicodeSet(
- u"[[:Zs:][\\u0009][:Bidi_Control:][:Variation_Selector:]]", status);
- gUnicodeSets[STRICT_IGNORABLES] = new UnicodeSet(u"[[:Bidi_Control:]]", status);
-
- LocalUResourceBundlePointer rb(ures_open(nullptr, "root", &status));
- if (U_FAILURE(status)) { return; }
- ParseDataSink sink;
- ures_getAllItemsWithFallback(rb.getAlias(), "parse", sink, status);
- if (U_FAILURE(status)) { return; }
-
- // TODO: Should there be fallback behavior if for some reason these sets didn't get populated?
- U_ASSERT(gUnicodeSets[COMMA] != nullptr);
- U_ASSERT(gUnicodeSets[STRICT_COMMA] != nullptr);
- U_ASSERT(gUnicodeSets[PERIOD] != nullptr);
- U_ASSERT(gUnicodeSets[STRICT_PERIOD] != nullptr);
-
- gUnicodeSets[OTHER_GROUPING_SEPARATORS] = new UnicodeSet(
- u"['٬‘’'\\u0020\\u00A0\\u2000-\\u200A\\u202F\\u205F\\u3000]", status);
- gUnicodeSets[ALL_SEPARATORS] = computeUnion(COMMA, PERIOD, OTHER_GROUPING_SEPARATORS);
- gUnicodeSets[STRICT_ALL_SEPARATORS] = computeUnion(
- STRICT_COMMA, STRICT_PERIOD, OTHER_GROUPING_SEPARATORS);
-
- U_ASSERT(gUnicodeSets[MINUS_SIGN] != nullptr);
- U_ASSERT(gUnicodeSets[PLUS_SIGN] != nullptr);
-
- gUnicodeSets[PERCENT_SIGN] = new UnicodeSet(u"[%٪]", status);
- gUnicodeSets[PERMILLE_SIGN] = new UnicodeSet(u"[‰؉]", status);
- gUnicodeSets[INFINITY_KEY] = new UnicodeSet(u"[∞]", status);
-
- U_ASSERT(gUnicodeSets[DOLLAR_SIGN] != nullptr);
- U_ASSERT(gUnicodeSets[POUND_SIGN] != nullptr);
- U_ASSERT(gUnicodeSets[RUPEE_SIGN] != nullptr);
- gUnicodeSets[YEN_SIGN] = new UnicodeSet(u"[¥\\uffe5]", status);
-
- gUnicodeSets[DIGITS] = new UnicodeSet(u"[:digit:]", status);
-
- gUnicodeSets[DIGITS_OR_ALL_SEPARATORS] = computeUnion(DIGITS, ALL_SEPARATORS);
- gUnicodeSets[DIGITS_OR_STRICT_ALL_SEPARATORS] = computeUnion(DIGITS, STRICT_ALL_SEPARATORS);
-
- for (int32_t i = 0; i < COUNT; i++) {
- gUnicodeSets[i]->freeze();
- }
-}
-
-}
-
-const UnicodeSet* unisets::get(Key key) {
- UErrorCode localStatus = U_ZERO_ERROR;
- umtx_initOnce(gNumberParseUniSetsInitOnce, &initNumberParseUniSets, localStatus);
- if (U_FAILURE(localStatus)) {
- // TODO: This returns non-null in Java, and callers assume that.
- return nullptr;
- }
- return gUnicodeSets[key];
-}
-
-Key unisets::chooseFrom(UnicodeString str, Key key1) {
- return get(key1)->contains(str) ? key1 : COUNT;
-}
-
-Key unisets::chooseFrom(UnicodeString str, Key key1, Key key2) {
- return get(key1)->contains(str) ? key1 : chooseFrom(str, key2);
-}
-
-//Key unisets::chooseCurrency(UnicodeString str) {
-// if (get(DOLLAR_SIGN)->contains(str)) {
-// return DOLLAR_SIGN;
-// } else if (get(POUND_SIGN)->contains(str)) {
-// return POUND_SIGN;
-// } else if (get(RUPEE_SIGN)->contains(str)) {
-// return RUPEE_SIGN;
-// } else if (get(YEN_SIGN)->contains(str)) {
-// return YEN_SIGN;
-// } else {
-// return COUNT;
-// }
-//}
-
-
-#endif /* #if !UCONFIG_NO_FORMATTING */
Property changes on: icu4c/source/common/numparse_unisets.cpp
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Deleted: svn:mime-type
## -1 +0,0 ##
-text/plain;charset=utf-8
\ No newline at end of property
Index: icu4c/source/common/numparse_unisets.h
===================================================================
--- icu4c/source/common/numparse_unisets.h (revision 41377)
+++ icu4c/source/common/numparse_unisets.h (nonexistent)
@@ -1,92 +0,0 @@
-// © 2018 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html
-
-// This file is in common instead of i18n because it is needed by ucurr.cpp.
-
-#include "unicode/utypes.h"
-
-#if !UCONFIG_NO_FORMATTING
-#ifndef __NUMPARSE_UNISETS_H__
-#define __NUMPARSE_UNISETS_H__
-
-#include "unicode/uniset.h"
-#include "unicode/unistr.h"
-
-U_NAMESPACE_BEGIN namespace numparse {
-namespace impl {
-namespace unisets {
-
-enum Key {
- EMPTY,
-
- // Ignorables
- DEFAULT_IGNORABLES,
- STRICT_IGNORABLES,
-
- // Separators
- // Notes:
- // - COMMA is a superset of STRICT_COMMA
- // - PERIOD is a superset of SCRICT_PERIOD
- // - ALL_SEPARATORS is the union of COMMA, PERIOD, and OTHER_GROUPING_SEPARATORS
- // - STRICT_ALL_SEPARATORS is the union of STRICT_COMMA, STRICT_PERIOD, and OTHER_GRP_SEPARATORS
- COMMA,
- PERIOD,
- STRICT_COMMA,
- STRICT_PERIOD,
- OTHER_GROUPING_SEPARATORS,
- ALL_SEPARATORS,
- STRICT_ALL_SEPARATORS,
-
- // Symbols
- MINUS_SIGN,
- PLUS_SIGN,
- PERCENT_SIGN,
- PERMILLE_SIGN,
- INFINITY_KEY, // INFINITY is defined in cmath
-
- // Currency Symbols
- DOLLAR_SIGN,
- POUND_SIGN,
- RUPEE_SIGN,
- YEN_SIGN, // not in CLDR data, but Currency.java wants it
-
- // Other
- DIGITS,
-
- // Combined Separators with Digits (for lead code points)
- DIGITS_OR_ALL_SEPARATORS,
- DIGITS_OR_STRICT_ALL_SEPARATORS,
-
- // The number of elements in the enum. Also used to indicate null.
- COUNT
-};
-
-// Exported as U_COMMON_API for ucurr.cpp
-U_COMMON_API const UnicodeSet* get(Key key);
-
-// Exported as U_COMMON_API for numparse_decimal.cpp
-U_COMMON_API Key chooseFrom(UnicodeString str, Key key1);
-
-// Exported as U_COMMON_API for numparse_decimal.cpp
-U_COMMON_API Key chooseFrom(UnicodeString str, Key key1, Key key2);
-
-// Unused in C++:
-// Key chooseCurrency(UnicodeString str);
-// Used instead:
-static const struct {
- Key key;
- UChar32 exemplar;
-} kCurrencyEntries[] = {
- {DOLLAR_SIGN, u'$'},
- {POUND_SIGN, u'£'},
- {RUPEE_SIGN, u'₨'},
- {YEN_SIGN, u'¥'},
-};
-
-} // namespace unisets
-} // namespace impl
-} // namespace numparse
-U_NAMESPACE_END
-
-#endif //__NUMPARSE_UNISETS_H__
-#endif /* #if !UCONFIG_NO_FORMATTING */
Property changes on: icu4c/source/common/numparse_unisets.h
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Deleted: svn:mime-type
## -1 +0,0 ##
-text/plain;charset=utf-8
\ No newline at end of property
Index: icu4c/source/common/static_unicode_sets.cpp
===================================================================
--- icu4c/source/common/static_unicode_sets.cpp (revision 41377)
+++ icu4c/source/common/static_unicode_sets.cpp (working copy)
@@ -9,7 +9,7 @@
// Helpful in toString methods and elsewhere.
#define UNISTR_FROM_STRING_EXPLICIT
-#include "numparse_unisets.h"
+#include "static_unicode_sets.h"
#include "umutex.h"
#include "ucln_cmn.h"
#include "unicode/uniset.h"
@@ -18,22 +18,35 @@
#include "uassert.h"
using namespace icu;
-using namespace icu::numparse;
-using namespace icu::numparse::impl;
-using namespace icu::numparse::impl::unisets;
+using namespace icu::unisets;
namespace {
-static UnicodeSet* gUnicodeSets[COUNT] = {};
+UnicodeSet* gUnicodeSets[COUNT] = {};
+// Save the empty instance in static memory to have well-defined behavior if a
+// regular UnicodeSet cannot be allocated.
+char gEmptyUnicodeSet[sizeof(UnicodeSet)];
+
+// Whether the gEmptyUnicodeSet is initialized and ready to use.
+UBool gEmptyUnicodeSetInitialized = FALSE;
+
+inline UnicodeSet* getImpl(Key key) {
+ UnicodeSet* candidate = gUnicodeSets[key];
+ if (candidate == nullptr) {
+ return reinterpret_cast(gEmptyUnicodeSet);
+ }
+ return candidate;
+}
+
UnicodeSet* computeUnion(Key k1, Key k2) {
UnicodeSet* result = new UnicodeSet();
if (result == nullptr) {
return nullptr;
}
- result->addAll(*gUnicodeSets[k1]);
- result->addAll(*gUnicodeSets[k2]);
+ result->addAll(*getImpl(k1));
+ result->addAll(*getImpl(k2));
result->freeze();
return result;
}
@@ -43,9 +56,9 @@
if (result == nullptr) {
return nullptr;
}
- result->addAll(*gUnicodeSets[k1]);
- result->addAll(*gUnicodeSets[k2]);
- result->addAll(*gUnicodeSets[k3]);
+ result->addAll(*getImpl(k1));
+ result->addAll(*getImpl(k2));
+ result->addAll(*getImpl(k3));
result->freeze();
return result;
}
@@ -104,6 +117,10 @@
icu::UInitOnce gNumberParseUniSetsInitOnce = U_INITONCE_INITIALIZER;
UBool U_CALLCONV cleanupNumberParseUniSets() {
+ if (gEmptyUnicodeSetInitialized) {
+ reinterpret_cast(gEmptyUnicodeSet)->~UnicodeSet();
+ gEmptyUnicodeSetInitialized = FALSE;
+ }
for (int32_t i = 0; i < COUNT; i++) {
delete gUnicodeSets[i];
gUnicodeSets[i] = nullptr;
@@ -115,7 +132,10 @@
void U_CALLCONV initNumberParseUniSets(UErrorCode& status) {
ucln_common_registerCleanup(UCLN_COMMON_NUMPARSE_UNISETS, cleanupNumberParseUniSets);
- gUnicodeSets[EMPTY] = new UnicodeSet();
+ // Initialize the empty instance for well-defined fallback behavior
+ new(gEmptyUnicodeSet) UnicodeSet();
+ reinterpret_cast(gEmptyUnicodeSet)->freeze();
+ gEmptyUnicodeSetInitialized = TRUE;
// These sets were decided after discussion with icu-design@. See tickets #13084 and #13309.
// Zs+TAB is "horizontal whitespace" according to UTS #18 (blank property).
@@ -129,7 +149,7 @@
ures_getAllItemsWithFallback(rb.getAlias(), "parse", sink, status);
if (U_FAILURE(status)) { return; }
- // TODO: Should there be fallback behavior if for some reason these sets didn't get populated?
+ // NOTE: It is OK for these assertions to fail if there was a no-data build.
U_ASSERT(gUnicodeSets[COMMA] != nullptr);
U_ASSERT(gUnicodeSets[STRICT_COMMA] != nullptr);
U_ASSERT(gUnicodeSets[PERIOD] != nullptr);
@@ -158,8 +178,10 @@
gUnicodeSets[DIGITS_OR_ALL_SEPARATORS] = computeUnion(DIGITS, ALL_SEPARATORS);
gUnicodeSets[DIGITS_OR_STRICT_ALL_SEPARATORS] = computeUnion(DIGITS, STRICT_ALL_SEPARATORS);
- for (int32_t i = 0; i < COUNT; i++) {
- gUnicodeSets[i]->freeze();
+ for (auto* uniset : gUnicodeSets) {
+ if (uniset != nullptr) {
+ uniset->freeze();
+ }
}
}
@@ -169,14 +191,13 @@
UErrorCode localStatus = U_ZERO_ERROR;
umtx_initOnce(gNumberParseUniSetsInitOnce, &initNumberParseUniSets, localStatus);
if (U_FAILURE(localStatus)) {
- // TODO: This returns non-null in Java, and callers assume that.
- return nullptr;
+ return reinterpret_cast(gEmptyUnicodeSet);
}
- return gUnicodeSets[key];
+ return getImpl(key);
}
Key unisets::chooseFrom(UnicodeString str, Key key1) {
- return get(key1)->contains(str) ? key1 : COUNT;
+ return get(key1)->contains(str) ? key1 : NONE;
}
Key unisets::chooseFrom(UnicodeString str, Key key1, Key key2) {
@@ -193,7 +214,7 @@
// } else if (get(YEN_SIGN)->contains(str)) {
// return YEN_SIGN;
// } else {
-// return COUNT;
+// return NONE;
// }
//}
Index: icu4c/source/common/static_unicode_sets.h
===================================================================
--- icu4c/source/common/static_unicode_sets.h (revision 41377)
+++ icu4c/source/common/static_unicode_sets.h (working copy)
@@ -6,18 +6,20 @@
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
-#ifndef __NUMPARSE_UNISETS_H__
-#define __NUMPARSE_UNISETS_H__
+#ifndef __STATIC_UNICODE_SETS_H__
+#define __STATIC_UNICODE_SETS_H__
#include "unicode/uniset.h"
#include "unicode/unistr.h"
-U_NAMESPACE_BEGIN namespace numparse {
-namespace impl {
+U_NAMESPACE_BEGIN
namespace unisets {
enum Key {
- EMPTY,
+ // NONE is used to indicate null in chooseFrom().
+ // EMPTY is used to get an empty UnicodeSet.
+ NONE = -1,
+ EMPTY = 0,
// Ignorables
DEFAULT_IGNORABLES,
@@ -57,17 +59,44 @@
DIGITS_OR_ALL_SEPARATORS,
DIGITS_OR_STRICT_ALL_SEPARATORS,
- // The number of elements in the enum. Also used to indicate null.
+ // The number of elements in the enum.
COUNT
};
-// Exported as U_COMMON_API for ucurr.cpp
+/**
+ * Gets the static-allocated UnicodeSet according to the provided key. The
+ * pointer will be deleted during u_cleanup(); the caller should NOT delete it.
+ *
+ * Exported as U_COMMON_API for ucurr.cpp
+ *
+ * @param key The desired UnicodeSet according to the enum in this file.
+ * @return The requested UnicodeSet. Guaranteed to be frozen and non-null, but
+ * may be empty if an error occurred during data loading.
+ */
U_COMMON_API const UnicodeSet* get(Key key);
-// Exported as U_COMMON_API for numparse_decimal.cpp
+/**
+ * Checks if the UnicodeSet given by key1 contains the given string.
+ *
+ * Exported as U_COMMON_API for numparse_decimal.cpp
+ *
+ * @param str The string to check.
+ * @param key1 The set to check.
+ * @return key1 if the set contains str, or NONE if not.
+ */
U_COMMON_API Key chooseFrom(UnicodeString str, Key key1);
-// Exported as U_COMMON_API for numparse_decimal.cpp
+/**
+ * Checks if the UnicodeSet given by either key1 or key2 contains the string.
+ *
+ * Exported as U_COMMON_API for numparse_decimal.cpp
+ *
+ * @param str The string to check.
+ * @param key1 The first set to check.
+ * @param key2 The second set to check.
+ * @return key1 if that set contains str; key2 if that set contains str; or
+ * NONE if neither set contains str.
+ */
U_COMMON_API Key chooseFrom(UnicodeString str, Key key1, Key key2);
// Unused in C++:
@@ -84,9 +113,7 @@
};
} // namespace unisets
-} // namespace impl
-} // namespace numparse
U_NAMESPACE_END
-#endif //__NUMPARSE_UNISETS_H__
+#endif //__STATIC_UNICODE_SETS_H__
#endif /* #if !UCONFIG_NO_FORMATTING */
Index: icu4c/source/common/ucurr.cpp
===================================================================
--- icu4c/source/common/ucurr.cpp (revision 41377)
+++ icu4c/source/common/ucurr.cpp (working copy)
@@ -23,7 +23,7 @@
#include "charstr.h"
#include "cmemory.h"
#include "cstring.h"
-#include "numparse_unisets.h"
+#include "static_unicode_sets.h"
#include "uassert.h"
#include "umutex.h"
#include "ucln_cmn.h"
@@ -2201,7 +2201,6 @@
}
static void populateCurrSymbolsEquiv(icu::Hashtable *hash, UErrorCode &status) {
- using namespace icu::numparse::impl;
if (U_FAILURE(status)) { return; }
for (auto& entry : unisets::kCurrencyEntries) {
UnicodeString exemplar(entry.exemplar);
Index: icu4c/source/i18n/numparse_decimal.cpp
===================================================================
--- icu4c/source/i18n/numparse_decimal.cpp (revision 41377)
+++ icu4c/source/i18n/numparse_decimal.cpp (working copy)
@@ -11,7 +11,7 @@
#include "numparse_types.h"
#include "numparse_decimal.h"
-#include "numparse_unisets.h"
+#include "static_unicode_sets.h"
#include "numparse_utils.h"
#include "unicode/uchar.h"
#include "putilimp.h"
@@ -41,7 +41,7 @@
decimalSeparator,
strictSeparators ? unisets::STRICT_COMMA : unisets::COMMA,
strictSeparators ? unisets::STRICT_PERIOD : unisets::PERIOD);
- if (decimalKey != unisets::COUNT) {
+ if (decimalKey >= 0) {
decimalUniSet = unisets::get(decimalKey);
} else {
auto* set = new UnicodeSet();
@@ -51,7 +51,7 @@
fLocalDecimalUniSet.adoptInstead(set);
}
- if (groupingKey != unisets::COUNT && decimalKey != unisets::COUNT) {
+ if (groupingKey >= 0 && decimalKey >= 0) {
// Everything is available in the static cache
separatorSet = groupingUniSet;
leadSet = unisets::get(
Index: icu4c/source/i18n/numparse_impl.cpp
===================================================================
--- icu4c/source/i18n/numparse_impl.cpp (revision 41377)
+++ icu4c/source/i18n/numparse_impl.cpp (working copy)
@@ -21,7 +21,7 @@
#include "unicode/numberformatter.h"
#include "cstr.h"
#include "number_mapper.h"
-#include "numparse_unisets.h"
+#include "static_unicode_sets.h"
using namespace icu;
using namespace icu::number;
Index: icu4c/source/i18n/numparse_scientific.cpp
===================================================================
--- icu4c/source/i18n/numparse_scientific.cpp (revision 41377)
+++ icu4c/source/i18n/numparse_scientific.cpp (working copy)
@@ -11,7 +11,7 @@
#include "numparse_types.h"
#include "numparse_scientific.h"
-#include "numparse_unisets.h"
+#include "static_unicode_sets.h"
using namespace icu;
using namespace icu::numparse;
Index: icu4c/source/i18n/numparse_symbols.h
===================================================================
--- icu4c/source/i18n/numparse_symbols.h (revision 41377)
+++ icu4c/source/i18n/numparse_symbols.h (working copy)
@@ -9,7 +9,7 @@
#include "numparse_types.h"
#include "unicode/uniset.h"
-#include "numparse_unisets.h"
+#include "static_unicode_sets.h"
U_NAMESPACE_BEGIN namespace numparse {
namespace impl {
Index: icu4c/source/i18n/numparse_validators.cpp
===================================================================
--- icu4c/source/i18n/numparse_validators.cpp (revision 41377)
+++ icu4c/source/i18n/numparse_validators.cpp (working copy)
@@ -11,7 +11,7 @@
#include "numparse_types.h"
#include "numparse_validators.h"
-#include "numparse_unisets.h"
+#include "static_unicode_sets.h"
using namespace icu;
using namespace icu::numparse;
Index: icu4c/source/i18n/numparse_validators.h
===================================================================
--- icu4c/source/i18n/numparse_validators.h (revision 41377)
+++ icu4c/source/i18n/numparse_validators.h (working copy)
@@ -8,7 +8,7 @@
#define __SOURCE_NUMPARSE_VALIDATORS_H__
#include "numparse_types.h"
-#include "numparse_unisets.h"
+#include "static_unicode_sets.h"
U_NAMESPACE_BEGIN namespace numparse {
namespace impl {
Index: icu4c/source/i18n/scientificnumberformatter.cpp
===================================================================
--- icu4c/source/i18n/scientificnumberformatter.cpp (revision 41377)
+++ icu4c/source/i18n/scientificnumberformatter.cpp (working copy)
@@ -16,7 +16,7 @@
#include "unicode/utf16.h"
#include "unicode/uniset.h"
#include "unicode/decimfmt.h"
-#include "numparse_unisets.h"
+#include "static_unicode_sets.h"
U_NAMESPACE_BEGIN
Index: icu4c/source/test/intltest/Makefile.in
===================================================================
--- icu4c/source/test/intltest/Makefile.in (revision 41377)
+++ icu4c/source/test/intltest/Makefile.in (working copy)
@@ -64,8 +64,9 @@
numberformattesttuple.o pluralmaptest.o \
numbertest_affixutils.o numbertest_api.o numbertest_decimalquantity.o \
numbertest_modifiers.o numbertest_patternmodifier.o numbertest_patternstring.o \
-numbertest_stringbuilder.o numbertest_stringsegment.o numbertest_unisets.o \
-numbertest_parse.o numbertest_doubleconversion.o numbertest_skeletons.o
+numbertest_stringbuilder.o numbertest_stringsegment.o \
+numbertest_parse.o numbertest_doubleconversion.o numbertest_skeletons.o \
+static_unisets_test.o
DEPS = $(OBJECTS:.o=.d)
Index: icu4c/source/test/intltest/intltest.cpp
===================================================================
--- icu4c/source/test/intltest/intltest.cpp (revision 41377)
+++ icu4c/source/test/intltest/intltest.cpp (working copy)
@@ -1901,9 +1901,13 @@
return condition;
}
-UBool IntlTest::assertFalse(const char* message, UBool condition, UBool quiet) {
+UBool IntlTest::assertFalse(const char* message, UBool condition, UBool quiet, UBool possibleDataError) {
if (condition) {
- errln("FAIL: assertFalse() failed: %s", message);
+ if (possibleDataError) {
+ dataerrln("FAIL: assertTrue() failed: %s", message);
+ } else {
+ errln("FAIL: assertTrue() failed: %s", message);
+ }
} else if (!quiet) {
logln("Ok: %s", message);
}
@@ -2111,12 +2115,12 @@
return ASSERT_BUF;
}
-UBool IntlTest::assertTrue(const UnicodeString& message, UBool condition, UBool quiet) {
- return assertTrue(extractToAssertBuf(message), condition, quiet);
+UBool IntlTest::assertTrue(const UnicodeString& message, UBool condition, UBool quiet, UBool possibleDataError) {
+ return assertTrue(extractToAssertBuf(message), condition, quiet, possibleDataError);
}
-UBool IntlTest::assertFalse(const UnicodeString& message, UBool condition, UBool quiet) {
- return assertFalse(extractToAssertBuf(message), condition, quiet);
+UBool IntlTest::assertFalse(const UnicodeString& message, UBool condition, UBool quiet, UBool possibleDataError) {
+ return assertFalse(extractToAssertBuf(message), condition, quiet, possibleDataError);
}
UBool IntlTest::assertSuccess(const UnicodeString& message, UErrorCode ec) {
Index: icu4c/source/test/intltest/intltest.h
===================================================================
--- icu4c/source/test/intltest/intltest.h (revision 41377)
+++ icu4c/source/test/intltest/intltest.h (working copy)
@@ -282,7 +282,7 @@
/* JUnit-like assertions. Each returns TRUE if it succeeds. */
UBool assertTrue(const char* message, UBool condition, UBool quiet=FALSE, UBool possibleDataError=FALSE, const char *file=NULL, int line=0);
- UBool assertFalse(const char* message, UBool condition, UBool quiet=FALSE);
+ UBool assertFalse(const char* message, UBool condition, UBool quiet=FALSE, UBool possibleDataError=FALSE);
/**
* @param possibleDataError - if TRUE, use dataerrln instead of errcheckln on failure
* @return TRUE on success, FALSE on failure.
@@ -303,8 +303,8 @@
UBool assertEquals(const UnicodeString& message, const Formattable& expected,
const Formattable& actual);
#endif
- UBool assertTrue(const UnicodeString& message, UBool condition, UBool quiet=FALSE);
- UBool assertFalse(const UnicodeString& message, UBool condition, UBool quiet=FALSE);
+ UBool assertTrue(const UnicodeString& message, UBool condition, UBool quiet=FALSE, UBool possibleDataError=FALSE);
+ UBool assertFalse(const UnicodeString& message, UBool condition, UBool quiet=FALSE, UBool possibleDataError=FALSE);
UBool assertSuccess(const UnicodeString& message, UErrorCode ec);
UBool assertEquals(const UnicodeString& message, const UnicodeString& expected,
const UnicodeString& actual, UBool possibleDataError=FALSE);
Index: icu4c/source/test/intltest/intltest.vcxproj
===================================================================
--- icu4c/source/test/intltest/intltest.vcxproj (revision 41377)
+++ icu4c/source/test/intltest/intltest.vcxproj (working copy)
@@ -253,7 +253,6 @@
-
@@ -270,8 +269,9 @@
+
+
-
Index: icu4c/source/test/intltest/intltest.vcxproj.filters
===================================================================
--- icu4c/source/test/intltest/intltest.vcxproj.filters (revision 41377)
+++ icu4c/source/test/intltest/intltest.vcxproj.filters (working copy)
@@ -280,9 +280,6 @@
formatting
-
- formatting
-
formatting
@@ -328,6 +325,9 @@
formatting
+
+ formatting
+
formatting
Index: icu4c/source/test/intltest/itutil.cpp
===================================================================
--- icu4c/source/test/intltest/itutil.cpp (revision 41377)
+++ icu4c/source/test/intltest/itutil.cpp (working copy)
@@ -39,7 +39,8 @@
extern IntlTest *createSimpleFormatterTest();
extern IntlTest *createUnifiedCacheTest();
extern IntlTest *createQuantityFormatterTest();
-extern IntlTest *createPluralMapTest();
+extern IntlTest *createPluralMapTest();
+extern IntlTest *createStaticUnicodeSetsTest();
#define CASE(id, test) case id: \
@@ -135,6 +136,14 @@
callTest(*test, par);
}
break;
+ case 24:
+ name = "StaticUnicodeSetsTest";
+ if (exec) {
+ logln("TestSuite StaticUnicodeSetsTest---"); logln();
+ LocalPointer test(createStaticUnicodeSetsTest());
+ callTest(*test, par);
+ }
+ break;
default: name = ""; break; //needed to end loop
}
}
Index: icu4c/source/test/intltest/numbertest.h
===================================================================
--- icu4c/source/test/intltest/numbertest.h (revision 41377)
+++ icu4c/source/test/intltest/numbertest.h (working copy)
@@ -214,19 +214,6 @@
void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par = 0);
};
-class UniSetsTest : public IntlTest {
- public:
- void testSetCoverage();
-
- void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par = 0);
-
- private:
- void assertInSet(const UnicodeString& localeName, const UnicodeString &setName,
- const UnicodeSet& set, const UnicodeString& str);
- void assertInSet(const UnicodeString& localeName, const UnicodeString &setName,
- const UnicodeSet& set, UChar32 cp);
-};
-
class NumberParserTest : public IntlTest {
public:
void testBasic();
@@ -287,9 +274,8 @@
TESTCLASS(6, NumberStringBuilderTest);
TESTCLASS(7, DoubleConversionTest);
TESTCLASS(8, StringSegmentTest);
- TESTCLASS(9, UniSetsTest);
- TESTCLASS(10, NumberParserTest);
- TESTCLASS(11, NumberSkeletonTest);
+ TESTCLASS(9, NumberParserTest);
+ TESTCLASS(10, NumberSkeletonTest);
default: name = ""; break; // needed to end loop
}
}
Index: icu4c/source/test/intltest/numbertest_parse.cpp
===================================================================
--- icu4c/source/test/intltest/numbertest_parse.cpp (revision 41377)
+++ icu4c/source/test/intltest/numbertest_parse.cpp (working copy)
@@ -7,7 +7,7 @@
#include "numbertest.h"
#include "numparse_impl.h"
-#include "numparse_unisets.h"
+#include "static_unicode_sets.h"
#include "unicode/dcfmtsym.h"
#include "unicode/testlog.h"
@@ -14,7 +14,7 @@
#include
#include
-using icu::numparse::impl::unisets::get;
+using icu::unisets::get;
void NumberParserTest::runIndexedTest(int32_t index, UBool exec, const char*& name, char*) {
if (exec) {
Index: icu4c/source/test/intltest/numbertest_unisets.cpp
===================================================================
--- icu4c/source/test/intltest/numbertest_unisets.cpp (revision 41377)
+++ icu4c/source/test/intltest/numbertest_unisets.cpp (nonexistent)
@@ -1,89 +0,0 @@
-// © 2018 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html
-
-#include "unicode/utypes.h"
-
-#if !UCONFIG_NO_FORMATTING
-
-#include "numbertest.h"
-#include "numparse_unisets.h"
-#include "unicode/dcfmtsym.h"
-
-using icu::numparse::impl::unisets::get;
-
-void UniSetsTest::runIndexedTest(int32_t index, UBool exec, const char*&name, char*) {
- if (exec) {
- logln("TestSuite UniSetsTest: ");
- }
- TESTCASE_AUTO_BEGIN;
- TESTCASE_AUTO(testSetCoverage);
- TESTCASE_AUTO_END;
-}
-
-void UniSetsTest::testSetCoverage() {
- UErrorCode status = U_ZERO_ERROR;
-
- // Lenient comma/period should be supersets of strict comma/period;
- // it also makes the coverage logic cheaper.
- assertTrue(
- "COMMA should be superset of STRICT_COMMA",
- get(unisets::COMMA)->containsAll(*get(unisets::STRICT_COMMA)));
- assertTrue(
- "PERIOD should be superset of STRICT_PERIOD",
- get(unisets::PERIOD)->containsAll(*get(unisets::STRICT_PERIOD)));
-
- UnicodeSet decimals;
- decimals.addAll(*get(unisets::STRICT_COMMA));
- decimals.addAll(*get(unisets::STRICT_PERIOD));
- decimals.freeze();
- UnicodeSet grouping;
- grouping.addAll(decimals);
- grouping.addAll(*get(unisets::OTHER_GROUPING_SEPARATORS));
- decimals.freeze();
-
- const UnicodeSet &plusSign = *get(unisets::PLUS_SIGN);
- const UnicodeSet &minusSign = *get(unisets::MINUS_SIGN);
- const UnicodeSet &percent = *get(unisets::PERCENT_SIGN);
- const UnicodeSet &permille = *get(unisets::PERMILLE_SIGN);
- const UnicodeSet &infinity = *get(unisets::INFINITY_KEY);
-
- int32_t localeCount;
- const Locale* allAvailableLocales = Locale::getAvailableLocales(localeCount);
- for (int32_t i = 0; i < localeCount; i++) {
- Locale locale = allAvailableLocales[i];
- DecimalFormatSymbols dfs(locale, status);
- UnicodeString localeName;
- locale.getDisplayName(localeName);
- assertSuccess(UnicodeString("Making DFS for ") + localeName, status);
-
-#define ASSERT_IN_SET(name, foo) assertInSet(localeName, UnicodeString("" #name ""), name, foo)
- ASSERT_IN_SET(decimals, dfs.getConstSymbol(DecimalFormatSymbols::kDecimalSeparatorSymbol));
- ASSERT_IN_SET(grouping, dfs.getConstSymbol(DecimalFormatSymbols::kGroupingSeparatorSymbol));
- ASSERT_IN_SET(plusSign, dfs.getConstSymbol(DecimalFormatSymbols::kPlusSignSymbol));
- ASSERT_IN_SET(minusSign, dfs.getConstSymbol(DecimalFormatSymbols::kMinusSignSymbol));
- ASSERT_IN_SET(percent, dfs.getConstSymbol(DecimalFormatSymbols::kPercentSymbol));
- ASSERT_IN_SET(permille, dfs.getConstSymbol(DecimalFormatSymbols::kPerMillSymbol));
- ASSERT_IN_SET(infinity, dfs.getConstSymbol(DecimalFormatSymbols::kInfinitySymbol));
- }
-}
-
-void UniSetsTest::assertInSet(const UnicodeString &localeName, const UnicodeString &setName,
- const UnicodeSet &set, const UnicodeString &str) {
- if (str.countChar32(0, str.length()) != 1) {
- // Ignore locale strings with more than one code point (usually a bidi mark)
- return;
- }
- assertInSet(localeName, setName, set, str.char32At(0));
-}
-
-void UniSetsTest::assertInSet(const UnicodeString &localeName, const UnicodeString &setName,
- const UnicodeSet &set, UChar32 cp) {
- // If this test case fails, add the specified code point to the corresponding set in
- // UnicodeSetStaticCache.java and numparse_unisets.cpp
- assertTrue(
- localeName + UnicodeString(u" ") + UnicodeString(cp) + UnicodeString(u" is missing in ") +
- setName, set.contains(cp));
-}
-
-
-#endif
Property changes on: icu4c/source/test/intltest/numbertest_unisets.cpp
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Deleted: svn:mime-type
## -1 +0,0 ##
-text/plain;charset=utf-8
\ No newline at end of property
Index: icu4c/source/test/intltest/static_unisets_test.cpp
===================================================================
--- icu4c/source/test/intltest/static_unisets_test.cpp (revision 41377)
+++ icu4c/source/test/intltest/static_unisets_test.cpp (working copy)
@@ -6,21 +6,40 @@
#if !UCONFIG_NO_FORMATTING
#include "numbertest.h"
-#include "numparse_unisets.h"
+#include "static_unicode_sets.h"
#include "unicode/dcfmtsym.h"
-using icu::numparse::impl::unisets::get;
+using icu::unisets::get;
-void UniSetsTest::runIndexedTest(int32_t index, UBool exec, const char*&name, char*) {
+class StaticUnicodeSetsTest : public IntlTest {
+ public:
+ void testSetCoverage();
+ void testNonEmpty();
+
+ void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par = 0);
+
+ private:
+ void assertInSet(const UnicodeString& localeName, const UnicodeString &setName,
+ const UnicodeSet& set, const UnicodeString& str);
+ void assertInSet(const UnicodeString& localeName, const UnicodeString &setName,
+ const UnicodeSet& set, UChar32 cp);
+};
+
+extern IntlTest *createStaticUnicodeSetsTest() {
+ return new StaticUnicodeSetsTest();
+}
+
+void StaticUnicodeSetsTest::runIndexedTest(int32_t index, UBool exec, const char*&name, char*) {
if (exec) {
- logln("TestSuite UniSetsTest: ");
+ logln("TestSuite StaticUnicodeSetsTest: ");
}
TESTCASE_AUTO_BEGIN;
TESTCASE_AUTO(testSetCoverage);
+ TESTCASE_AUTO(testNonEmpty);
TESTCASE_AUTO_END;
}
-void UniSetsTest::testSetCoverage() {
+void StaticUnicodeSetsTest::testSetCoverage() {
UErrorCode status = U_ZERO_ERROR;
// Lenient comma/period should be supersets of strict comma/period;
@@ -67,7 +86,18 @@
}
}
-void UniSetsTest::assertInSet(const UnicodeString &localeName, const UnicodeString &setName,
+void StaticUnicodeSetsTest::testNonEmpty() {
+ for (int32_t i=0; i(i));
+ // Can fail if no data:
+ assertFalse(UnicodeString("Set should not be empty: ") + i, uset->isEmpty(), FALSE, TRUE);
+ }
+}
+
+void StaticUnicodeSetsTest::assertInSet(const UnicodeString &localeName, const UnicodeString &setName,
const UnicodeSet &set, const UnicodeString &str) {
if (str.countChar32(0, str.length()) != 1) {
// Ignore locale strings with more than one code point (usually a bidi mark)
@@ -76,7 +106,7 @@
assertInSet(localeName, setName, set, str.char32At(0));
}
-void UniSetsTest::assertInSet(const UnicodeString &localeName, const UnicodeString &setName,
+void StaticUnicodeSetsTest::assertInSet(const UnicodeString &localeName, const UnicodeString &setName,
const UnicodeSet &set, UChar32 cp) {
// If this test case fails, add the specified code point to the corresponding set in
// UnicodeSetStaticCache.java and numparse_unisets.cpp
Index: icu4j/main/classes/core/src/com/ibm/icu/impl/StaticUnicodeSets.java
===================================================================
--- icu4j/main/classes/core/src/com/ibm/icu/impl/StaticUnicodeSets.java (revision 41377)
+++ icu4j/main/classes/core/src/com/ibm/icu/impl/StaticUnicodeSets.java (working copy)
@@ -1,13 +1,10 @@
// © 2017 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html#License
-package com.ibm.icu.impl.number.parse;
+package com.ibm.icu.impl;
import java.util.EnumMap;
import java.util.Map;
-import com.ibm.icu.impl.ICUData;
-import com.ibm.icu.impl.ICUResourceBundle;
-import com.ibm.icu.impl.UResource;
import com.ibm.icu.impl.UResource.Value;
import com.ibm.icu.text.UnicodeSet;
import com.ibm.icu.util.ULocale;
@@ -14,16 +11,16 @@
import com.ibm.icu.util.UResourceBundle;
/**
- * This class statically initializes UnicodeSets useful for number parsing. Microbenchmarks show this to
- * bring a very sizeable performance boost.
+ * This class statically initializes UnicodeSets, originally built for number parsing. Microbenchmarks
+ * show this to bring a very sizeable performance boost.
*
- * IMPORTANT ASSUMPTION: All of the sets contain code points (no strings) and they are all case-folded.
- * If this assumption were ever broken, logic in classes such as SymbolMatcher would need to be updated
- * in order to return well-formed sets upon calls to getLeadCodePoints().
+ * IMPORTANT ASSUMPTION FOR NUMBER PARSING: All of the sets contain code points (no strings) and they are
+ * all case-folded. If this assumption were ever broken, logic in classes such as SymbolMatcher would
+ * need to be updated in order to return well-formed sets upon calls to getLeadCodePoints().
*
* @author sffc
*/
-public class UnicodeSetStaticCache {
+public class StaticUnicodeSets {
public static enum Key {
// Ignorables
DEFAULT_IGNORABLES,
@@ -67,18 +64,57 @@
private static final Map unicodeSets = new EnumMap(Key.class);
+ /**
+ * Gets the static-allocated UnicodeSet according to the provided key.
+ *
+ * @param key
+ * The desired UnicodeSet according to the enum in this file.
+ * @return The requested UnicodeSet. Guaranteed to be frozen and non-null, but may be empty if an
+ * error occurred during data loading.
+ */
public static UnicodeSet get(Key key) {
- return unicodeSets.get(key);
+ UnicodeSet candidate = unicodeSets.get(key);
+ if (candidate == null) {
+ return UnicodeSet.EMPTY;
+ }
+ return candidate;
}
+ /**
+ * Checks if the UnicodeSet given by key1 contains the given string.
+ *
+ * @param str
+ * The string to check.
+ * @param key1
+ * The set to check.
+ * @return key1 if the set contains str, or COUNT if not.
+ */
public static Key chooseFrom(String str, Key key1) {
return get(key1).contains(str) ? key1 : null;
}
+ /**
+ * Checks if the UnicodeSet given by either key1 or key2 contains the string.
+ *
+ * Exported as U_COMMON_API for numparse_decimal.cpp
+ *
+ * @param str
+ * The string to check.
+ * @param key1
+ * The first set to check.
+ * @param key2
+ * The second set to check.
+ * @return key1 if that set contains str; key2 if that set contains str; or COUNT if neither set
+ * contains str.
+ */
public static Key chooseFrom(String str, Key key1, Key key2) {
return get(key1).contains(str) ? key1 : chooseFrom(str, key2);
}
+ /**
+ * Looks through all Currency-related sets for the given string, returning the first match or null if
+ * no match was round.
+ */
public static Key chooseCurrency(String str) {
if (get(Key.DOLLAR_SIGN).contains(str)) {
return Key.DOLLAR_SIGN;
@@ -187,7 +223,7 @@
.getBundleInstance(ICUData.ICU_BASE_NAME, ULocale.ROOT);
rb.getAllItemsWithFallback("parse", new ParseDataSink());
- // TODO: Should there be fallback behavior if for some reason these sets didn't get populated?
+ // NOTE: It is OK for these assertions to fail if there was a no-data build.
assert unicodeSets.containsKey(Key.COMMA);
assert unicodeSets.containsKey(Key.STRICT_COMMA);
assert unicodeSets.containsKey(Key.PERIOD);
Index: icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/DecimalMatcher.java
===================================================================
--- icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/DecimalMatcher.java (revision 41377)
+++ icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/DecimalMatcher.java (working copy)
@@ -3,9 +3,10 @@
package com.ibm.icu.impl.number.parse;
import com.ibm.icu.impl.StringSegment;
+import com.ibm.icu.impl.StaticUnicodeSets;
+import com.ibm.icu.impl.StaticUnicodeSets.Key;
import com.ibm.icu.impl.number.DecimalQuantity_DualStorageBCD;
import com.ibm.icu.impl.number.Grouper;
-import com.ibm.icu.impl.number.parse.UnicodeSetStaticCache.Key;
import com.ibm.icu.lang.UCharacter;
import com.ibm.icu.text.DecimalFormatSymbols;
import com.ibm.icu.text.UnicodeSet;
@@ -63,12 +64,12 @@
// Attempt to find separators in the static cache
- groupingUniSet = UnicodeSetStaticCache.get(groupingKey);
- Key decimalKey = UnicodeSetStaticCache.chooseFrom(decimalSeparator,
+ groupingUniSet = StaticUnicodeSets.get(groupingKey);
+ Key decimalKey = StaticUnicodeSets.chooseFrom(decimalSeparator,
strictSeparators ? Key.STRICT_COMMA : Key.COMMA,
strictSeparators ? Key.STRICT_PERIOD : Key.PERIOD);
if (decimalKey != null) {
- decimalUniSet = UnicodeSetStaticCache.get(decimalKey);
+ decimalUniSet = StaticUnicodeSets.get(decimalKey);
} else {
decimalUniSet = new UnicodeSet().add(decimalSeparator.codePointAt(0)).freeze();
}
@@ -76,7 +77,7 @@
if (groupingKey != null && decimalKey != null) {
// Everything is available in the static cache
separatorSet = groupingUniSet;
- leadSet = UnicodeSetStaticCache.get(strictSeparators ? Key.DIGITS_OR_ALL_SEPARATORS
+ leadSet = StaticUnicodeSets.get(strictSeparators ? Key.DIGITS_OR_ALL_SEPARATORS
: Key.DIGITS_OR_STRICT_ALL_SEPARATORS);
} else {
separatorSet = new UnicodeSet().addAll(groupingUniSet).addAll(decimalUniSet).freeze();
Index: icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/IgnorablesMatcher.java
===================================================================
--- icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/IgnorablesMatcher.java (revision 41377)
+++ icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/IgnorablesMatcher.java (working copy)
@@ -3,6 +3,7 @@
package com.ibm.icu.impl.number.parse;
import com.ibm.icu.impl.StringSegment;
+import com.ibm.icu.impl.StaticUnicodeSets;
import com.ibm.icu.text.UnicodeSet;
/**
@@ -12,10 +13,10 @@
public class IgnorablesMatcher extends SymbolMatcher implements NumberParseMatcher.Flexible {
public static final IgnorablesMatcher DEFAULT = new IgnorablesMatcher(
- UnicodeSetStaticCache.get(UnicodeSetStaticCache.Key.DEFAULT_IGNORABLES));
+ StaticUnicodeSets.get(StaticUnicodeSets.Key.DEFAULT_IGNORABLES));
public static final IgnorablesMatcher STRICT = new IgnorablesMatcher(
- UnicodeSetStaticCache.get(UnicodeSetStaticCache.Key.STRICT_IGNORABLES));
+ StaticUnicodeSets.get(StaticUnicodeSets.Key.STRICT_IGNORABLES));
public static IgnorablesMatcher getInstance(UnicodeSet ignorables) {
assert ignorables.isFrozen();
Index: icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/InfinityMatcher.java
===================================================================
--- icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/InfinityMatcher.java (revision 41377)
+++ icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/InfinityMatcher.java (working copy)
@@ -3,6 +3,7 @@
package com.ibm.icu.impl.number.parse;
import com.ibm.icu.impl.StringSegment;
+import com.ibm.icu.impl.StaticUnicodeSets;
import com.ibm.icu.text.DecimalFormatSymbols;
/**
@@ -27,7 +28,7 @@
}
private InfinityMatcher() {
- super(UnicodeSetStaticCache.Key.INFINITY);
+ super(StaticUnicodeSets.Key.INFINITY);
}
@Override
Index: icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/MinusSignMatcher.java
===================================================================
--- icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/MinusSignMatcher.java (revision 41377)
+++ icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/MinusSignMatcher.java (working copy)
@@ -3,6 +3,7 @@
package com.ibm.icu.impl.number.parse;
import com.ibm.icu.impl.StringSegment;
+import com.ibm.icu.impl.StaticUnicodeSets;
import com.ibm.icu.text.DecimalFormatSymbols;
/**
@@ -31,7 +32,7 @@
}
private MinusSignMatcher(boolean allowTrailing) {
- super(UnicodeSetStaticCache.Key.MINUS_SIGN);
+ super(StaticUnicodeSets.Key.MINUS_SIGN);
this.allowTrailing = allowTrailing;
}
Index: icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/PercentMatcher.java
===================================================================
--- icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/PercentMatcher.java (revision 41377)
+++ icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/PercentMatcher.java (working copy)
@@ -3,6 +3,7 @@
package com.ibm.icu.impl.number.parse;
import com.ibm.icu.impl.StringSegment;
+import com.ibm.icu.impl.StaticUnicodeSets;
import com.ibm.icu.text.DecimalFormatSymbols;
/**
@@ -27,7 +28,7 @@
}
private PercentMatcher() {
- super(UnicodeSetStaticCache.Key.PERCENT_SIGN);
+ super(StaticUnicodeSets.Key.PERCENT_SIGN);
}
@Override
Index: icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/PermilleMatcher.java
===================================================================
--- icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/PermilleMatcher.java (revision 41377)
+++ icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/PermilleMatcher.java (working copy)
@@ -3,6 +3,7 @@
package com.ibm.icu.impl.number.parse;
import com.ibm.icu.impl.StringSegment;
+import com.ibm.icu.impl.StaticUnicodeSets;
import com.ibm.icu.text.DecimalFormatSymbols;
/**
@@ -27,7 +28,7 @@
}
private PermilleMatcher() {
- super(UnicodeSetStaticCache.Key.PERMILLE_SIGN);
+ super(StaticUnicodeSets.Key.PERMILLE_SIGN);
}
@Override
Index: icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/PlusSignMatcher.java
===================================================================
--- icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/PlusSignMatcher.java (revision 41377)
+++ icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/PlusSignMatcher.java (working copy)
@@ -3,6 +3,7 @@
package com.ibm.icu.impl.number.parse;
import com.ibm.icu.impl.StringSegment;
+import com.ibm.icu.impl.StaticUnicodeSets;
import com.ibm.icu.text.DecimalFormatSymbols;
/**
@@ -31,7 +32,7 @@
}
private PlusSignMatcher(boolean allowTrailing) {
- super(UnicodeSetStaticCache.Key.PLUS_SIGN);
+ super(StaticUnicodeSets.Key.PLUS_SIGN);
this.allowTrailing = allowTrailing;
}
Index: icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/ScientificMatcher.java
===================================================================
--- icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/ScientificMatcher.java (revision 41377)
+++ icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/ScientificMatcher.java (working copy)
@@ -3,6 +3,7 @@
package com.ibm.icu.impl.number.parse;
import com.ibm.icu.impl.StringSegment;
+import com.ibm.icu.impl.StaticUnicodeSets;
import com.ibm.icu.impl.number.DecimalQuantity_DualStorageBCD;
import com.ibm.icu.impl.number.Grouper;
import com.ibm.icu.text.DecimalFormatSymbols;
@@ -37,11 +38,11 @@
}
private static UnicodeSet minusSignSet() {
- return UnicodeSetStaticCache.get(UnicodeSetStaticCache.Key.MINUS_SIGN);
+ return StaticUnicodeSets.get(StaticUnicodeSets.Key.MINUS_SIGN);
}
private static UnicodeSet plusSignSet() {
- return UnicodeSetStaticCache.get(UnicodeSetStaticCache.Key.PLUS_SIGN);
+ return StaticUnicodeSets.get(StaticUnicodeSets.Key.PLUS_SIGN);
}
@Override
Index: icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/SymbolMatcher.java
===================================================================
--- icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/SymbolMatcher.java (revision 41377)
+++ icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/SymbolMatcher.java (working copy)
@@ -3,6 +3,7 @@
package com.ibm.icu.impl.number.parse;
import com.ibm.icu.impl.StringSegment;
+import com.ibm.icu.impl.StaticUnicodeSets;
import com.ibm.icu.text.UnicodeSet;
/**
@@ -22,9 +23,9 @@
uniSet = symbolUniSet;
}
- protected SymbolMatcher(UnicodeSetStaticCache.Key key) {
+ protected SymbolMatcher(StaticUnicodeSets.Key key) {
string = "";
- uniSet = UnicodeSetStaticCache.get(key);
+ uniSet = StaticUnicodeSets.get(key);
}
public UnicodeSet getSet() {
Index: icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/UnicodeSetStaticCache.java
===================================================================
--- icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/UnicodeSetStaticCache.java (revision 41377)
+++ icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/UnicodeSetStaticCache.java (nonexistent)
@@ -1,221 +0,0 @@
-// © 2017 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
-package com.ibm.icu.impl.number.parse;
-
-import java.util.EnumMap;
-import java.util.Map;
-
-import com.ibm.icu.impl.ICUData;
-import com.ibm.icu.impl.ICUResourceBundle;
-import com.ibm.icu.impl.UResource;
-import com.ibm.icu.impl.UResource.Value;
-import com.ibm.icu.text.UnicodeSet;
-import com.ibm.icu.util.ULocale;
-import com.ibm.icu.util.UResourceBundle;
-
-/**
- * This class statically initializes UnicodeSets useful for number parsing. Microbenchmarks show this to
- * bring a very sizeable performance boost.
- *
- * IMPORTANT ASSUMPTION: All of the sets contain code points (no strings) and they are all case-folded.
- * If this assumption were ever broken, logic in classes such as SymbolMatcher would need to be updated
- * in order to return well-formed sets upon calls to getLeadCodePoints().
- *
- * @author sffc
- */
-public class UnicodeSetStaticCache {
- public static enum Key {
- // Ignorables
- DEFAULT_IGNORABLES,
- STRICT_IGNORABLES,
-
- // Separators
- // Notes:
- // - COMMA is a superset of STRICT_COMMA
- // - PERIOD is a superset of SCRICT_PERIOD
- // - ALL_SEPARATORS is the union of COMMA, PERIOD, and OTHER_GROUPING_SEPARATORS
- // - STRICT_ALL_SEPARATORS is the union of STRICT_COMMA, STRICT_PERIOD, and OTHER_GRP_SEPARATORS
- COMMA,
- PERIOD,
- STRICT_COMMA,
- STRICT_PERIOD,
- OTHER_GROUPING_SEPARATORS,
- ALL_SEPARATORS,
- STRICT_ALL_SEPARATORS,
-
- // Symbols
- // TODO: NaN?
- MINUS_SIGN,
- PLUS_SIGN,
- PERCENT_SIGN,
- PERMILLE_SIGN,
- INFINITY,
-
- // Currency Symbols
- DOLLAR_SIGN,
- POUND_SIGN,
- RUPEE_SIGN,
- YEN_SIGN, // not in CLDR data, but Currency.java wants it
-
- // Other
- DIGITS,
-
- // Combined Separators with Digits (for lead code points)
- DIGITS_OR_ALL_SEPARATORS,
- DIGITS_OR_STRICT_ALL_SEPARATORS,
- };
-
- private static final Map unicodeSets = new EnumMap(Key.class);
-
- public static UnicodeSet get(Key key) {
- return unicodeSets.get(key);
- }
-
- public static Key chooseFrom(String str, Key key1) {
- return get(key1).contains(str) ? key1 : null;
- }
-
- public static Key chooseFrom(String str, Key key1, Key key2) {
- return get(key1).contains(str) ? key1 : chooseFrom(str, key2);
- }
-
- public static Key chooseCurrency(String str) {
- if (get(Key.DOLLAR_SIGN).contains(str)) {
- return Key.DOLLAR_SIGN;
- } else if (get(Key.POUND_SIGN).contains(str)) {
- return Key.POUND_SIGN;
- } else if (get(Key.RUPEE_SIGN).contains(str)) {
- return Key.RUPEE_SIGN;
- } else if (get(Key.YEN_SIGN).contains(str)) {
- return Key.YEN_SIGN;
- } else {
- return null;
- }
- }
-
- private static UnicodeSet computeUnion(Key k1, Key k2) {
- return new UnicodeSet().addAll(get(k1)).addAll(get(k2)).freeze();
- }
-
- private static UnicodeSet computeUnion(Key k1, Key k2, Key k3) {
- return new UnicodeSet().addAll(get(k1)).addAll(get(k2)).addAll(get(k3)).freeze();
- }
-
- private static void saveSet(Key key, String unicodeSetPattern) {
- assert unicodeSets.get(key) == null;
- unicodeSets.put(key, new UnicodeSet(unicodeSetPattern).freeze());
- }
-
- /*
- parse{
- date{
- lenient{
- "[\\--/]",
- "[\\:∶]",
- }
- }
- general{
- lenient{
- "[.․。︒﹒.。]",
- "[\$﹩$$]",
- "[£₤]",
- "[₨₹{Rp}{Rs}]",
- }
- }
- number{
- lenient{
- "[\\-‒⁻₋−➖﹣-]",
- "[,،٫、︐︑﹐﹑,、]",
- "[+⁺₊➕﬩﹢+]",
- }
- stricter{
- "[,٫︐﹐,]",
- "[.․﹒.。]",
- }
- }
- }
- */
- static class ParseDataSink extends UResource.Sink {
- @Override
- public void put(com.ibm.icu.impl.UResource.Key key, Value value, boolean noFallback) {
- UResource.Table contextsTable = value.getTable();
- for (int i = 0; contextsTable.getKeyAndValue(i, key, value); i++) {
- if (key.contentEquals("date")) {
- // ignore
- } else {
- assert key.contentEquals("general") || key.contentEquals("number");
- UResource.Table strictnessTable = value.getTable();
- for (int j = 0; strictnessTable.getKeyAndValue(j, key, value); j++) {
- boolean isLenient = key.contentEquals("lenient");
- UResource.Array array = value.getArray();
- for (int k = 0; k < array.getSize(); k++) {
- array.getValue(k, value);
- String str = value.toString();
- // There is both lenient and strict data for comma/period,
- // but not for any of the other symbols.
- if (str.indexOf('.') != -1) {
- saveSet(isLenient ? Key.PERIOD : Key.STRICT_PERIOD, str);
- } else if (str.indexOf(',') != -1) {
- saveSet(isLenient ? Key.COMMA : Key.STRICT_COMMA, str);
- } else if (str.indexOf('+') != -1) {
- saveSet(Key.PLUS_SIGN, str);
- } else if (str.indexOf('‒') != -1) {
- saveSet(Key.MINUS_SIGN, str);
- } else if (str.indexOf('$') != -1) {
- saveSet(Key.DOLLAR_SIGN, str);
- } else if (str.indexOf('£') != -1) {
- saveSet(Key.POUND_SIGN, str);
- } else if (str.indexOf('₨') != -1) {
- saveSet(Key.RUPEE_SIGN, str);
- }
- }
- }
- }
- }
- }
- }
-
- static {
- // These sets were decided after discussion with icu-design@. See tickets #13084 and #13309.
- // Zs+TAB is "horizontal whitespace" according to UTS #18 (blank property).
- unicodeSets.put(Key.DEFAULT_IGNORABLES,
- new UnicodeSet("[[:Zs:][\\u0009][:Bidi_Control:][:Variation_Selector:]]").freeze());
- unicodeSets.put(Key.STRICT_IGNORABLES, new UnicodeSet("[[:Bidi_Control:]]").freeze());
-
- // CLDR provides data for comma, period, minus sign, and plus sign.
- ICUResourceBundle rb = (ICUResourceBundle) UResourceBundle
- .getBundleInstance(ICUData.ICU_BASE_NAME, ULocale.ROOT);
- rb.getAllItemsWithFallback("parse", new ParseDataSink());
-
- // TODO: Should there be fallback behavior if for some reason these sets didn't get populated?
- assert unicodeSets.containsKey(Key.COMMA);
- assert unicodeSets.containsKey(Key.STRICT_COMMA);
- assert unicodeSets.containsKey(Key.PERIOD);
- assert unicodeSets.containsKey(Key.STRICT_PERIOD);
-
- unicodeSets.put(Key.OTHER_GROUPING_SEPARATORS,
- new UnicodeSet("['٬‘’'\\u0020\\u00A0\\u2000-\\u200A\\u202F\\u205F\\u3000]").freeze());
- unicodeSets.put(Key.ALL_SEPARATORS,
- computeUnion(Key.COMMA, Key.PERIOD, Key.OTHER_GROUPING_SEPARATORS));
- unicodeSets.put(Key.STRICT_ALL_SEPARATORS,
- computeUnion(Key.STRICT_COMMA, Key.STRICT_PERIOD, Key.OTHER_GROUPING_SEPARATORS));
-
- assert unicodeSets.containsKey(Key.MINUS_SIGN);
- assert unicodeSets.containsKey(Key.PLUS_SIGN);
-
- unicodeSets.put(Key.PERCENT_SIGN, new UnicodeSet("[%٪]").freeze());
- unicodeSets.put(Key.PERMILLE_SIGN, new UnicodeSet("[‰؉]").freeze());
- unicodeSets.put(Key.INFINITY, new UnicodeSet("[∞]").freeze());
-
- assert unicodeSets.containsKey(Key.DOLLAR_SIGN);
- assert unicodeSets.containsKey(Key.POUND_SIGN);
- assert unicodeSets.containsKey(Key.RUPEE_SIGN);
- unicodeSets.put(Key.YEN_SIGN, new UnicodeSet("[¥\\uffe5]").freeze());
-
- unicodeSets.put(Key.DIGITS, new UnicodeSet("[:digit:]").freeze());
-
- unicodeSets.put(Key.DIGITS_OR_ALL_SEPARATORS, computeUnion(Key.DIGITS, Key.ALL_SEPARATORS));
- unicodeSets.put(Key.DIGITS_OR_STRICT_ALL_SEPARATORS,
- computeUnion(Key.DIGITS, Key.STRICT_ALL_SEPARATORS));
- }
-}
Property changes on: icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/UnicodeSetStaticCache.java
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Deleted: svn:mime-type
## -1 +0,0 ##
-text/plain;charset=utf-8
\ No newline at end of property
Index: icu4j/main/classes/core/src/com/ibm/icu/text/ScientificNumberFormatter.java
===================================================================
--- icu4j/main/classes/core/src/com/ibm/icu/text/ScientificNumberFormatter.java (revision 41377)
+++ icu4j/main/classes/core/src/com/ibm/icu/text/ScientificNumberFormatter.java (working copy)
@@ -13,7 +13,7 @@
import java.text.CharacterIterator;
import java.util.Map;
-import com.ibm.icu.impl.number.parse.UnicodeSetStaticCache;
+import com.ibm.icu.impl.StaticUnicodeSets;
import com.ibm.icu.lang.UCharacter;
import com.ibm.icu.util.ULocale;
@@ -230,7 +230,7 @@
int start = iterator.getRunStart(NumberFormat.Field.EXPONENT_SIGN);
int limit = iterator.getRunLimit(NumberFormat.Field.EXPONENT_SIGN);
int aChar = char32AtAndAdvance(iterator);
- if (UnicodeSetStaticCache.get(UnicodeSetStaticCache.Key.MINUS_SIGN).contains(aChar)) {
+ if (StaticUnicodeSets.get(StaticUnicodeSets.Key.MINUS_SIGN).contains(aChar)) {
append(
iterator,
copyFromOffset,
@@ -237,7 +237,7 @@
start,
result);
result.append(SUPERSCRIPT_MINUS_SIGN);
- } else if (UnicodeSetStaticCache.get(UnicodeSetStaticCache.Key.PLUS_SIGN).contains(aChar)) {
+ } else if (StaticUnicodeSets.get(StaticUnicodeSets.Key.PLUS_SIGN).contains(aChar)) {
append(
iterator,
copyFromOffset,
Index: icu4j/main/classes/core/src/com/ibm/icu/util/Currency.java
===================================================================
--- icu4j/main/classes/core/src/com/ibm/icu/util/Currency.java (revision 41377)
+++ icu4j/main/classes/core/src/com/ibm/icu/util/Currency.java (working copy)
@@ -30,7 +30,7 @@
import com.ibm.icu.impl.SimpleCache;
import com.ibm.icu.impl.SoftCache;
import com.ibm.icu.impl.TextTrieMap;
-import com.ibm.icu.impl.number.parse.UnicodeSetStaticCache;
+import com.ibm.icu.impl.StaticUnicodeSets;
import com.ibm.icu.text.CurrencyDisplayNames;
import com.ibm.icu.text.CurrencyMetaInfo;
import com.ibm.icu.text.CurrencyMetaInfo.CurrencyDigits;
@@ -772,10 +772,10 @@
String isoCode = e.getValue();
// Register under not just symbol, but under every equivalent symbol as well
// e.g short width yen and long width yen.
- UnicodeSetStaticCache.Key key = UnicodeSetStaticCache.chooseCurrency(symbol);
+ StaticUnicodeSets.Key key = StaticUnicodeSets.chooseCurrency(symbol);
CurrencyStringInfo value = new CurrencyStringInfo(isoCode, symbol);
if (key != null) {
- UnicodeSet equivalents = UnicodeSetStaticCache.get(key);
+ UnicodeSet equivalents = StaticUnicodeSets.get(key);
// The symbol itself is included in the UnicodeSet
for (String equivalentSymbol : equivalents) {
symTrie.put(equivalentSymbol, value);
Index: icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/ExhaustiveNumberTest.java
===================================================================
--- icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/ExhaustiveNumberTest.java (revision 41377)
+++ icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/ExhaustiveNumberTest.java (working copy)
@@ -2,7 +2,7 @@
// License & terms of use: http://www.unicode.org/copyright.html#License
package com.ibm.icu.dev.test.number;
-import static com.ibm.icu.impl.number.parse.UnicodeSetStaticCache.get;
+import static com.ibm.icu.impl.StaticUnicodeSets.get;
import java.math.BigDecimal;
import java.util.Random;
@@ -11,8 +11,8 @@
import org.junit.Test;
import com.ibm.icu.dev.test.TestFmwk;
+import com.ibm.icu.impl.StaticUnicodeSets.Key;
import com.ibm.icu.impl.number.DecimalQuantity_DualStorageBCD;
-import com.ibm.icu.impl.number.parse.UnicodeSetStaticCache.Key;
import com.ibm.icu.lang.UCharacter;
import com.ibm.icu.number.NumberFormatter;
import com.ibm.icu.number.Precision;
Index: icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/UnicodeSetStaticCacheTest.java
===================================================================
--- icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/UnicodeSetStaticCacheTest.java (revision 41377)
+++ icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/UnicodeSetStaticCacheTest.java (nonexistent)
@@ -1,24 +0,0 @@
-// © 2018 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
-package com.ibm.icu.dev.test.number;
-
-import static com.ibm.icu.impl.number.parse.UnicodeSetStaticCache.get;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-import com.ibm.icu.impl.number.parse.UnicodeSetStaticCache.Key;
-
-/**
- * This test class is thin; most of it was moved to ExhaustiveNumberTest.
- * @author sffc
- */
-public class UnicodeSetStaticCacheTest {
-
- @Test
- public void testFrozen() {
- for (Key key : Key.values()) {
- assertTrue(get(key).isFrozen());
- }
- }
-}
Property changes on: icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/UnicodeSetStaticCacheTest.java
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Deleted: svn:mime-type
## -1 +0,0 ##
-text/plain;charset=utf-8
\ No newline at end of property
Index: icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/StaticUnicodeSetsTest.java
===================================================================
--- icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/StaticUnicodeSetsTest.java (revision 41377)
+++ icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/StaticUnicodeSetsTest.java (working copy)
@@ -1,19 +1,20 @@
// © 2018 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html#License
-package com.ibm.icu.dev.test.number;
+package com.ibm.icu.dev.test.util;
-import static com.ibm.icu.impl.number.parse.UnicodeSetStaticCache.get;
+import static com.ibm.icu.impl.StaticUnicodeSets.get;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import com.ibm.icu.impl.number.parse.UnicodeSetStaticCache.Key;
+import com.ibm.icu.impl.StaticUnicodeSets.Key;
/**
- * This test class is thin; most of it was moved to ExhaustiveNumberTest.
+ * NOTE: The test testSetCoverage can be found in ExhaustiveNumberTest.java
+ *
* @author sffc
*/
-public class UnicodeSetStaticCacheTest {
+public class StaticUnicodeSetsTest {
@Test
public void testFrozen() {
@@ -21,4 +22,12 @@
assertTrue(get(key).isFrozen());
}
}
+
+ @Test
+ public void testNonEmpty() {
+ for (Key key : Key.values()) {
+ // NOTE: No key EMPTY in Java
+ assertTrue(get(key).isFrozen());
+ }
+ }
}