{
new CompactArrayTest().run(args);
}
public void TestByteArrayCoverage() {
CompactByteArray cba = new CompactByteArray();
cba.setElementAt((char)0x5, (byte)0xdf);
cba.setElementAt((char)0x105, (byte)0xdf);
cba.setElementAt((char)0x205, (byte)0xdf);
cba.setElementAt((char)0x305, (byte)0xdf);
CompactByteArray cba2 = new CompactByteArray((byte)0xdf);
if (cba.equals(cba2)) {
errln("unequal byte arrays compare equal");
}
CompactByteArray cba3 = (CompactByteArray)cba.clone();
logln("equals null: " + cba.equals(null));
logln("equals self: " + cba.equals(cba));
logln("equals clone: " + cba.equals(cba3));
logln("equals bogus: " + cba.equals(new Object()));
logln("hash: " + cba.hashCode());
cba.compact(true);
cba.compact(true);
char[] xa = cba.getIndexArray();
byte[] va = cba.getValueArray();
CompactByteArray cba4 = new CompactByteArray(xa, va);
String xs = Utility.arrayToRLEString(xa);
String vs = Utility.arrayToRLEString(va);
CompactByteArray cba5 = new CompactByteArray(xs, vs);
logln("equals: " + cba4.equals(cba5));
logln("equals: " + cba.equals(cba4));
cba4.compact(false);
logln("equals: " + cba4.equals(cba5));
cba5.compact(true);
logln("equals: " + cba4.equals(cba5));
cba.setElementAt((char)0x405, (byte)0xdf); // force expand
logln("modified equals clone: " + cba.equals(cba3));
cba3.setElementAt((char)0x405, (byte)0xdf); // equivalent modification
logln("modified equals modified clone: " + cba.equals(cba3));
cba3.setElementAt((char)0x405, (byte)0xee); // different modification
logln("different mod equals: " + cba.equals(cba3));
cba.compact();
CompactByteArray cba6 = (CompactByteArray)cba.clone();
logln("cloned compact equals: " + cba.equals(cba6));
cba6.setElementAt((char)0x405, (byte)0xee);
logln("modified clone: " + cba3.equals(cba6));
cba6.setElementAt((char)0x100, (char)0x104, (byte)0xfe);
for (int i = 0x100; i < 0x105; ++i) {
cba3.setElementAt((char)i, (byte)0xfe);
}
logln("double modified: " + cba3.equals(cba6));
}