use of org.eclipse.wst.sse.core.tests.util.Accessor in project webtools.sourceediting by eclipse.
the class TestRegionList method test_indexOf.
public void test_indexOf() {
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]));
}
use of org.eclipse.wst.sse.core.tests.util.Accessor in project webtools.sourceediting by eclipse.
the class TestRegionList method test_getOver.
public void test_getOver() {
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));
ArrayIndexOutOfBoundsException e = null;
try {
impl.get(impl.size());
} catch (ArrayIndexOutOfBoundsException e2) {
e = e2;
}
assertNotNull("no ArrayIndexOutOfBoundsException thrown when expected", e);
}
use of org.eclipse.wst.sse.core.tests.util.Accessor in project webtools.sourceediting by eclipse.
the class TestRegionList method test_removeByObject.
public void test_removeByObject() {
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(regions[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_getUnder.
public void test_getUnder() {
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));
ArrayIndexOutOfBoundsException e = null;
try {
impl.get(-1);
} catch (ArrayIndexOutOfBoundsException e2) {
e = e2;
}
assertNotNull("no ArrayIndexOutOfBoundsException thrown when expected", e);
}
use of org.eclipse.wst.sse.core.tests.util.Accessor in project webtools.sourceediting by eclipse.
the class TestRegionList method test_iterator2.
public void test_iterator2() {
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, 1, 1, 1));
assertTrue("region not added", added);
assertEquals("count was wrong", 2, 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", 3, new Accessor(impl, TextRegionListImpl.class).getInt("fRegionsCount"));
Iterator it = null;
assertNotNull("no iterator returned", it = (Iterator) new Accessor(impl, TextRegionListImpl.class).invoke("iterator", new Object[0]));
assertTrue(it.hasNext());
assertNotNull(it.next());
assertNotNull(it.next());
assertNotNull(it.next());
assertFalse(it.hasNext());
}
Aggregations