### Question:
BaseHighLimitRecordFormat extends BaseOneByteHeaderRecordFormat<RECORD> { @Override public void read( RECORD record, PageCursor primaryCursor, RecordLoad mode, int recordSize ) throws IOException { int primaryStartOffset = primaryCursor.getOffset(); byte headerByte = primaryCursor.getByte(); boolean inUse = isInUse( headerByte ); boolean doubleRecordUnit = has( headerByte, HEADER_BIT_RECORD_UNIT ); record.setUseFixedReferences( false ); if ( doubleRecordUnit ) { boolean firstRecordUnit = has( headerByte, HEADER_BIT_FIRST_RECORD_UNIT ); if ( !firstRecordUnit ) { record.clear(); primaryCursor.setCursorException( "Expected record to be the first unit in the chain, but record header says it's not" ); return; } long secondaryId = Reference.decode( primaryCursor ); long pageId = pageIdForRecord( secondaryId, primaryCursor.getCurrentPageSize(), recordSize ); int offset = offsetForId( secondaryId, primaryCursor.getCurrentPageSize(), recordSize ); PageCursor secondaryCursor = primaryCursor.openLinkedCursor( pageId ); if ( (!secondaryCursor.next()) | offset < 0 ) { record.clear(); primaryCursor.setCursorException( illegalSecondaryReferenceMessage( pageId ) ); return; } secondaryCursor.setOffset( offset + HEADER_BYTE); int primarySize = recordSize - (primaryCursor.getOffset() - primaryStartOffset); int secondarySize = recordSize - HEADER_BYTE; PageCursor composite = CompositePageCursor.compose( primaryCursor, primarySize, secondaryCursor, secondarySize ); doReadInternal( record, composite, recordSize, headerByte, inUse ); record.setSecondaryUnitId( secondaryId ); record.setRequiresSecondaryUnit(true); } else { record.setUseFixedReferences( isUseFixedReferences( headerByte ) ); doReadInternal( record, primaryCursor, recordSize, headerByte, inUse ); } primaryCursor.setOffset( primaryStartOffset + 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 mustNotCheckForOutOfBoundsWhenReadingSingleRecord() throws Exception { MyRecordFormat format = new MyRecordFormat(); StubPageCursor cursor = new StubPageCursor( 0, 3 ); format.read( new MyRecord( 0 ), cursor, RecordLoad.NORMAL, 4 ); assertFalse( cursor.checkAndClearBoundsFlag() ); }
@Test public void mustCheckForOutOfBoundsWhenReadingDoubleRecord() throws Exception { MyRecordFormat format = new MyRecordFormat(); StubPageCursor cursor = new StubPageCursor( 0, 4 ); cursor.putByte( 0, (byte) (HEADER_BIT_RECORD_UNIT + HEADER_BIT_FIRST_RECORD_UNIT) ); StubPagedFile pagedFile = new StubPagedFile( 3 ) { @Override protected void prepareCursor( StubPageCursor cursor ) { cursor.putByte( 0, (byte) HEADER_BIT_RECORD_UNIT ); } }; format.shortsPerRecord.add( 2 ); format.read( new MyRecord( 0 ), cursor, RecordLoad.NORMAL, 4 ); assertTrue( cursor.checkAndClearBoundsFlag() ); }