### Question:
TextSegment { public Line getLineAtOffset(int textOffset) { int documentOffset = offsetOf(textOffset); Line previous = null; for (Line line : lines) { if (line.getOffset() > documentOffset) { break; } previous = line; } return requireNonNull(previous); } TextSegment(Iterable<Line> lines); String getText(); List<Line> getLines(); int offsetOf(int textOffset); int toTextOffset(int documentOffset); @Override String toString(); Line getLineAtOffset(int textOffset);  }### Answer:
@Test public void getLineAtOffset() { ImmutableList<Line> lines = ImmutableList.of(new Line(1, 10, "abc"), new Line(2, 15, "def")); TextSegment segment = new TextSegment(lines); assertEquals(lines.get(0), segment.getLineAtOffset(0)); assertEquals(lines.get(0), segment.getLineAtOffset(3)); assertEquals(lines.get(1), segment.getLineAtOffset(4)); assertEquals(lines.get(1), segment.getLineAtOffset(6)); }