ICU-7120 Fix error check in test and concatenation code for normalizer.

X-SVN-Rev: 26594
This commit is contained in:
Michael Ow 2009-09-03 19:32:31 +00:00
parent 0ea33cbf80
commit 37b340e112
2 changed files with 12 additions and 6 deletions

View File

@ -1657,7 +1657,7 @@ public final class Normalizer implements Cloneable {
int rightLength=(rightLimit-rightStart);
if(rightLength>0 && destLimit>destLength) {
System.arraycopy(right,rightStart,dest,destLength,
Math.min(rightLength,destLength)
Math.min(rightLength,destLimit - destLength)
);
}
destLength+=rightLength;
@ -2400,8 +2400,11 @@ public final class Normalizer implements Cloneable {
(bufferLength<destCapacity) ?
bufferLength : destCapacity);
}
destLength = bufferLength;
}
}
} else {
destLength = bufferLength;
}
return destLength;
@ -2621,9 +2624,12 @@ public final class Normalizer implements Cloneable {
/* just copy the source characters */
if(destCapacity>0) {
System.arraycopy(buffer,0,dest,destStart,
Math.min(bufferLength,destCapacity));
Math.min(bufferLength,destCapacity - destStart));
}
destLength = bufferLength;
}
} else {
destLength = bufferLength;
}
return destLength;
}

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1996-2008, International Business Machines Corporation and *
* Copyright (C) 1996-2009, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -1594,7 +1594,7 @@ public class BasicTest extends TestFmwk {
expect=(String)cases[i][3];
{
result=Normalizer.concatenate(left, right, mode,0);
if( result.equals(expect)) {
if(!result.equals(expect)) {
errln("error in Normalizer.concatenate(), cases[] failed"
+", result==expect: expected: "
+ hex(expect)+" =========> got: " + hex(result));
@ -1602,7 +1602,7 @@ public class BasicTest extends TestFmwk {
}
{
result=Normalizer.concatenate(left.toCharArray(), right.toCharArray(), mode,0);
if( result.equals(expect)) {
if(!result.equals(expect)) {
errln("error in Normalizer.concatenate(), cases[] failed"
+", result==expect: expected: "
+ hex(expect)+" =========> got: " + hex(result));