### Question:
History { public void alloc( int k ) { if (k == 0) throw new IllegalArgumentException( "k == 0" ); int newAlloc = alloc + k; if (newAlloc > limit) throw new IllegalStateException( "newAlloc > limit" ); if (newAlloc < 0) throw new IllegalStateException( "newAlloc < 0" ); alloc = newAlloc; } History( int min, int limit, int len ); int limit(); int min(); int length(); boolean used( int k ); int getUsed(); void alloc( int k ); int getAlloc(); void init(); void tickle(); int suggested();  }### Answer:
@Test public void alloc1() throws Exception { History h = new History( 0, 10, 5 ); checkUsedAlloc( h, 0, 0 ); h.alloc( 1 ); checkUsedAlloc( h, 0, 1 ); h.alloc( -1 ); checkUsedAlloc( h, 0, 0 ); }
@Test public void alloc2() throws Exception { History h = new History( 0, 10, 5 ); checkUsedAlloc( h, 0, 0 ); h.alloc( 2 ); checkUsedAlloc( h, 0, 2 ); h.alloc( -2 ); checkUsedAlloc( h, 0, 0 ); }
@Test public void alloc3() throws Exception { History h = new History( 0, 10, 5 ); checkUsedAlloc( h, 0, 0 ); h.alloc( 1 ); checkUsedAlloc( h, 0, 1 ); h.alloc( 1 ); checkUsedAlloc( h, 0, 2 ); h.alloc( -1 ); checkUsedAlloc( h, 0, 1 ); h.alloc( -1 ); checkUsedAlloc( h, 0, 0 ); }
@Test( expected = IllegalStateException.class ) public void alloc4() throws Exception { History h = new History( 0, 10, 5 ); checkUsedAlloc( h, 0, 0 ); h.alloc( 11 ); }
@Test( expected = IllegalStateException.class ) public void alloc5() throws Exception { History h = new History( 0, 10, 5 ); checkUsedAlloc( h, 0, 0 ); h.alloc( 1 ); checkUsedAlloc( h, 0, 1 ); h.alloc( 9 ); checkUsedAlloc( h, 0, 10 ); h.alloc( 1 ); }
@Test( expected = IllegalStateException.class ) public void alloc6() throws Exception { History h = new History( 0, 10, 5 ); checkUsedAlloc( h, 0, 0 ); h.alloc( -1 ); }
@Test( expected = IllegalStateException.class ) public void alloc7() throws Exception { History h = new History( 0, 10, 5 ); checkUsedAlloc( h, 0, 0 ); h.alloc( 1 ); checkUsedAlloc( h, 0, 1 ); h.alloc( -2 ); }
@Test public void alloc8() throws Exception { History h = new History( 0, 10, 5 ); checkUsedAlloc( h, 0, 0 ); h.alloc( 1 ); checkUsedAlloc( h, 0, 1 ); try { h.alloc( -2 ); fail( "never reached" ); } catch ( IllegalStateException e ) { checkUsedAlloc( h, 0, 1 ); } }
@Test( expected = IllegalArgumentException.class ) public void alloc9() throws Exception { History h = new History( 0, 10, 5 ); h.alloc( 0 ); }