ICU-7592 Remove timebomb in data-driven conversion test. Fix a few bugs in charset code. Update testdata.jar.

X-SVN-Rev: 28022
This commit is contained in:
Michael Ow 2010-05-05 20:45:21 +00:00
parent 1875b3fdbc
commit ab0a766468
7 changed files with 27 additions and 25 deletions

View file

@ -326,7 +326,7 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
charErrorBufferLength = 0;
}
if (!flush && !source.hasRemaining() && preToULength >= 0) {
if (!flush && !source.hasRemaining() && toULength == 0 && preToULength >= 0) {
/* the overflow buffer is emptied and there is no new input: we are done */
return CoderResult.UNDERFLOW;
}

View file

@ -357,7 +357,7 @@ class CharsetSCSU extends CharsetICU{
while(source.hasRemaining()){
if(!target.hasRemaining()){
cr = CoderResult.OVERFLOW;
LabelLoop = false;
label = EndLoop;
return label;
}
b = (short)(source.get() & UConverterConstants.UNSIGNED_BYTE_MASK);
@ -509,7 +509,7 @@ class CharsetSCSU extends CharsetICU{
while(source.hasRemaining()){
if(!target.hasRemaining()){
cr = CoderResult.OVERFLOW;
LabelLoop = false;
label = EndLoop;
return label;
}
b = (short)(source.get() & UConverterConstants.UNSIGNED_BYTE_MASK);

View file

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 2006-2009, International Business Machines Corporation and *
* Copyright (C) 2006-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -102,7 +102,7 @@ class CharsetUTF16 extends CharsetICU {
actualEndianXOR = endianXOR;
break;
}
} else if (toUBytesArray[toULength - 1] != actualBOM[toULength - 1]) {
} else if (isEndianSpecified || toUBytesArray[toULength - 1] != actualBOM[toULength - 1]) {
// we do not have a BOM (and we have toULength bytes)
actualBOM = null;
actualEndianXOR = endianXOR;

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2007-2009, International Business Machines Corporation and *
* Copyright (C) 2007-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -243,6 +243,8 @@ class CharsetUTF7 extends CharsetICU {
offsets.put(sourceIndex++);
}
} else { // Get out and set the CoderResult.
charErrorBufferArray[charErrorBufferLength++] = b;
cr = CoderResult.OVERFLOW;
break;
}
} else { /* PLUS or (AMPERSAND in IMAP)*/

View file

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 2006-2008, International Business Machines Corporation and *
* Copyright (C) 2006-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
@ -143,7 +143,7 @@ class CharsetUTF8 extends CharsetICU {
if (targetIndex >= targetLimit) {
/* put in overflow buffer (not handled here) */
charErrorBufferArray[charErrorBufferBegin++] = (char) char32;
charErrorBufferArray[charErrorBufferLength++] = (char) ((char32 & UConverterConstants.HALF_MASK) + UConverterConstants.SURROGATE_LOW_START);
cr = CoderResult.OVERFLOW;
break;
}
@ -278,7 +278,7 @@ class CharsetUTF8 extends CharsetICU {
if (targetIndex >= targetLimit) {
/* put in overflow buffer (not handled here) */
charErrorBufferArray[charErrorBufferBegin++] = (char) char32;
charErrorBufferArray[charErrorBufferLength++] = (char) ((char32 & UConverterConstants.HALF_MASK) + UConverterConstants.SURROGATE_LOW_START);
cr = CoderResult.OVERFLOW;
break;
}

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d9a696ca3c5bd0786846e763ea0f67b847d81e5333840681b8b770ff6fb4b6b2
size 720423
oid sha256:593c722f8cfb2f0354dbd27d882dfd9ee4fc2abfb7845b2f7b0246a1257f818e
size 718070

View file

@ -68,6 +68,11 @@ public class TestConversion extends ModuleTest {
return "[" + caseNr + "]";
}
}
/* In the data-driven conversion test, converters that are not available in
* ICU4J are marked with the following leading symbol.
*/
private static final char UNSUPPORTED_CHARSET_SYMBOL = '+';
// public methods --------------------------------------------------------
@ -214,8 +219,8 @@ public class TestConversion extends ModuleTest {
}
} catch (Exception e) {
if (skipIfBeforeICU(4,5,1)) { // TIME BOMB
logln("Skipping test:(" + cc.charset + ") due to ICU Charset not supported at this time");
if (cc.charset.charAt(0) == UNSUPPORTED_CHARSET_SYMBOL) {
logln("Skipping test:(" + cc.charset.substring(1) + ") due to ICU Charset not supported at this time");
} else {
errln(cc.charset + " was not found");
}
@ -496,8 +501,8 @@ public class TestConversion extends ModuleTest {
} catch (Exception e) {
// TODO implement loading of test data.
if (skipIfBeforeICU(4,5,1)) {
logln("Skipping test:(" + cc.charset + ") due to ICU Charset not supported at this time");
if (cc.charset.charAt(0) == UNSUPPORTED_CHARSET_SYMBOL) {
logln("Skipping test:(" + cc.charset.substring(1) + ") due to ICU Charset not supported at this time");
} else {
errln(cc.charset + " was not found");
}
@ -692,8 +697,10 @@ public class TestConversion extends ModuleTest {
cr = decoder.decode(source, target, true);
//due to limitation of the API we need to check for target limit for expected
if (target.limit() != cc.unicode.length()) {
target.limit(cc.unicode.length());
if (target.position() != cc.unicode.length()) {
if (target.limit() != cc.unicode.length()) {
target.limit(cc.unicode.length());
}
cr = decoder.flush(target);
if (cr.isError()) {
errln("Flush operation failed");
@ -1096,11 +1103,7 @@ public class TestConversion extends ModuleTest {
// test to see if the conversion matches actual results
if (output.limit() != expected.length()) {
if (skipIfBeforeICU(4,5,1)) { // TIME BOMB
logln("Skipping test:(" + cc.charset + ") due to time bomb");
} else {
errln("Test failed: output length does not match expected for charset: "+cc.charset+ " [" + cc.caseNr + "]");
}
errln("Test failed: output length does not match expected for charset: "+cc.charset+ " [" + cc.caseNr + "]");
res = false;
} else {
for (int i = 0; i < expected.length(); i++) {
@ -1119,9 +1122,6 @@ public class TestConversion extends ModuleTest {
logln("Output: " + printchars(output, output.limit()));
logln("Expected: " + printchars(CharBuffer.wrap(expected), expected.length()));
logln("Passed");
}
else if (skipIfBeforeICU(4,5,1)) {
// TIME BOMB
} else {
errln("[" + cc.caseNr + "]:" + cc.charset);
errln("Input: " + printbytes(cc.bytes, cc.bytes.limit()));