test-parse-message.lisp
 1 ;;;; $Id: test-parse-message.lisp 184 2007-04-19 21:54:49Z ehuelsmann $
2 ;;;; $URL: file:///project/cl-irc/svn/tags/0.9.2/test/test-parse-message.lisp $
3
4 ;;;; See the LICENSE file for licensing information.
5
6 (in-package :cl-irc-test)
7
8 (defvar *msg1* (format nil ":kire!~~eenge@216.248.178.227 PRIVMSG cl-irc :heyhey!~A" #\Return))
9 (defvar *msg2* (format nil ":tolkien.freenode.net 372 cl-irc :-~A" #\Return))
10 (defvar *msg3* (format nil "NOTICE AUTH :*** Your forward and reverse DNS don't match~A" #\Return))
11 (defvar *msg4* (format nil ":kire_!~~eenge@adsl-156-35-240.asm.bellsouth.net MODE #lisppaste +k key~A" #\Return))
12 (defvar *msg5* (format nil ":kire_!~~eenge@adsl-156-35-240.asm.bellsouth.net MODE #lisppaste +bbb *!*@somewhere.com *!*@somewhereles.com *!*@youdontwannaknow.org~A" #\Return))
13 (defvar *msg6* (format nil ":kire!~~eenge@216.248.178.227 PRIVMSG cl-irc heyhey!~A" #\Return))
14 (defvar *msg7* (format nil ":ChanServ!ChanServ@services. MODE #lisppaste +o eh "))
15
16
17 (deftest find-reply-name.1 (irc:find-reply-name 1) :rpl_welcome)
18 (deftest find-reply-name.2
19 (handler-bind ((irc:no-such-reply #'continue))
20 (irc:find-reply-name 999)) :unknown-reply)
21
22 (deftest return-source.1 (irc::return-source cl-irc-test::*msg1*) 5 "kire")
23 (deftest return-source.2 (irc::return-source cl-irc-test::*msg2*) 21 "tolkien.freenode.net")
24 (deftest return-source.3 (irc::return-source cl-irc-test::*msg3*) 0 nil)
25 (deftest return-source.4 (irc::return-source cl-irc-test::*msg4*) 6 "kire_")
26 (deftest return-source.5 (irc::return-source cl-irc-test::*msg5*) 6 "kire_")
27
28 (deftest return-user.1 (irc::return-user cl-irc-test::*msg1* :start 5) 12 "~eenge")
29 (deftest return-user.2 (irc::return-user cl-irc-test::*msg2* :start 21) 21 nil)
30 (deftest return-user.3 (irc::return-user cl-irc-test::*msg3* :start 0) 0 nil)
31 (deftest return-user.4 (irc::return-user cl-irc-test::*msg4* :start 6) 13 "~eenge")
32 (deftest return-user.5 (irc::return-user cl-irc-test::*msg5* :start 6) 13 "~eenge")
33
34 (deftest return-host.1 (irc::return-host cl-irc-test::*msg1* :start 12) 28 "216.248.178.227")
35 (deftest return-host.2 (irc::return-host cl-irc-test::*msg2* :start 21) 21 nil)
36 (deftest return-host.3 (irc::return-host cl-irc-test::*msg3* :start 0) 0 nil)
37 (deftest return-host.4 (irc::return-host cl-irc-test::*msg4* :start 13) 47 "adsl-156-35-240.asm.bellsouth.net")
38 (deftest return-host.5 (irc::return-host cl-irc-test::*msg5* :start 13) 47 "adsl-156-35-240.asm.bellsouth.net")
39
40 (deftest return-command.1 (irc::return-command cl-irc-test::*msg1* :start 28) 36 "PRIVMSG")
41 (deftest return-command.2 (irc::return-command cl-irc-test::*msg2* :start 21) 25 "372")
42 (deftest return-command.3 (irc::return-command cl-irc-test::*msg3* :start 0) 6 "NOTICE")
43 (deftest return-command.4 (irc::return-command cl-irc-test::*msg4* :start 47) 52 "MODE")
44 (deftest return-command.5 (irc::return-command cl-irc-test::*msg5* :start 47) 52 "MODE")
45
46 (deftest return-arguments.1 (irc::return-arguments cl-irc-test::*msg1* :start 36) 44 ("cl-irc"))
47 (deftest return-arguments.2 (irc::return-arguments cl-irc-test::*msg2* :start 25) 33 ("cl-irc"))
48 (deftest return-arguments.3 (irc::return-arguments cl-irc-test::*msg3* :start 6) 12 ("AUTH"))
49 (deftest return-arguments.4 (irc::return-arguments cl-irc-test::*msg4* :start 52) 70 ("#lisppaste" "+k" "key"))
50 (deftest return-arguments.5 (irc::return-arguments cl-irc-test::*msg5* :start 52) 132 ("#lisppaste" "+bbb" "*!*@somewhere.com" "*!*@somewhereles.com" "*!*@youdontwannaknow.org"))
51
52 (deftest return-trailing-argument.1
53 (irc::return-trailing-argument cl-irc-test::*msg1* :start 44) 52 "heyhey!")
54 (deftest return-trailing-argument.2
55 (irc::return-trailing-argument cl-irc-test::*msg2* :start 33) 35 "-")
56 (deftest return-trailing-argument.3
57 (irc::return-trailing-argument cl-irc-test::*msg3* :start 12) 57 "*** Your forward and reverse DNS don't match")
58 (deftest return-trailing-argument.4
59 (irc::return-trailing-argument cl-irc-test::*msg4* :start 70) 70 nil)
60 (deftest return-trailing-argument.5
61 (irc::return-trailing-argument cl-irc-test::*msg5* :start 132) 132 nil)
62
63 (deftest parse-raw-message.1
64 (irc::parse-raw-message cl-irc-test::*msg1*)
65 "kire" "~eenge" "216.248.178.227" "PRIVMSG" ("cl-irc" "heyhey!"))
66
67 (deftest no-trailing.1
68 (irc::parse-raw-message *msg6*)
69 "kire" "~eenge" "216.248.178.227" "PRIVMSG" ("cl-irc" "heyhey!"))
70
71 (deftest mode.1
72 (irc::parse-raw-message *msg7*)
73 "ChanServ" "ChanServ" "services." "MODE" ("#lisppaste" "+o" "eh"))