Merge unit tests
This commit is contained in:
parent
2d7c74eae5
commit
ca8f31bdc7
@ -191,4 +191,34 @@ public class ComponentsTest
|
|||||||
a.addExtra( b );
|
a.addExtra( b );
|
||||||
ComponentSerializer.toString( a );
|
ComponentSerializer.toString( a );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInvalidColorCodes()
|
||||||
|
{
|
||||||
|
StringBuilder allInvalidColorCodes = new StringBuilder();
|
||||||
|
|
||||||
|
// collect all invalid color codes (e.g. §z, §g, ...)
|
||||||
|
for ( char alphChar : "0123456789abcdefghijklmnopqrstuvwxyz".toCharArray() )
|
||||||
|
{
|
||||||
|
if ( ChatColor.ALL_CODES.indexOf( alphChar ) == -1 )
|
||||||
|
{
|
||||||
|
allInvalidColorCodes.append( ChatColor.COLOR_CHAR );
|
||||||
|
allInvalidColorCodes.append( alphChar );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// last char is a single '§'
|
||||||
|
allInvalidColorCodes.append( ChatColor.COLOR_CHAR );
|
||||||
|
|
||||||
|
String invalidColorCodesLegacyText = fromAndToLegacyText( allInvalidColorCodes.toString() );
|
||||||
|
String emptyLegacyText = fromAndToLegacyText( "" );
|
||||||
|
|
||||||
|
// all invalid color codes and the trailing '§' should be ignored
|
||||||
|
Assert.assertEquals( emptyLegacyText, invalidColorCodesLegacyText );
|
||||||
|
}
|
||||||
|
|
||||||
|
private String fromAndToLegacyText(String legacyText)
|
||||||
|
{
|
||||||
|
return BaseComponent.toLegacyText( TextComponent.fromLegacyText( legacyText ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
package net.md_5.bungee.api.chat;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import org.junit.Test;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class TextComponentTest
|
|
||||||
{
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testInvalidColorCodes()
|
|
||||||
{
|
|
||||||
StringBuilder allInvalidColorCodes = new StringBuilder();
|
|
||||||
|
|
||||||
// collect all invalid color codes (e.g. §z, §g, ...)
|
|
||||||
for ( char alphChar : "0123456789abcdefghijklmnopqrstuvwxyz".toCharArray() )
|
|
||||||
{
|
|
||||||
if ( ChatColor.ALL_CODES.indexOf( alphChar ) == -1 )
|
|
||||||
{
|
|
||||||
allInvalidColorCodes.append( ChatColor.COLOR_CHAR );
|
|
||||||
allInvalidColorCodes.append( alphChar );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// last char is a single '§'
|
|
||||||
allInvalidColorCodes.append( ChatColor.COLOR_CHAR );
|
|
||||||
|
|
||||||
String invalidColorCodesLegacyText = fromAndToLegacyText( allInvalidColorCodes.toString() );
|
|
||||||
String emptyLegacyText = fromAndToLegacyText( "" );
|
|
||||||
|
|
||||||
// all invalid color codes and the trailing '§' should be ignored
|
|
||||||
assertEquals( emptyLegacyText, invalidColorCodesLegacyText );
|
|
||||||
}
|
|
||||||
|
|
||||||
private String fromAndToLegacyText(String legacyText)
|
|
||||||
{
|
|
||||||
return BaseComponent.toLegacyText( TextComponent.fromLegacyText( legacyText ) );
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user