Correct component loop detector

This commit is contained in:
Thinkofdeath
2014-02-21 20:56:10 +00:00
parent 941450b4e4
commit 38f12840ca
3 changed files with 89 additions and 63 deletions

View File

@@ -81,21 +81,50 @@ public class ComponentsTest
}
@Test(expected = IllegalArgumentException.class)
public void testLoopSimple() {
public void testLoopSimple()
{
TextComponent component = new TextComponent( "Testing" );
component.addExtra( component );
ComponentSerializer.toString( component );
}
@Test(expected = IllegalArgumentException.class)
public void testLoopComplex() {
public void testLoopComplex()
{
TextComponent a = new TextComponent( "A" );
TextComponent b = new TextComponent( "B" );
b.setColor( ChatColor.AQUA );
TextComponent c = new TextComponent( "C" );
c.setColor( ChatColor.RED );
a.addExtra( b );
b.addExtra( c );
c.addExtra( a );
ComponentSerializer.toString( a );
}
@Test
public void testRepeated()
{
TextComponent a = new TextComponent( "A" );
TextComponent b = new TextComponent( "B" );
b.setColor( ChatColor.AQUA );
a.addExtra( b );
a.addExtra( b );
ComponentSerializer.toString( a );
}
@Test(expected = IllegalArgumentException.class)
public void testRepeatedError()
{
TextComponent a = new TextComponent( "A" );
TextComponent b = new TextComponent( "B" );
b.setColor( ChatColor.AQUA );
TextComponent c = new TextComponent( "C" );
c.setColor( ChatColor.RED );
a.addExtra( b );
a.addExtra( c );
c.addExtra( a );
a.addExtra( b );
ComponentSerializer.toString( a );
}
}