Search in sources :

Example 6 with Accessor

use of org.eclipse.wst.sse.core.tests.util.Accessor in project webtools.sourceediting by eclipse.

the class TestRegionList method test_addAllToPosition.

public void test_addAllToPosition() {
    ITextRegion[] regions = new ITextRegion[3];
    TextRegionListImpl impl = new TextRegionListImpl();
    boolean added = impl.add(regions[0] = new ContextRegion(REGION_TYPE, 0, 1, 1));
    assertTrue("region not added", added);
    TextRegionListImpl impl2 = new TextRegionListImpl();
    added = impl2.add(regions[1] = new ContextRegion(REGION_TYPE, 1, 1, 1));
    assertTrue("region not added", added);
    added = impl2.add(regions[2] = new ContextRegion(REGION_TYPE, 2, 1, 1));
    assertTrue("region not added", added);
    added = impl.addAll(0, impl2);
    assertTrue("regions not added", added);
    assertEquals("count was wrong", 3, new Accessor(impl, TextRegionListImpl.class).getInt("fRegionsCount"));
    assertEquals("object was wrong", regions[1], ((ITextRegion[]) new Accessor(impl, TextRegionListImpl.class).get("fRegions"))[0]);
    assertEquals("object was wrong", regions[2], ((ITextRegion[]) new Accessor(impl, TextRegionListImpl.class).get("fRegions"))[1]);
    assertEquals("object was wrong", regions[0], ((ITextRegion[]) new Accessor(impl, TextRegionListImpl.class).get("fRegions"))[2]);
}
Also used : TextRegionListImpl(org.eclipse.wst.sse.core.internal.text.TextRegionListImpl) ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) ContextRegion(org.eclipse.wst.sse.core.internal.parser.ContextRegion) Accessor(org.eclipse.wst.sse.core.tests.util.Accessor)

Example 7 with Accessor

use of org.eclipse.wst.sse.core.tests.util.Accessor in project webtools.sourceediting by eclipse.

the class TestRegionList method test_add2.

public void test_add2() {
    TextRegionListImpl impl = new TextRegionListImpl();
    boolean added = impl.add(new ContextRegion(REGION_TYPE, 0, 1, 1));
    assertTrue("region not added", added);
    assertEquals("count was wrong", 1, new Accessor(impl, TextRegionListImpl.class).getInt("fRegionsCount"));
    added = impl.add(new ContextRegion(REGION_TYPE, 2, 1, 1));
    assertTrue("region not added", added);
    assertEquals("count was wrong", 2, new Accessor(impl, TextRegionListImpl.class).getInt("fRegionsCount"));
}
Also used : TextRegionListImpl(org.eclipse.wst.sse.core.internal.text.TextRegionListImpl) ContextRegion(org.eclipse.wst.sse.core.internal.parser.ContextRegion) Accessor(org.eclipse.wst.sse.core.tests.util.Accessor)

Example 8 with Accessor

use of org.eclipse.wst.sse.core.tests.util.Accessor in project webtools.sourceediting by eclipse.

the class TestRegionList method test_clear.

public void test_clear() {
    TextRegionListImpl impl = new TextRegionListImpl();
    boolean added = impl.add(new ContextRegion(REGION_TYPE, 0, 1, 1));
    assertTrue("region not added", added);
    assertEquals("count was wrong", 1, new Accessor(impl, TextRegionListImpl.class).getInt("fRegionsCount"));
    added = impl.add(new ContextRegion(REGION_TYPE, 2, 1, 1));
    assertTrue("region not added", added);
    assertEquals("count was wrong", 2, new Accessor(impl, TextRegionListImpl.class).getInt("fRegionsCount"));
    impl.clear();
    assertEquals("count was wrong", 0, new Accessor(impl, TextRegionListImpl.class).getInt("fRegionsCount"));
}
Also used : TextRegionListImpl(org.eclipse.wst.sse.core.internal.text.TextRegionListImpl) ContextRegion(org.eclipse.wst.sse.core.internal.parser.ContextRegion) Accessor(org.eclipse.wst.sse.core.tests.util.Accessor)

