@Test
void testCharAt() {

    final RingBuffer buffer = RingBuffer.fromString("0123456789");
    // Test charAt.
    buffer.append("0123456789012345678901234567890123");
    assertThat(buffer.toString()).isEqualTo("4567890123");
    try {
        buffer.charAt(-1);
        fail("Should have thrown exception.");
    } catch (final IndexOutOfBoundsException e) {
        // Ignore
    }
    try {
        buffer.charAt(buffer.length());
        fail("Should have thrown exception.");
    } catch (final IndexOutOfBoundsException e) {
        // Ignore
    }
    assertThat(buffer.charAt(0)).isEqualTo('4');
    assertThat(buffer.charAt(1)).isEqualTo('5');
    assertThat(buffer.charAt(2)).isEqualTo('6');
    assertThat(buffer.charAt(3)).isEqualTo('7');
    assertThat(buffer.charAt(4)).isEqualTo('8');
    assertThat(buffer.charAt(5)).isEqualTo('9');
    assertThat(buffer.charAt(6)).isEqualTo('0');
    assertThat(buffer.charAt(7)).isEqualTo('1');
    assertThat(buffer.charAt(8)).isEqualTo('2');
    assertThat(buffer.charAt(9)).isEqualTo('3');
}