Search in sources :

Example 11 with ChangeRegion

use of org.eclipse.jface.internal.text.revisions.ChangeRegion in project eclipse.platform.text by eclipse.

the class ChangeRegionTest method testHunkAtStart.

@Test
public void testHunkAtStart() throws Exception {
    ChangeRegion r;
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(12, 0, 2));
    RangeUtil.assertEqualSingleRange(new LineRange(14, 5), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(14, 5), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(12, -2, 0));
    RangeUtil.assertEqualSingleRange(new LineRange(12, 5), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(12, 5), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(12, -2, 1));
    RangeUtil.assertEqualSingleRange(new LineRange(13, 4), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(13, 4), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(12, 3, 0));
    RangeUtil.assertEqualSingleRange(new LineRange(15, 7), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(15, 7), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(12, 3, 2));
    RangeUtil.assertEqualSingleRange(new LineRange(17, 5), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(17, 5), r.getAdjustedCoverage());
}
Also used : Hunk(org.eclipse.jface.internal.text.revisions.Hunk) ChangeRegion(org.eclipse.jface.internal.text.revisions.ChangeRegion) LineRange(org.eclipse.jface.text.source.LineRange) Test(org.junit.Test)

Example 12 with ChangeRegion

use of org.eclipse.jface.internal.text.revisions.ChangeRegion in project eclipse.platform.text by eclipse.

the class ChangeRegionTest method testHunkRightBefore.

@Test
public void testHunkRightBefore() throws Exception {
    ChangeRegion r;
    r = new ChangeRegion(fRevision, new LineRange(12, 3));
    r.adjustTo(new Hunk(10, 0, 2));
    RangeUtil.assertEqualSingleRange(new LineRange(12, 3), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(12, 3), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 3));
    r.adjustTo(new Hunk(10, 2, 2));
    RangeUtil.assertEqualSingleRange(new LineRange(14, 3), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(14, 3), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 3));
    r.adjustTo(new Hunk(9, -3, 0));
    RangeUtil.assertEqualSingleRange(new LineRange(9, 3), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(9, 3), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 3));
    r.adjustTo(new Hunk(9, -1, 2));
    RangeUtil.assertEqualSingleRange(new LineRange(11, 3), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(11, 3), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 3));
    r.adjustTo(new Hunk(9, 3, 3));
    RangeUtil.assertEqualSingleRange(new LineRange(15, 3), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(15, 3), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 3));
    r.adjustTo(new Hunk(12, 3, 0));
    RangeUtil.assertEqualSingleRange(new LineRange(15, 3), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(15, 3), r.getAdjustedCoverage());
}
Also used : Hunk(org.eclipse.jface.internal.text.revisions.Hunk) ChangeRegion(org.eclipse.jface.internal.text.revisions.ChangeRegion) LineRange(org.eclipse.jface.text.source.LineRange) Test(org.junit.Test)

Aggregations

ChangeRegion (org.eclipse.jface.internal.text.revisions.ChangeRegion)12 LineRange (org.eclipse.jface.text.source.LineRange)11 Test (org.junit.Test)11 Hunk (org.eclipse.jface.internal.text.revisions.Hunk)10 Range (org.eclipse.jface.internal.text.revisions.Range)2 ArrayList (java.util.ArrayList)1 ILineRange (org.eclipse.jface.text.source.ILineRange)1