@Test public void testSingle() { RepeatedList<Integer> rl = new RepeatedList<>(7, 1); assertThat(rl.size(), equalTo(1)); assertThat(rl.get(0).intValue(), equalTo(7)); try { rl.get(1); fail("Should throw an exception!"); } catch(IndexOutOfBoundsException e) { /* expected */ } }
@Test public void testEmpty() { RepeatedList<Integer> rl = new RepeatedList<>(7, 0); assertThat(rl.size(), equalTo(0)); try { rl.get(-1); fail("Should throw an exception!"); } catch(IndexOutOfBoundsException e) { /* expected */ } try { rl.get(0); fail("Should throw an exception!"); } catch(IndexOutOfBoundsException e) { /* expected */ } try { rl.get(1); fail("Should throw an exception!"); } catch(IndexOutOfBoundsException e) { /* expected */ } }