assertEquals("0a1A0A", p2.toArray()[6]);
}
public void testGetCRCWithoutCrash() throws IOException {
ParameterSet pset;
PureJavaCrc32C crc;
ByteBuffer buf;
Object[] psetObjs = new Object[] {
null, VoltType.INTEGER.getNullValue(), VoltType.DECIMAL.getNullValue(), // null values
(byte)1, (short)2, (int)3, (long)4, 1.2f, 3.6d, // numbers
"This is spinal tap", "", // strings
"ABCDF012", new byte[] { 1, 3, 5 }, new byte[0], // binary
new BigDecimal(5.5), // decimal
new TimestampType(new Date()) // timestamp
};
pset = ParameterSet.fromArrayNoCopy(psetObjs);
crc = new PureJavaCrc32C();
buf = ByteBuffer.allocate(pset.getSerializedSize());
pset.flattenToBuffer(buf);
crc.update(buf.array());
long crc1 = crc.getValue();
ArrayUtils.reverse(psetObjs);
pset = ParameterSet.fromArrayNoCopy(psetObjs);
crc = new PureJavaCrc32C();
buf = ByteBuffer.allocate(pset.getSerializedSize());
pset.flattenToBuffer(buf);
crc.update(buf.array());
long crc2 = crc.getValue();
pset = ParameterSet.fromArrayNoCopy(new Object[0]);
crc = new PureJavaCrc32C();
buf = ByteBuffer.allocate(pset.getSerializedSize());
pset.flattenToBuffer(buf);
crc.update(buf.array());
long crc3 = crc.getValue();
pset = ParameterSet.fromArrayNoCopy(new Object[] { 1 });
crc = new PureJavaCrc32C();
buf = ByteBuffer.allocate(pset.getSerializedSize());
pset.flattenToBuffer(buf);
crc.update(buf.array());
long crc4 = crc.getValue();
assertNotSame(crc1, crc2);
assertNotSame(crc1, crc3);
assertNotSame(crc1, crc4);
assertNotSame(crc2, crc3);