use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.
the class ProjectionDocumentTest method test29_33.
@Test
public void test29_33() {
// test computation of unprojected master regions
// spanning multiple fragments
// starting right of fragment
// ending touching left fragment border
IRegion[] expected = { new Region(50, 10), new Region(80, 20), new Region(120, 20) };
assertUnprojectedMasterRegions(expected, 50, 90);
}
use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.
the class ProjectionDocumentTest method test29_30.
@Test
public void test29_30() {
// test computation of unprojected master regions
// spanning multiple fragments
// starting touching right fragment border
// ending touching right fragment border
IRegion[] expected = { new Region(40, 20), new Region(80, 20), new Region(120, 20) };
assertUnprojectedMasterRegions(expected, 40, 120);
}
use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.
the class ProjectionDocumentTest method test29_19.
@Test
public void test29_19() {
// test computation of unprojected master regions
// spanning multiple fragments
// starting touching left fragment border
// ending inside fragment
IRegion[] expected = { new Region(80, 20) };
assertUnprojectedMasterRegions(expected, 60, 50);
}
use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.
the class ProjectionMappingTest method test11g.
@Test
public void test11g() {
// test toExactOriginRegions
// test a region starting in the middle of a segment and ending in the middle of another fragment
createStandardProjection();
try {
IRegion[] actual = fProjectionMapping.toExactOriginRegions(new Region(10, 20));
IRegion[] expected = new IRegion[] { new Region(30, 10), new Region(60, 10) };
assertRegions(expected, actual);
} catch (BadLocationException e) {
assertTrue(false);
}
}
use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.
the class ProjectionMappingTest method test8b.
@Test
public void test8b() {
// test toImageRegion
createStandardProjection();
try {
// test a region contained by a fragment
IRegion imageRegion = fProjectionMapping.toClosestImageRegion(new Region(25, 10));
assertEquals(new Region(5, 10), imageRegion);
// test region of length 0
imageRegion = fProjectionMapping.toClosestImageRegion(new Region(25, 0));
assertEquals(new Region(5, 0), imageRegion);
// test a complete fragment
imageRegion = fProjectionMapping.toClosestImageRegion(new Region(20, 20));
assertEquals(new Region(0, 20), imageRegion);
// test a region spanning multiple fragments incompletely
imageRegion = fProjectionMapping.toClosestImageRegion(new Region(25, 50));
assertEquals(new Region(5, 30), imageRegion);
// test a region spanning multiple fragments completely
imageRegion = fProjectionMapping.toClosestImageRegion(new Region(20, 60));
assertEquals(new Region(0, 40), imageRegion);
// test a region non overlapping with a fragment
imageRegion = fProjectionMapping.toClosestImageRegion(new Region(45, 10));
assertEquals(new Region(20, 0), imageRegion);
// test a zero-length region at the end of the last fragment
imageRegion = fProjectionMapping.toClosestImageRegion(new Region(80, 0));
assertEquals(new Region(40, 0), imageRegion);
// test a region at the end of the last fragment
imageRegion = fProjectionMapping.toClosestImageRegion(new Region(80, 10));
assertEquals(new Region(40, 0), imageRegion);
// test a region before the first fragment
imageRegion = fProjectionMapping.toClosestImageRegion(new Region(10, 5));
assertEquals(new Region(0, 0), imageRegion);
// test a region surrounded by two fragments
imageRegion = fProjectionMapping.toClosestImageRegion(new Region(40, 20));
assertEquals(new Region(20, 0), imageRegion);
// test a region starting in a fragment and ending outside a fragment
imageRegion = fProjectionMapping.toClosestImageRegion(new Region(25, 30));
assertEquals(new Region(5, 15), imageRegion);
// test a region starting outside a fragment and ending inside a fragment
imageRegion = fProjectionMapping.toClosestImageRegion(new Region(45, 30));
assertEquals(new Region(20, 15), imageRegion);
// test a region starting outside a fragment and ending outside a fragment (covering one)
imageRegion = fProjectionMapping.toClosestImageRegion(new Region(45, 50));
assertEquals(new Region(20, 20), imageRegion);
// test a region starting outside a fragment and ending outside a fragment (covering two)
imageRegion = fProjectionMapping.toClosestImageRegion(new Region(15, 70));
assertEquals(new Region(0, 40), imageRegion);
} catch (BadLocationException e) {
assertTrue(false);
}
}
Aggregations