errln("Incorrect result in " + converter);
}
}
public void TestSurrogateBehavior() {
CharsetProviderICU icu = new CharsetProviderICU();
// get all the converters into an array
Object[] converters = CharsetProviderICU.getAvailableNames();
String norm = "a";
String ext = "\u0275"; // theta
String lead = "\ud835";
String trail = "\udd04";
// lead + trail = \U1d504 (fraktur capital A)
String input =
// error position
ext // unmap(1) 1
+ lead // under 1
+ lead // malf(1) 2
+ trail // unmap(2) 4
+ trail // malf(1) 5
+ ext // unmap(1) 6
+ norm // unmap(1) 7
;
CoderResult[] results = new CoderResult[] {
CoderResult.unmappableForLength(1), // or underflow
CoderResult.UNDERFLOW,
CoderResult.malformedForLength(1),
CoderResult.unmappableForLength(2), // or underflow
CoderResult.malformedForLength(1),
CoderResult.unmappableForLength(1), // or underflow
CoderResult.unmappableForLength(1), // or underflow
};
int[] positions = new int[] { 1,1,2,4,5,6,7 };
int n = positions.length;
int badcount = 0;
int goodcount = 0;
int[] uhohindices = new int[n];
int[] badposindices = new int[n];
int[] malfindices = new int[n];
int[] unmapindices = new int[n];
ArrayList pass = new ArrayList();
ArrayList exempt = new ArrayList();
outer: for (int conv=0; conv<converters.length; conv++) {
String converter = (String)converters[conv];
if (converter.equals("x-IMAP-mailbox-name") || converter.equals("UTF-7") || converter.equals("CESU-8") || converter.equals("BOCU-1") ||
converter.equals("x-LMBCS-1")) {
exempt.add(converter);
continue;
}
boolean currentlybad = false;
Charset icuChar = icu.charsetForName(converter);
CharsetEncoder encoder = icuChar.newEncoder();
CoderResult cr;
CharBuffer source = CharBuffer.wrap(input);
ByteBuffer target = ByteBuffer.allocate(30);