/** * Constructor. * * @param startOffs The starting offset in the document, inclusive. * @param endOffs The ending offset in the document, exclusive. * @throws IllegalArgumentException If <code>endOffs</code> is less than * <code>startOffs</code>, or either argument is less than zero. */ public DocumentRange(int startOffs, int endOffs) { set(startOffs, endOffs); }
@Test(expected = IllegalArgumentException.class) public void testSet_NegativeStart() throws Exception { new DocumentRange(1, 1).set(-1, 8); }
@Test(expected = IllegalArgumentException.class) public void testSet_NegativeEnd() throws Exception { new DocumentRange(1, 1).set(5, -2); }
@Test(expected = IllegalArgumentException.class) public void testSet_EndLessThanStart() throws Exception { new DocumentRange(1, 1).set(9, 8); }
/** * Constructor. * * @param startOffs The starting offset in the document, inclusive. * @param endOffs The ending offset in the document, exclusive. * @throws IllegalArgumentException If <code>endOffs</code> is less than * <code>startOffs</code>, or either argument is less than zero. */ public DocumentRange(int startOffs, int endOffs) { set(startOffs, endOffs); }
@Test public void testGetEndOffset() { DocumentRange range = new DocumentRange(5, 8); Assert.assertEquals(8, range.getEndOffset()); range.set(1, 2); Assert.assertEquals(2, range.getEndOffset()); }
@Test public void testGetStartOffset() { DocumentRange range = new DocumentRange(5, 8); Assert.assertEquals(5, range.getStartOffset()); range.set(9, 12); Assert.assertEquals(9, range.getStartOffset()); }
@Test public void testSet_HappyPath() { DocumentRange range = new DocumentRange(1, 1); range.set(5, 8); Assert.assertEquals(5, range.getStartOffset()); Assert.assertEquals(8, range.getEndOffset()); }