use of org.eclipse.wst.sse.core.tests.util.Accessor in project webtools.sourceediting by eclipse.
the class TestRegionList method test_removeAll.
public void test_removeAll() {
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", 0, impl.indexOf(regions[0]));
assertEquals("wrong object", 1, impl.indexOf(regions[1]));
assertEquals("wrong object", 2, impl.indexOf(regions[2]));
TextRegionListImpl impl2 = new TextRegionListImpl();
impl2.add(regions[0]);
impl2.add(regions[1]);
impl2.add(regions[2]);
impl.removeAll(impl2);
assertEquals("count was wrong", 0, new Accessor(impl, TextRegionListImpl.class).getInt("fRegionsCount"));
}
use of org.eclipse.wst.sse.core.tests.util.Accessor in project webtools.sourceediting by eclipse.
the class TestRegionList method test_removeByPosition.
public void test_removeByPosition() {
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", 0, impl.indexOf(regions[0]));
assertEquals("wrong object", 1, impl.indexOf(regions[1]));
assertEquals("wrong object", 2, impl.indexOf(regions[2]));
impl.remove(1);
Iterator it = null;
assertNotNull("no iterator returned", it = (Iterator) new Accessor(impl, TextRegionListImpl.class).invoke("iterator", new Object[0]));
assertTrue(it.hasNext());
assertEquals(regions[0], it.next());
assertEquals(regions[2], it.next());
assertFalse(it.hasNext());
}
use of org.eclipse.wst.sse.core.tests.util.Accessor in project webtools.sourceediting by eclipse.
the class TestRegionList method test_isEmpty.
public void test_isEmpty() {
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", true, impl.isEmpty());
}
use of org.eclipse.wst.sse.core.tests.util.Accessor in project webtools.sourceediting by eclipse.
the class TestRegionList method test_trimToSize1.
public void test_trimToSize1() {
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, impl.size());
added = impl.add(regions[1] = new ContextRegion(REGION_TYPE, 1, 1, 1));
assertTrue("region not added", added);
assertEquals("count was wrong", 2, impl.size());
added = impl.add(regions[2] = new ContextRegion(REGION_TYPE, 2, 1, 1));
assertTrue("region not added", added);
assertEquals("count was wrong", 3, impl.size());
impl.remove(0);
impl.remove(0);
assertEquals("count was wrong", 1, new Accessor(impl, TextRegionListImpl.class).getInt("fRegionsCount"));
impl.trimToSize();
assertEquals("count was wrong", 1, new Accessor(impl, TextRegionListImpl.class).getInt("fRegionsCount"));
assertEquals("not trimmed", 1, ((Object[]) new Accessor(impl, TextRegionListImpl.class).get("fRegions")).length);
}
use of org.eclipse.wst.sse.core.tests.util.Accessor in project webtools.sourceediting by eclipse.
the class TestRegionList method test_add.
public void test_add() {
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"));
}
Aggregations