Detect component loops

This commit is contained in:
Thinkofdeath
2014-02-21 10:13:03 +00:00
parent e87d25c321
commit 941450b4e4
3 changed files with 37 additions and 1 deletions

View File

@@ -80,4 +80,22 @@ public class ComponentsTest
+ "World" + ChatColor.YELLOW + ChatColor.BOLD + "!", BaseComponent.toLegacyText( components ) );
}
@Test(expected = IllegalArgumentException.class)
public void testLoopSimple() {
TextComponent component = new TextComponent( "Testing" );
component.addExtra( component );
ComponentSerializer.toString( component );
}
@Test(expected = IllegalArgumentException.class)
public void testLoopComplex() {
TextComponent a = new TextComponent( "A" );
TextComponent b = new TextComponent( "B" );
TextComponent c = new TextComponent( "C" );
a.addExtra( b );
b.addExtra( c );
c.addExtra( a );
ComponentSerializer.toString( a );
}
}