mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-10-03 00:47:27 +02:00
e1553a3f25
Since Waterfall is now using Log4J for logging, these patches no longer have any effect.
80 lines
3.2 KiB
Diff
80 lines
3.2 KiB
Diff
From 7415b8f4ad505083d9dc0daa08dbc9d4601af26e Mon Sep 17 00:00:00 2001
|
|
From: Tux <write@imaginarycode.com>
|
|
Date: Thu, 19 May 2016 17:36:31 -0600
|
|
Subject: [PATCH] Better unit tests for Chat API
|
|
|
|
|
|
diff --git a/chat/src/test/java/net/md_5/bungee/api/chat/TranslatableComponentTest.java b/chat/src/test/java/net/md_5/bungee/api/chat/TranslatableComponentTest.java
|
|
index 0837c672..7d1ee8e7 100644
|
|
--- a/chat/src/test/java/net/md_5/bungee/api/chat/TranslatableComponentTest.java
|
|
+++ b/chat/src/test/java/net/md_5/bungee/api/chat/TranslatableComponentTest.java
|
|
@@ -3,6 +3,8 @@ package net.md_5.bungee.api.chat;
|
|
import org.junit.Test;
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
+import java.util.List;
|
|
+
|
|
public class TranslatableComponentTest
|
|
{
|
|
|
|
@@ -13,4 +15,25 @@ public class TranslatableComponentTest
|
|
assertEquals( "Test string with 2 placeholders: aoeu", testComponent.toPlainText() );
|
|
assertEquals( "§fTest string with §f2§f placeholders: §faoeu", testComponent.toLegacyText() );
|
|
}
|
|
+
|
|
+ @Test
|
|
+ public void testDuplicateNullWithDoesntThrowException() {
|
|
+ TranslatableComponent component = new TranslatableComponent("Test") {
|
|
+ @Override
|
|
+ public List<BaseComponent> getExtra() {
|
|
+ return null;
|
|
+ }
|
|
+ };
|
|
+
|
|
+ TranslatableComponent copy = new TranslatableComponent(component);
|
|
+ // The fact that we don't throw an exception means it's working as intended.
|
|
+ }
|
|
+
|
|
+ @Test
|
|
+ public void testEscapedPercentInPlainText()
|
|
+ {
|
|
+ TranslatableComponent testComponent = new TranslatableComponent( "Test string with %% sign" );
|
|
+ assertEquals( "Test string with % sign", testComponent.toPlainText() );
|
|
+ assertEquals( "§fTest string with §f%§f sign", testComponent.toLegacyText() );
|
|
+ }
|
|
}
|
|
diff --git a/proxy/src/test/java/net/md_5/bungee/chat/ComponentsTest.java b/proxy/src/test/java/net/md_5/bungee/chat/ComponentsTest.java
|
|
index 3d9396d3..c1afa6da 100644
|
|
--- a/proxy/src/test/java/net/md_5/bungee/chat/ComponentsTest.java
|
|
+++ b/proxy/src/test/java/net/md_5/bungee/chat/ComponentsTest.java
|
|
@@ -149,6 +149,26 @@ public class ComponentsTest
|
|
Assert.assertEquals( eventRetention[1].getClickEvent(), testClickEvent );
|
|
}
|
|
|
|
+ @Test
|
|
+ public void testBuilderSpecialFormatting()
|
|
+ {
|
|
+ BaseComponent[] components = new ComponentBuilder( "Hello " )
|
|
+ .bold(true).underlined(true).italic(true).strikethrough(true).obfuscated(true)
|
|
+ .append("World").underlined(false).strikethrough(false).create();
|
|
+
|
|
+ Assert.assertTrue( components[0].isBold() );
|
|
+ Assert.assertTrue( components[0].isUnderlined() );
|
|
+ Assert.assertTrue( components[0].isItalic() );
|
|
+ Assert.assertTrue( components[0].isStrikethrough() );
|
|
+ Assert.assertTrue( components[0].isObfuscated() );
|
|
+
|
|
+ Assert.assertTrue( components[1].isBold() );
|
|
+ Assert.assertFalse( components[1].isUnderlined() );
|
|
+ Assert.assertTrue( components[1].isItalic() );
|
|
+ Assert.assertFalse( components[1].isStrikethrough() );
|
|
+ Assert.assertTrue( components[1].isObfuscated() );
|
|
+ }
|
|
+
|
|
@Test(expected = IllegalArgumentException.class)
|
|
public void testLoopSimple()
|
|
{
|
|
--
|
|
2.14.1
|
|
|