Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2020-01-03 11:48:16 +0000
committerPaul Pazderski2020-01-06 08:27:08 +0000
commit9fae9caf849cc3428e20a680145072eb0372c891 (patch)
tree3091ffa030b6dba90caef2a1359e2a273bdea55a /org.eclipse.jface.text.tests
parent9053ccf04b5d2e8bee7ed04a49a1153d540e2237 (diff)
downloadeclipse.platform.text-9fae9caf849cc3428e20a680145072eb0372c891.tar.gz
eclipse.platform.text-9fae9caf849cc3428e20a680145072eb0372c891.tar.xz
eclipse.platform.text-9fae9caf849cc3428e20a680145072eb0372c891.zip
Bug 558781 - TextPresentation iterator catches wrong exception
Change-Id: Ie50c2216c58656079ad00fd8938d03818e5a385b Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
Diffstat (limited to 'org.eclipse.jface.text.tests')
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java
index 41289bb46f2..8e70ca0c028 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java
@@ -16,10 +16,12 @@ package org.eclipse.jface.text.tests;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
+import java.util.NoSuchElementException;
import org.junit.After;
import org.junit.Before;
@@ -1250,6 +1252,29 @@ public class TextPresentationTest {
shell.dispose();
}
}
+
+ @Test
+ public void testIterator() {
+ // Test read over iterator end
+ Iterator<StyleRange> e= fTextPresentation.getAllStyleRangeIterator();
+ try {
+ for (int i= 0; i < 1000; i++) {
+ e.next();
+ }
+ fail("Iterator has no end.");
+ } catch (NoSuchElementException ex) {
+ // expected
+ }
+ e= fTextPresentation.getNonDefaultStyleRangeIterator();
+ try {
+ for (int i= 0; i < 1000; i++) {
+ e.next();
+ }
+ fail("Iterator has no end.");
+ } catch (NoSuchElementException ex) {
+ // expected
+ }
+ }
// helper method required as long as TextPresentation methods manipulate given arguments
private static StyleRange[] deepClone(StyleRange[] original) {

Back to the top