public void testStore() throws IOException {
CellRangeAddress ref = new CellRangeAddress(0, 0, 0, 0);
byte[] recordBytes;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
LittleEndianOutputStream out = new LittleEndianOutputStream(baos);
try {
// With nothing set
ref.serialize(out);
recordBytes = baos.toByteArray();
assertEquals(recordBytes.length, data.length);
for (int i = 0; i < data.length; i++) {
assertEquals("At offset " + i, 0, recordBytes[i]);
}
// Now set the flags
ref.setFirstRow((short) 2);
ref.setLastRow((short) 4);
ref.setFirstColumn((short) 0);
ref.setLastColumn((short) 3);
// Re-test
baos.reset();
ref.serialize(out);
recordBytes = baos.toByteArray();
assertEquals(recordBytes.length, data.length);
for (int i = 0; i < data.length; i++) {
assertEquals("At offset " + i, data[i], recordBytes[i]);
}
} finally {
out.close();
}
}