mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 08:48:55 +00:00
[Xtext] fixed 363914 - Check that you cannot append a null segment to a
QualifiedName
This commit is contained in:
parent
a69606b307
commit
2f0d40663d
2 changed files with 10 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue