Skip to content

Commit

Permalink
add test for getLineOffset()
Browse files Browse the repository at this point in the history
  • Loading branch information
koentsje committed Mar 27, 2014
1 parent 45a593b commit d893936
Showing 1 changed file with 14 additions and 1 deletion.
Expand Up @@ -10,9 +10,14 @@ public class DocumentImplTest {
private DocumentImpl documentImpl = new DocumentImpl();

private Document testDocument = new Document() {
@Override public int getLineOfOffset(int offset) throws BadLocationException {
@Override
public int getLineOfOffset(int offset) throws BadLocationException {
return offset < 10 ? offset : super.getLineOfOffset(offset);
}
@Override
public int getLineOffset(int line) throws BadLocationException {
return line < 5 ? line * 10 : super.getLineOffset(line);
}
};

@Test
Expand All @@ -39,4 +44,12 @@ public void testGetLineOfOffset() {
Assert.assertEquals(-1, documentImpl.getLineOfOffset(100));
}

@Test
public void testGetLineOffset() {
Assert.assertEquals(-1, documentImpl.getLineOffset(2));
documentImpl.delegateDocument = testDocument;
Assert.assertEquals(20, documentImpl.getLineOffset(2));
Assert.assertEquals(-1, documentImpl.getLineOffset(10));
}

}

0 comments on commit d893936

Please sign in to comment.