Example 9 with Accessor

use of org.eclipse.wst.sse.core.tests.util.Accessor in project webtools.sourceediting by eclipse.

the class TestRegionList method test_addAllToEmpty.

public void test_addAllToEmpty() {
    ITextRegion[] regions = new ITextRegion[3];
    TextRegionListImpl impl = new TextRegionListImpl();
    boolean added = impl.add(regions[0] = new ContextRegion(REGION_TYPE, 0, 1, 1));
    assertTrue("region not added", added);
    added = impl.add(regions[1] = new ContextRegion(REGION_TYPE, 1, 1, 1));
    assertTrue("region not added", added);
    added = impl.add(regions[2] = new ContextRegion(REGION_TYPE, 2, 1, 1));
    assertTrue("region not added", added);
    TextRegionListImpl impl2 = new TextRegionListImpl();
    added = impl2.addAll(0, impl);
    assertTrue("regions not added", added);
    assertEquals("count was wrong", 3, new Accessor(impl, TextRegionListImpl.class).getInt("fRegionsCount"));
    assertEquals("object was wrong", regions[0], ((ITextRegion[]) new Accessor(impl, TextRegionListImpl.class).get("fRegions"))[0]);
    assertEquals("object was wrong", regions[1], ((ITextRegion[]) new Accessor(impl, TextRegionListImpl.class).get("fRegions"))[1]);
    assertEquals("object was wrong", regions[2], ((ITextRegion[]) new Accessor(impl, TextRegionListImpl.class).get("fRegions"))[2]);
}
Also used : TextRegionListImpl(org.eclipse.wst.sse.core.internal.text.TextRegionListImpl) ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) ContextRegion(org.eclipse.wst.sse.core.internal.parser.ContextRegion) Accessor(org.eclipse.wst.sse.core.tests.util.Accessor)

Example 10 with Accessor

use of org.eclipse.wst.sse.core.tests.util.Accessor in project webtools.sourceediting by eclipse.

the class TestRegionList method test_get.

public void test_get() {
    ITextRegion[] regions = new ITextRegion[3];
    TextRegionListImpl impl = new TextRegionListImpl();
    boolean added = impl.add(regions[0] = new ContextRegion(REGION_TYPE, 0, 1, 1));
    assertTrue("region not added", added);
    assertEquals("count was wrong", 1, new Accessor(impl, TextRegionListImpl.class).getInt("fRegionsCount"));
    added = impl.add(regions[1] = new ContextRegion(REGION_TYPE, 1, 1, 1));
    assertTrue("region not added", added);
    assertEquals("count was wrong", 2, new Accessor(impl, TextRegionListImpl.class).getInt("fRegionsCount"));
    added = impl.add(regions[2] = new ContextRegion(REGION_TYPE, 2, 1, 1));
    assertTrue("region not added", added);
    assertEquals("count was wrong", 3, new Accessor(impl, TextRegionListImpl.class).getInt("fRegionsCount"));
    assertEquals("wrong object", regions[0], impl.get(0));
    assertEquals("wrong object", regions[1], impl.get(1));
    assertEquals("wrong object", regions[2], impl.get(2));
}
Also used : TextRegionListImpl(org.eclipse.wst.sse.core.internal.text.TextRegionListImpl) ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) ContextRegion(org.eclipse.wst.sse.core.internal.parser.ContextRegion) Accessor(org.eclipse.wst.sse.core.tests.util.Accessor)

Aggregations

TextRegionListImpl (org.eclipse.wst.sse.core.internal.text.TextRegionListImpl)18 Accessor (org.eclipse.wst.sse.core.tests.util.Accessor)18 ContextRegion (org.eclipse.wst.sse.core.internal.parser.ContextRegion)17 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)11 Iterator (java.util.Iterator)5