ConversionCase cc = new ConversionCase();
CharsetProviderICU provider = new CharsetProviderICU();
CharsetICU charset ;
UnicodeSet mapset = new UnicodeSet();
UnicodeSet mapnotset = new UnicodeSet();
UnicodeSet unicodeset = new UnicodeSet();
String ellipsis = "0x2e";
cc.charset = ((ICUResourceBundle) testcase.getObject("charset"))
.getString();
cc.map = ((ICUResourceBundle) testcase.getObject("map")).getString();
cc.mapnot = ((ICUResourceBundle) testcase.getObject("mapnot"))
.getString();
int which = ((ICUResourceBundle) testcase.getObject("which")).getInt(); // only checking for ROUNDTRIP_SET
// ----for debugging only
logln("");
logln("TestGetUnicodeSet[" + cc.charset + "] ");
logln("...............................................");
try{
// if cc.charset starts with '*', obtain it from com/ibm/icu/dev/data/testdata
charset = (cc.charset != null && cc.charset.length() > 0 && cc.charset.charAt(0) == '*')
? (CharsetICU) provider.charsetForName(cc.charset.substring(1),
"com/ibm/icu/dev/data/testdata", this.getClass().getClassLoader())
: (CharsetICU) provider.charsetForName(cc.charset);
//checking for converter that are not supported at this point
try{
if(charset.name()=="BOCU-1" ||charset.name()== "SCSU"|| charset.name()=="lmbcs1" || charset.name()== "lmbcs2" ||
charset.name()== "lmbcs3" || charset.name()== "lmbcs4" || charset.name()=="lmbcs5" || charset.name()=="lmbcs6" ||
charset.name()== "lmbcs8" || charset.name()=="lmbcs11" || charset.name()=="lmbcs16" || charset.name()=="lmbcs17" ||
charset.name()=="lmbcs18"|| charset.name()=="lmbcs19"){
logln("Converter not supported at this point :" +charset.displayName());
return;
}
if(which==1){
logln("Fallback set not supported at this point for converter : "+charset.displayName());
return;
}
}catch(Exception e){
return;
}
mapset.clear();
mapnotset.clear();
mapset.applyPattern(cc.map,false);
mapnotset.applyPattern(cc.mapnot,false);
charset.getUnicodeSet(unicodeset, which);
UnicodeSet diffset = new UnicodeSet();
//are there items that must be in unicodeset but are not?
(diffset = mapset).removeAll(unicodeset);
if(!diffset.isEmpty()){
StringBuffer s = new StringBuffer(diffset.toPattern(true));
if(s.length()>100){
s.replace(0, 0x7fffffff, ellipsis);
}
errln("error in missing items - conversion/getUnicodeSet test case "+cc.charset + "\n" + s.toString());
}
//are the items that must not be in unicodeset but are?
(diffset=mapnotset).retainAll(unicodeset);
if(!diffset.isEmpty()){
StringBuffer s = new StringBuffer(diffset.toPattern(true));
if(s.length()>100){
s.replace(0, 0x7fffffff, ellipsis);
}
errln("contains unexpected items - conversion/getUnicodeSet test case "+cc.charset + "\n" + s.toString());
}