X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Firc%2Futil%2FMessageCleanerTest.java;h=986cbad38c0a825ed5fa7736f99bd368f6dfbc14;hb=0c607fe61d662a15fb9b6368a7f32b92a694096a;hp=bbbf5071b2d98940994f5783bd8dfa571cc9d9f8;hpb=a03a8ed8d6dec72ce7b95aaa74d7043cacec65b5;p=xudocci.git diff --git a/src/test/java/net/pterodactylus/irc/util/MessageCleanerTest.java b/src/test/java/net/pterodactylus/irc/util/MessageCleanerTest.java index bbbf507..986cbad 100644 --- a/src/test/java/net/pterodactylus/irc/util/MessageCleanerTest.java +++ b/src/test/java/net/pterodactylus/irc/util/MessageCleanerTest.java @@ -28,6 +28,8 @@ import static net.pterodactylus.irc.util.MessageCleaner.getDefaultInstance; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import java.util.Collections; + import net.pterodactylus.irc.util.MessageCleaner.Attributes; import org.junit.Test; @@ -41,50 +43,71 @@ public class MessageCleanerTest { private final MessageCleaner messageCleaner = getDefaultInstance(); - /** Tests removal of {@link Attributes#bold} formatting. */ @Test - public void testRemoveBold() { - String clean = messageCleaner.clean("This contains \u0002bold\u0002 characters.", of(bold)); - assertThat(clean, is("This contains bold characters.")); - - clean = messageCleaner.clean("This contains \u0002bold\u0002 and \u00034color\u0003 characters.", of(bold)); - assertThat(clean, is("This contains bold and \u00034color\u0003 characters.")); + public void removeBoldFormatting() { + assertThat(messageCleaner.clean("Text\u0002bold", of(bold)), is("Textbold")); } - /** Tests removal of {@link Attributes#color} formatting. */ @Test - public void testRemoveColors() { - String clean = messageCleaner.clean("This contains \u0002bold\u0002 characters.", of(color)); - assertThat(clean, is("This contains \u0002bold\u0002 characters.")); - - clean = messageCleaner.clean("This contains \u0002bold\u0002 and \u00034color\u0003 characters.", of(color)); - assertThat(clean, is("This contains \u0002bold\u0002 and color characters.")); - - clean = messageCleaner.clean("This contains \u00034,12colorful \u00039,18shit and \u000328stuff\u0003 and characters.", of(color)); - assertThat(clean, is("This contains colorful 8shit and 8stuff and characters.")); + public void boldFormattingIsNotRemovedUnwanted() { + assertThat(messageCleaner.clean("Text\u0002bold", Collections.emptySet()), is("Text\u0002bold")); } - /** Tests removal of {@link Attributes#clear} formatting. */ @Test - public void testRemoveClear() { - String clean = messageCleaner.clean("This contains \u0002bold\u0002 and \u00034color\u0003 characters.", of(clear)); - assertThat(clean, is("This contains \u0002bold\u0002 and \u00034color\u0003 characters.")); - - clean = messageCleaner.clean("This contains \u0002bold\u0002 and \u00034color\u0003 and \u000fclear characters.", of(clear)); - assertThat(clean, is("This contains \u0002bold\u0002 and \u00034color\u0003 and clear characters.")); + public void removeColorFormatting() { + assertThat(messageCleaner.clean("Text\u0003!color", of(color)), is("Text!color")); + assertThat(messageCleaner.clean("Text\u0003color", of(color)), is("Textcolor")); + assertThat(messageCleaner.clean("Text\u00034color", of(color)), is("Textcolor")); + assertThat(messageCleaner.clean("Text\u00034!color", of(color)), is("Text!color")); + assertThat(messageCleaner.clean("Text\u000314color", of(color)), is("Textcolor")); + assertThat(messageCleaner.clean("Text\u000318color", of(color)), is("Text8color")); + assertThat(messageCleaner.clean("Text\u000399color", of(color)), is("Textcolor")); + assertThat(messageCleaner.clean("Text\u00031,!color", of(color)), is("Text!color")); + assertThat(messageCleaner.clean("Text\u00031,color", of(color)), is("Textcolor")); + assertThat(messageCleaner.clean("Text\u00031,1!color", of(color)), is("Text!color")); + assertThat(messageCleaner.clean("Text\u00031,1color", of(color)), is("Textcolor")); + assertThat(messageCleaner.clean("Text\u00031,14color", of(color)), is("Textcolor")); + assertThat(messageCleaner.clean("Text\u00031,18color", of(color)), is("Text8color")); + assertThat(messageCleaner.clean("Text\u00031,99color", of(color)), is("Textcolor")); + assertThat(messageCleaner.clean("Text\u000314,color", of(color)), is("Textcolor")); + assertThat(messageCleaner.clean("Text\u000314,1color", of(color)), is("Textcolor")); + assertThat(messageCleaner.clean("Text\u000314,14color", of(color)), is("Textcolor")); + assertThat(messageCleaner.clean("Text\u000314,18color", of(color)), is("Text8color")); + assertThat(messageCleaner.clean("Text\u000314,99color", of(color)), is("Textcolor")); + assertThat(messageCleaner.clean("Text\u000399,99color", of(color)), is("Textcolor")); + assertThat(messageCleaner.clean("Text\u000399,9color", of(color)), is("Textcolor")); + assertThat(messageCleaner.clean("Text\u00039color", of(color)), is("Textcolor")); + assertThat(messageCleaner.clean("Text\u00039,color", of(color)), is("Textcolor")); } - /** Tests removal of all formatting. */ @Test - public void testRemoveAll() { - String clean = messageCleaner.clean("This contains \u0002bold\u0002 and \u00034color\u0003 characters."); - assertThat(clean, is("This contains bold and color characters.")); + public void colorFormattingIsNotRemovedUnwanted() { + assertThat(messageCleaner.clean("Text\u00034color", Collections.emptySet()), is("Text\u00034color")); + assertThat(messageCleaner.clean("Text\u000314color", Collections.emptySet()), is("Text\u000314color")); + assertThat(messageCleaner.clean("Text\u000318color", Collections.emptySet()), is("Text\u000318color")); + assertThat(messageCleaner.clean("Text\u000399color", Collections.emptySet()), is("Text\u000399color")); + assertThat(messageCleaner.clean("Text\u00031,color", Collections.emptySet()), is("Text\u00031,color")); + assertThat(messageCleaner.clean("Text\u00031,1color", Collections.emptySet()), is("Text\u00031,1color")); + assertThat(messageCleaner.clean("Text\u00031,14color", Collections.emptySet()), is("Text\u00031,14color")); + assertThat(messageCleaner.clean("Text\u00031,18color", Collections.emptySet()), is("Text\u00031,18color")); + assertThat(messageCleaner.clean("Text\u00031,99color", Collections.emptySet()), is("Text\u00031,99color")); + assertThat(messageCleaner.clean("Text\u000314,color", Collections.emptySet()), is("Text\u000314,color")); + assertThat(messageCleaner.clean("Text\u000314,1color", Collections.emptySet()), is("Text\u000314,1color")); + assertThat(messageCleaner.clean("Text\u000314,14color", Collections.emptySet()), is("Text\u000314,14color")); + assertThat(messageCleaner.clean("Text\u000314,18color", Collections.emptySet()), is("Text\u000314,18color")); + assertThat(messageCleaner.clean("Text\u000314,99color", Collections.emptySet()), is("Text\u000314,99color")); + assertThat(messageCleaner.clean("Text\u000399,99color", Collections.emptySet()), is("Text\u000399,99color")); + assertThat(messageCleaner.clean("Text\u00039color", Collections.emptySet()), is("Text\u00039color")); + } - clean = messageCleaner.clean("This contains \u00034,12colorful \u00039,18shit and \u000328stuff\u0003 and characters."); - assertThat(clean, is("This contains colorful 8shit and 8stuff and characters.")); + @Test + public void removeClearFormatting() { + assertThat(messageCleaner.clean("Text\u000fclear", of(clear)), is("Textclear")); + } - clean = messageCleaner.clean("This contains \u0002bold\u0002 and \u00034color\u0003 and \u000fclear characters."); - assertThat(clean, is("This contains bold and color and clear characters.")); + @Test + public void clearFormattingIsNotRemovedUnwanted() { + assertThat(messageCleaner.clean("Text\u000fclear", Collections.emptySet()), is("Text\u000fclear")); } @Test @@ -93,13 +116,28 @@ public class MessageCleanerTest { } @Test + public void underlineFormattingIsNotRemovedUnwanted() { + assertThat(messageCleaner.clean("Text\u001funderline", Collections.emptySet()), is("Text\u001funderline")); + } + + @Test public void removeReverseFormatting() { assertThat(messageCleaner.clean("Text\u0016reverse", of(reverse)), is("Textreverse")); } @Test + public void reverseFormattingIsNotRemovedUnwanted() { + assertThat(messageCleaner.clean("Text\u0016reverse", Collections.emptySet()), is("Text\u0016reverse")); + } + + @Test public void removeItalicFormatting() { assertThat(messageCleaner.clean("Text\u001ditalics", of(italics)), is("Textitalics")); } + @Test + public void italicFormattingIsNotRemovedUnwanted() { + assertThat(messageCleaner.clean("Text\u001ditalics", Collections.emptySet()), is("Text\u001ditalics")); + } + }