@Test
  public final void testWriteStringIntInt() {
    final Random ramdom = new Random();

    for (int repeatIndex = 0; repeatIndex < 100; repeatIndex++) {
      for (int i = 0, size = string.length(); i < size; i++) {
        final int length = size - i - ramdom.nextInt(size - i);

        final StringBuildWriter stringBuildWriter = new StringBuildWriter();
        stringBuildWriter.write(string, i, length);

        assertThat(
            stringBuildWriter.getStringBuilder().toString(),
            is(equalTo(string.substring(i, i + length))));
      }
      for (int i = string.length() - 1, size = string.length() + 1; i > 0; i--) {
        final int length = ramdom.nextInt(size - i);

        final StringBuildWriter stringBuildWriter = new StringBuildWriter();
        stringBuildWriter.write(string, i, length);

        assertThat(
            stringBuildWriter.getStringBuilder().toString(),
            is(equalTo(string.substring(i, i + length))));
      }
    }
  }
  @Test
  public final void testWriteCharArrayIntInt() {
    final Random ramdom = new Random();

    for (int repeatIndex = 0; repeatIndex < 100; repeatIndex++) {
      for (int i = 0, size = chars.length; i < size; i++) {
        final int length = size - i - ramdom.nextInt(size - i);

        final StringBuildWriter stringBuildWriter = new StringBuildWriter();
        stringBuildWriter.write(chars, i, length);

        assertThat(
            stringBuildWriter.getStringBuilder().toString(),
            is(equalTo(new StringBuilder().append(chars, i, length).toString())));
      }
      for (int i = chars.length - 1, size = chars.length + 1; i > 0; i--) {
        final int length = ramdom.nextInt(size - i);

        final StringBuildWriter stringBuildWriter = new StringBuildWriter();
        stringBuildWriter.write(chars, i, length);

        assertThat(
            stringBuildWriter.getStringBuilder().toString(),
            is(equalTo(new StringBuilder().append(chars, i, length).toString())));
      }
    }
  }
 @Test
 public final void testWriteCharArray() {
   final StringBuildWriter stringBuildWriter = new StringBuildWriter();
   stringBuildWriter.write(chars);
   assertThat(
       stringBuildWriter.getStringBuilder().toString(),
       is(equalTo(new StringBuilder().append(chars).toString())));
 }
 @Test
 public final void testWriteInt() throws IOException {
   for (int i = 0; i < 255; i++) {
     final StringBuildWriter stringBuildWriter = new StringBuildWriter();
     stringBuildWriter.write(i);
     assertThat(
         stringBuildWriter.getStringBuilder().toString(), is(equalTo(String.valueOf((char) i))));
   }
 }
 @Test
 public final void testToString() {
   final StringBuildWriter stringBuildWriter = new StringBuildWriter();
   final StringBuilder expected = new StringBuilder();
   for (int i = 0, size = string.length(); i < size; i++) {
     stringBuildWriter.write(string.substring(i));
     expected.append(string.substring(i));
     assertThat(stringBuildWriter.toString(), is(equalTo(expected.toString())));
   }
 }
 @Test
 public final void testWriteString() {
   final StringBuildWriter stringBuildWriter = new StringBuildWriter();
   stringBuildWriter.write(string);
   assertThat(stringBuildWriter.getStringBuilder().toString(), is(equalTo(string)));
 }