public static Iterator<Integer> lineOffsetIterator(String input) {
    return new LineOffsetIterator(input);
  }
@Test
  public void offsets() {
    assertThat(ImmutableList.copyOf(Newlines.lineOffsetIterator("foo\nbar\n")))
        .containsExactly(0, 4, 8);
    assertThat(ImmutableList.copyOf(Newlines.lineOffsetIterator("foo\nbar"))).containsExactly(0, 4);

    assertThat(ImmutableList.copyOf(Newlines.lineOffsetIterator("foo\rbar\r")))
        .containsExactly(0, 4, 8);
    assertThat(ImmutableList.copyOf(Newlines.lineOffsetIterator("foo\rbar"))).containsExactly(0, 4);

    assertThat(ImmutableList.copyOf(Newlines.lineOffsetIterator("foo\r\nbar\r\n")))
        .containsExactly(0, 5, 10);
    assertThat(ImmutableList.copyOf(Newlines.lineOffsetIterator("foo\r\nbar")))
        .containsExactly(0, 5);
  }