mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-4162 fix failures
X-SVN-Rev: 16659
This commit is contained in:
parent
82239ea37e
commit
e3dbdda10a
8 changed files with 72 additions and 8 deletions
|
@ -52,7 +52,7 @@ public class RandomCollator extends TestFmwk {
|
|||
// System.out.println("\nTestRandom skipped for 2003");
|
||||
// return;
|
||||
// }
|
||||
if(skipIfBeforeICU(3,0)) return;
|
||||
if(skipIfBeforeICU(3,2)) return;
|
||||
String fileName;
|
||||
PrintWriter pw = BagFormatter.openUTF8Writer(System.getProperty("user.dir")+File.separator, "RandomCollationTestLog.txt");
|
||||
TestCollator tc = new TestCollator(chars);
|
||||
|
|
|
@ -33,7 +33,7 @@ public class TestUScript extends TestFmwk {
|
|||
new ULocale("he"), new ULocale("ar"),
|
||||
new ULocale("abcde"),
|
||||
new ULocale("abcde_cdef"),
|
||||
//new ULocale(ULocale.canonicalize("iw"))
|
||||
new ULocale("iw")
|
||||
};
|
||||
final int[] expected ={
|
||||
/* locales should return */
|
||||
|
@ -42,7 +42,7 @@ public class TestUScript extends TestFmwk {
|
|||
UScript.TELUGU,UScript.DEVANAGARI,
|
||||
UScript.HEBREW, UScript.ARABIC,
|
||||
UScript.INVALID_CODE,UScript.INVALID_CODE,
|
||||
//UScript.HEBREW
|
||||
UScript.HEBREW
|
||||
};
|
||||
int i =0;
|
||||
int numErrors =0;
|
||||
|
@ -64,6 +64,16 @@ public class TestUScript extends TestFmwk {
|
|||
}
|
||||
}
|
||||
reportDataErrors(numErrors);
|
||||
|
||||
//
|
||||
ULocale defaultLoc = ULocale.getDefault();
|
||||
ULocale esparanto = new ULocale("eo_DE");
|
||||
ULocale.setDefault(esparanto);
|
||||
int[] code = UScript.getCode(esparanto);
|
||||
if(code[0] != UScript.LATIN){
|
||||
errln("Did not get the expected script code for Esparanto");
|
||||
}
|
||||
ULocale.setDefault(defaultLoc);
|
||||
}
|
||||
|
||||
private void reportDataErrors(int numErrors) {
|
||||
|
|
|
@ -778,7 +778,7 @@ public class ULocaleTest extends TestFmwk {
|
|||
{ "uz-UZ-Cyrl", "uz_UZ_CYRL", "uz_Cyrl_UZ" }, /* .NET name */
|
||||
{ "uz-UZ-Latn", "uz_UZ_LATN", "uz_Latn_UZ" }, /* .NET name */
|
||||
{ "zh-CHS", "zh_CHS", "zh_Hans" }, /* .NET name */
|
||||
{ "zh-CHT", "zh_CHT", "zh_TW" }, /* .NET name This may change back to zh_Hant */
|
||||
{ "zh-CHT", "zh_CHT", "zh_Hant" }, /* .NET name This may change back to zh_Hant */
|
||||
|
||||
/* posix behavior that used to be performed by getName */
|
||||
{ "mr.utf8", null, "mr" },
|
||||
|
|
|
@ -9,8 +9,14 @@
|
|||
**********************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.test.util;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.text.UnicodeSet;
|
||||
|
||||
/**
|
||||
* @test
|
||||
|
@ -109,4 +115,17 @@ public class UtilityTest extends TestFmwk {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
public void TestUnicodeSet(){
|
||||
String[] array = new String[]{"a", "b", "c", "{de}"};
|
||||
List list = Arrays.asList(array);
|
||||
Set aset = new HashSet(list);
|
||||
logln(" *** The source set's size is: " + aset.size());
|
||||
//The size reads 4
|
||||
UnicodeSet set = new UnicodeSet();
|
||||
set.clear();
|
||||
set.addAll(aset);
|
||||
logln(" *** After addAll, the UnicodeSet size is: " + set.size());
|
||||
//The size should also read 4, but 0 is seen instead
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,6 +145,18 @@ public abstract class ICUResourceBundle extends UResourceBundle{
|
|||
*/
|
||||
public static final int INT_VECTOR=14;
|
||||
|
||||
public static final int FROM_FALLBACK =1,
|
||||
FROM_ROOT = 2,
|
||||
FROM_DEFAULT = 3;
|
||||
|
||||
private int loadingStatus = -1;
|
||||
|
||||
public void setLoadingStatus(int newStatus){
|
||||
loadingStatus = newStatus;
|
||||
}
|
||||
public int getLoadingStatus(){
|
||||
return loadingStatus;
|
||||
}
|
||||
/**
|
||||
* Return the version number associated with this UResourceBundle as an
|
||||
* VersionInfo object.
|
||||
|
|
|
@ -35,6 +35,10 @@ public class ResourceBundleWrapper extends UResourceBundle {
|
|||
}
|
||||
}
|
||||
}
|
||||
private int loadingStatus = -1;
|
||||
protected void setLoadingStatus(int newStatus){
|
||||
loadingStatus = newStatus;
|
||||
}
|
||||
protected Object handleGetObject(String key){
|
||||
return bundle.getObject(key);
|
||||
}
|
||||
|
|
|
@ -356,9 +356,13 @@ public final class UScript {
|
|||
catch (MissingResourceException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// if rb is not a strict fallback of the requested locale, return null
|
||||
if(!LocaleUtility.isFallbackOf(rb.getULocale().toString(), locale.toString())){
|
||||
//if(!LocaleUtility.isFallbackOf(rb.getULocale().toString(), locale.toString())){
|
||||
// return null;
|
||||
//}
|
||||
//non existent locale check
|
||||
if(rb.getLoadingStatus()==ICUResourceBundle.FROM_DEFAULT){
|
||||
return null;
|
||||
}
|
||||
ICUResourceBundle sub = rb.get("LocaleScript");
|
||||
|
|
|
@ -351,6 +351,9 @@ public abstract class UResourceBundle extends ResourceBundle{
|
|||
}
|
||||
|
||||
private static final ResourceCacheKey cacheKey = new ResourceCacheKey();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Loads a new resource bundle for the give base name, locale and class loader.
|
||||
* Optionally will disable loading of fallback bundles.
|
||||
|
@ -392,6 +395,9 @@ public abstract class UResourceBundle extends ResourceBundle{
|
|||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
protected abstract void setLoadingStatus(int newStatus);
|
||||
|
||||
/**
|
||||
* Creates a new ICUResourceBundle for the given locale, baseName and class loader
|
||||
* @param baseName the base name of the resource bundle, a fully qualified class name
|
||||
|
@ -428,11 +434,20 @@ public abstract class UResourceBundle extends ResourceBundle{
|
|||
int i = localeName.lastIndexOf('_');
|
||||
if (i != -1) {
|
||||
b = instantiateICUResource(baseName, localeName.substring(0, i), root);
|
||||
if(b!=null && b.getULocale().equals(localeName)){
|
||||
b.setLoadingStatus(ICUResourceBundle.FROM_FALLBACK);
|
||||
}
|
||||
}else{
|
||||
if(defaultID.indexOf(localeName)==-1){
|
||||
b = instantiateICUResource(baseName, defaultID, root);
|
||||
b = instantiateICUResource(baseName, defaultID, root);
|
||||
if(b!=null){
|
||||
b.setLoadingStatus(ICUResourceBundle.FROM_DEFAULT);
|
||||
}
|
||||
}else if(rootLocale.length()!=0){
|
||||
b = ICUResourceBundle.createBundle(baseName, rootLocale, root);
|
||||
b = ICUResourceBundle.createBundle(baseName, rootLocale, root);
|
||||
if(b!=null){
|
||||
b.setLoadingStatus(ICUResourceBundle.FROM_ROOT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
|
Loading…
Add table
Reference in a new issue