ICU-11976 test & fix ByteArrayWrapper.hashCode()
This commit is contained in:
parent
710b6e1421
commit
0b5b3bcdb1
@ -237,7 +237,7 @@ public class ByteArrayWrapper implements Comparable<ByteArrayWrapper>
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = bytes.length;
|
||||
int result = size;
|
||||
for (int i = 0; i < size; ++i) {
|
||||
result = 37*result + bytes[i];
|
||||
}
|
||||
|
@ -137,10 +137,10 @@ public class UtilityTest extends TestFmwk {
|
||||
}
|
||||
|
||||
// test equality
|
||||
if (!x.equals(y) || !x.equals(z))
|
||||
errln("FAIL: test (operator ==): Failed!");
|
||||
if (x.hashCode()!=y.hashCode())
|
||||
errln("FAIL: identical objects have different hash codes.");
|
||||
assertEquals("x==y", x, y);
|
||||
assertEquals("y==z", y, z);
|
||||
assertEquals("x.hashCode()==y.hashCode()", x.hashCode(), y.hashCode());
|
||||
assertEquals("y.hashCode()==z.hashCode()", y.hashCode(), z.hashCode());
|
||||
|
||||
// test non-equality
|
||||
y = new ByteArrayWrapper(bb, 4);
|
||||
|
Loading…
Reference in New Issue
Block a user