aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNoam Postavsky2019-06-16 13:48:56 -0400
committerNoam Postavsky2019-06-22 19:25:44 -0400
commitf46b16b9fb00d341f222422a9514f5bd62f29971 (patch)
treee42e73ce40e790018f6a3cdf88af5bb141fb1d8a /test
parent96ebbf44b076b165943caefc1bbb0ff4c0f12b6b (diff)
downloademacs-f46b16b9fb00d341f222422a9514f5bd62f29971.tar.gz
emacs-f46b16b9fb00d341f222422a9514f5bd62f29971.zip
Make rcirc parsing more RFC2812 compliant (Bug#36233)
Do continue to allow multiple spaces between arguments, even though that is technically not allowed by the RFC. * lisp/net/rcirc.el (rcirc-process-server-response-1): Fix parsing of arguments which contain colons. * test/lisp/net/rcirc-tests.el: New test.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/net/rcirc-tests.el52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/lisp/net/rcirc-tests.el b/test/lisp/net/rcirc-tests.el
new file mode 100644
index 00000000000..128cb2e7540
--- /dev/null
+++ b/test/lisp/net/rcirc-tests.el
@@ -0,0 +1,52 @@
1;;; rcirc-tests.el --- Tests for rcirc -*- lexical-binding:t -*-
2
3;; Copyright (C) 2019 Free Software Foundation, Inc.
4
5;; This program is free software: you can redistribute it and/or
6;; modify it under the terms of the GNU General Public License as
7;; published by the Free Software Foundation, either version 3 of the
8;; License, or (at your option) any later version.
9;;
10;; This program is distributed in the hope that it will be useful, but
11;; WITHOUT ANY WARRANTY; without even the implied warranty of
12;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13;; General Public License for more details.
14;;
15;; You should have received a copy of the GNU General Public License
16;; along with this program. If not, see `https://www.gnu.org/licenses/'.
17
18;;; Code:
19
20(require 'ert)
21(require 'rcirc)
22(require 'cl-lib)
23
24(defun rcirc-tests--parse-server-response (cmd text)
25 (cl-letf* ((received-args nil)
26 ((symbol-function (intern (concat "rcirc-handler-" cmd)))
27 (lambda (_process sender args text)
28 (setq received-args (list sender cmd args text))))
29 (rcirc-receive-message-functions nil)
30 (rcirc-trap-errors-flag nil))
31 (rcirc-process-server-response nil text)
32 received-args))
33
34(defmacro rcirc-tests--server-response-parse-should-be
35 (text expected-sender expected-cmd expected-args)
36 (declare (debug t))
37 (macroexp-let2* nil ((cmd expected-cmd))
38 `(should (equal (rcirc-tests--parse-server-response ,cmd ,text)
39 (list ,expected-sender ,cmd ,expected-args ,text)))))
40
41(ert-deftest rcirc-process-server-response ()
42 (rcirc-tests--server-response-parse-should-be
43 "MODE #cchan +kl a:b :999"
44 nil "MODE" '("#cchan" "+kl" "a:b" "999"))
45 (rcirc-tests--server-response-parse-should-be
46 "MODE #cchan +kl a:b 999"
47 nil "MODE" '("#cchan" "+kl" "a:b" "999"))
48 (rcirc-tests--server-response-parse-should-be
49 "MODE #cchan +kl :a:b"
50 nil "MODE" '("#cchan" "+kl" "a:b")))
51
52;;; rcirc-tests.el ends here