[Xtext] fixed 363914 - Check that you cannot append a null segment to a

QualifiedName
This commit is contained in:
Moritz Eysholdt 2011-11-28 14:19:16 +01:00
parent a69606b307
commit 2f0d40663d
2 changed files with 10 additions and 0 deletions

View file

@ -95,6 +95,9 @@ public class QualifiedName implements Comparable<QualifiedName> {
}
public QualifiedName append(String segment) {
if (segment == null) {
throw new IllegalArgumentException("Segment cannot be null");
}
String[] newSegments = new String[getSegmentCount() + 1];
System.arraycopy(segments, 0, newSegments, 0, segments.length);
newSegments[segments.length] = segment;

View file

@ -25,6 +25,13 @@ public class QualifiedNameTest extends TestCase {
fail("Exception expected");
} catch(IllegalArgumentException e) {}
}
public void testAppendNull() {
try {
QualifiedName.create().append((String) null);
fail("Exception expected");
} catch (IllegalArgumentException e) {}
}
public void testSegments() {
QualifiedName qn = QualifiedName.create("foo", "bar", "baz");