serializer.setNextBuffer(buffer);
int numBytes = 0;
for (SerializationTestType record : records) {
SerializationResult result = serializer.addRecord(record);
numBytes += record.length() + SERIALIZATION_OVERHEAD;
if (numBytes < segmentSize) {
Assert.assertEquals(SerializationResult.FULL_RECORD, result);
} else if (numBytes == segmentSize) {
Assert.assertEquals(SerializationResult.FULL_RECORD_MEMORY_SEGMENT_FULL, result);
serializer.setNextBuffer(buffer);
numBytes = 0;
} else {
Assert.assertEquals(SerializationResult.PARTIAL_RECORD_MEMORY_SEGMENT_FULL, result);
while (result.isFullBuffer()) {
numBytes -= segmentSize;
result = serializer.setNextBuffer(buffer);
}
}
}