### Question:
GenerationSafePointerPair { public static long read( PageCursor cursor, long stableGeneration, long unstableGeneration, GBPTreeGenerationTarget generationTarget ) { long generationA = readGeneration( cursor ); long pointerA = readPointer( cursor ); short readChecksumA = readChecksum( cursor ); short checksumA = checksumOf( generationA, pointerA ); boolean correctChecksumA = readChecksumA == checksumA; long generationB = readGeneration( cursor ); long pointerB = readPointer( cursor ); short readChecksumB = readChecksum( cursor ); short checksumB = checksumOf( generationB, pointerB ); boolean correctChecksumB = readChecksumB == checksumB; byte pointerStateA = pointerState( stableGeneration, unstableGeneration, generationA, pointerA, correctChecksumA ); byte pointerStateB = pointerState( stableGeneration, unstableGeneration, generationB, pointerB, correctChecksumB ); if ( pointerStateA == UNSTABLE ) { if ( pointerStateB == STABLE || pointerStateB == EMPTY ) { return buildSuccessfulReadResult( FLAG_SLOT_A, generationA, pointerA, generationTarget ); } } else if ( pointerStateB == UNSTABLE ) { if ( pointerStateA == STABLE || pointerStateA == EMPTY ) { return buildSuccessfulReadResult( FLAG_SLOT_B, generationB, pointerB, generationTarget ); } } else if ( pointerStateA == STABLE && pointerStateB == STABLE ) { if ( generationA > generationB ) { return buildSuccessfulReadResult( FLAG_SLOT_A, generationA, pointerA, generationTarget ); } else if ( generationB > generationA ) { return buildSuccessfulReadResult( FLAG_SLOT_B, generationB, pointerB, generationTarget ); } } else if ( pointerStateA == STABLE ) { return buildSuccessfulReadResult( FLAG_SLOT_A, generationA, pointerA, generationTarget ); } else if ( pointerStateB == STABLE ) { return buildSuccessfulReadResult( FLAG_SLOT_B, generationB, pointerB, generationTarget ); } generationTarget.accept( EMPTY_GENERATION ); return FLAG_FAIL | FLAG_READ | generationState( generationA, generationB ) | ((long) pointerStateA) << SHIFT_STATE_A | ((long) pointerStateB) << SHIFT_STATE_B; } private  GenerationSafePointerPair(); static long read( PageCursor cursor, long stableGeneration, long unstableGeneration, GBPTreeGenerationTarget generationTarget ); static long write( PageCursor cursor, long pointer, long stableGeneration, long unstableGeneration );  }### Answer:
@Test public void shouldRead() { cursor.setOffset( SLOT_A_OFFSET ); long preStatePointerA = stateA.materialize( cursor, POINTER_A ); cursor.setOffset( SLOT_B_OFFSET ); long preStatePointerB = stateB.materialize( cursor, POINTER_B ); cursor.setOffset( GSPP_OFFSET ); GenerationKeeper generationKeeper = new GenerationKeeper(); long result = GenerationSafePointerPair.read( cursor, STABLE_GENERATION, UNSTABLE_GENERATION, generationKeeper ); expectedReadOutcome.verifyRead( cursor, result, stateA, stateB, preStatePointerA, preStatePointerB, generationKeeper.generation ); }