### Question:
BaseHighLimitRecordFormat extends BaseOneByteHeaderRecordFormat<RECORD> { @Override public void write( RECORD record, PageCursor primaryCursor, int recordSize ) throws IOException { if ( record.inUse() ) { byte headerByte = headerBits( record ); assert (headerByte & 0x7) == 0 : "Format-specific header bits (" + headerByte + ") collides with format-generic header bits"; headerByte = set( headerByte, IN_USE_BIT, record.inUse() ); headerByte = set( headerByte, HEADER_BIT_RECORD_UNIT, record.requiresSecondaryUnit() ); if ( record.requiresSecondaryUnit() ) { headerByte = set( headerByte, HEADER_BIT_FIRST_RECORD_UNIT, true ); } else { headerByte = set( headerByte, HEADER_BIT_FIXED_REFERENCE, !record.isUseFixedReferences() ); } primaryCursor.putByte( headerByte ); if ( record.requiresSecondaryUnit() ) { long secondaryUnitId = record.getSecondaryUnitId(); long pageId = pageIdForRecord( secondaryUnitId, primaryCursor.getCurrentPageSize(), recordSize ); int offset = offsetForId( secondaryUnitId, primaryCursor.getCurrentPageSize(), recordSize ); PageCursor secondaryCursor = primaryCursor.openLinkedCursor( pageId ); if ( !secondaryCursor.next() ) { record.clear(); return; } secondaryCursor.setOffset( offset ); secondaryCursor.putByte( (byte) (IN_USE_BIT | HEADER_BIT_RECORD_UNIT) ); int recordSizeWithoutHeader = recordSize - HEADER_BYTE; PageCursor composite = CompositePageCursor.compose( primaryCursor, recordSizeWithoutHeader, secondaryCursor, recordSizeWithoutHeader ); Reference.encode( secondaryUnitId, composite ); doWriteInternal( record, composite ); } else { doWriteInternal( record, primaryCursor ); } } else { markAsUnused( primaryCursor, record, recordSize ); } } protected  BaseHighLimitRecordFormat( Function<StoreHeader,Integer> recordSize, int recordHeaderSize, int maxIdBits ); @Override void read( RECORD record, PageCursor primaryCursor, RecordLoad mode, int recordSize ); @Override void write( RECORD record, PageCursor primaryCursor, int recordSize ); @Override final void prepare( RECORD record, int recordSize, IdSequence idSequence );  }### Answer:
@Test public void mustNotCheckForOutOfBoundsWhenWritingSingleRecord() throws Exception { MyRecordFormat format = new MyRecordFormat(); StubPageCursor cursor = new StubPageCursor( 0, 3 ); MyRecord record = new MyRecord( 0 ); record.setInUse( true ); format.write( record, cursor, 4 ); assertFalse( cursor.checkAndClearBoundsFlag() ); }
@Test public void mustCheckForOutOfBoundsWhenWritingDoubleRecord() throws Exception { MyRecordFormat format = new MyRecordFormat(); StubPageCursor cursor = new StubPageCursor( 0, 5 ); MyRecord record = new MyRecord( 0 ); record.setRequiresSecondaryUnit( true ); record.setSecondaryUnitId( 42 ); record.setInUse( true ); format.shortsPerRecord.add( 3 ); format.write( record, cursor, 4 ); assertTrue( cursor.checkAndClearBoundsFlag() ); }