### Question:
Terms { synchronized long get( long logIndex ) { if ( logIndex == -1 || logIndex < min || logIndex > max ) { return -1; } for ( int i = size - 1; i >= 0; i-- ) { if ( logIndex >= indexes[i] ) { return terms[i]; } } throw new RuntimeException( "Should be possible to find index >= min" ); } Terms( long prevIndex, long prevTerm );   }### Answer:
@Test public void shouldHaveCorrectInitialValues() { long prevIndex = 5; long prevTerm = 10; terms = new Terms( prevIndex, prevTerm ); assertTermInRange( -1, prevIndex, index -> -1L ); assertEquals( prevTerm, terms.get( prevIndex ) ); assertTermInRange( prevIndex + 1, prevIndex + 10, index -> -1L ); }
@Test public void shouldReturnAppendedTerms() { terms = new Terms( -1, -1 ); int count = 10; appendRange( 0, count, index -> index * 2L ); assertTermInRange( 0, count, index -> index * 2L ); assertEquals( -1, terms.get( -1 ) ); assertEquals( -1, terms.get( count ) ); }