@Test(expected = StringIndexOutOfBoundsException.class) public void shouldThrowExceptionWhenCharAtCalledWithNoBuffer() { asciiSequenceView.charAt(0); }
@Test public void shouldBeAbleToGetChars() { final String data = "stringy"; buffer.putStringWithoutLengthAscii(INDEX, data); asciiSequenceView.wrap(buffer, INDEX, data.length()); assertThat(asciiSequenceView.charAt(0), is('s')); assertThat(asciiSequenceView.charAt(1), is('t')); assertThat(asciiSequenceView.charAt(2), is('r')); assertThat(asciiSequenceView.charAt(3), is('i')); assertThat(asciiSequenceView.charAt(4), is('n')); assertThat(asciiSequenceView.charAt(5), is('g')); assertThat(asciiSequenceView.charAt(6), is('y')); }
@Test(expected = StringIndexOutOfBoundsException.class) public void shouldThrowIndexOutOfBoundsExceptionWhenCharNotPresentAtGivenPosition() { final String data = "foo"; buffer.putStringWithoutLengthAscii(INDEX, data); asciiSequenceView.wrap(buffer, INDEX, data.length()); asciiSequenceView.charAt(4); }
@Test(expected = StringIndexOutOfBoundsException.class) public void shouldThrowExceptionWhenCharAtCalledWithNegativeIndex() { final String data = "foo"; buffer.putStringWithoutLengthAscii(INDEX, data); asciiSequenceView.wrap(buffer, INDEX, data.length()); asciiSequenceView.charAt(-1); } }