X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Firc%2FReplyTest.java;fp=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Firc%2FReplyTest.java;h=9d84c549f15c4e2e5ec4f7612097d827cd1dc838;hb=74e56181fe0578d1371401d718af93131b87b9bc;hp=0000000000000000000000000000000000000000;hpb=fd8d1078c1847cbc8024521349e63b6cef39bfcc;p=xudocci.git diff --git a/src/test/java/net/pterodactylus/irc/ReplyTest.java b/src/test/java/net/pterodactylus/irc/ReplyTest.java new file mode 100644 index 0000000..9d84c54 --- /dev/null +++ b/src/test/java/net/pterodactylus/irc/ReplyTest.java @@ -0,0 +1,56 @@ +/* + * XdccDownloader - ReplyTest.java - Copyright © 2013 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.irc; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; + +import com.google.common.base.Optional; +import org.testng.annotations.Test; + +/** + * Tests for {@link Reply}. + * + * @author David ‘Bombe’ Roden + */ +public class ReplyTest { + + @Test + public void testParser() { + Reply reply; + + reply = Reply.parseLine("NOTICE AUTH :*** Processing your connection"); + assertThat(reply, notNullValue()); + assertThat(reply.source(), is(Optional.absent())); + assertThat(reply.command(), is("NOTICE")); + assertThat(reply.parameters(), hasSize(2)); + assertThat(reply.parameters().get(0), is("AUTH")); + assertThat(reply.parameters().get(1), is("*** Processing your connection")); + + reply = Reply.parseLine(":ParaDMON!services@paraphysics.services PRIVMSG QshelTier :\u0001VERSION\u0001"); + assertThat(reply, notNullValue()); + assertThat(reply.source(), is(Optional.of("ParaDMON!services@paraphysics.services"))); + assertThat(reply.command(), is("PRIVMSG")); + assertThat(reply.parameters(), hasSize(2)); + assertThat(reply.parameters().get(0), is("QshelTier")); + assertThat(reply.parameters().get(1), is("\u0001VERSION\u0001")); + } + +}