aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPeder O. Klingenberg2017-05-23 20:34:08 -0400
committerGlenn Morris2017-05-23 20:34:08 -0400
commit8f6550b38c8b467a8f26c63050bd842f4fdc0b1e (patch)
tree5c33e5238776ff33a2f7bb004eca88afffadcd3b /test
parentef9f5c672a8e248dd7bd682101c03feb2e527340 (diff)
downloademacs-8f6550b38c8b467a8f26c63050bd842f4fdc0b1e.tar.gz
emacs-8f6550b38c8b467a8f26c63050bd842f4fdc0b1e.zip
New dns-mode command for IPv6 address conversion
This converts IPv6 addresses to a format suitable for reverse lookup zone files. (Bug#26820) * lisp/textmodes/dns-mode.el (dns-mode-map, dns-mode-menu): Add dns-mode-ipv6-to-nibbles. (dns-mode-ipv6-to-nibbles, dns-mode-reverse-and-expand-ipv6): New functions. * test/lisp/dns-mode-tests.el: New file. ; * etc/NEWS: Mention this.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/dns-mode-tests.el58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/lisp/dns-mode-tests.el b/test/lisp/dns-mode-tests.el
new file mode 100644
index 00000000000..34e86201d82
--- /dev/null
+++ b/test/lisp/dns-mode-tests.el
@@ -0,0 +1,58 @@
1;;; dns-mode-tests.el --- Test suite for dns-mode -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2017 Free Software Foundation, Inc.
4
5;; Author: Peder O. Klingenberg <peder@klingenberg.no>
6;; Keywords: dns zone
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software: you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22
23;;; Code:
24
25(require 'ert)
26(require 'dns-mode)
27
28;;; IPv6 reverse zones
29(ert-deftest dns-mode-ipv6-conversion ()
30 (let ((address "2001:db8::42"))
31 (should (equal (dns-mode-reverse-and-expand-ipv6 address)
32 "2.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa. "))
33 (should (equal (dns-mode-reverse-and-expand-ipv6 address 32)
34 "8.b.d.0.1.0.0.2.ip6.arpa. "))
35 (should (equal (dns-mode-reverse-and-expand-ipv6 address -112)
36 "2.4.0.0 "))))
37
38(ert-deftest dns-mode-ipv6-text-replacement ()
39 (let ((address "2001:db8::42/32"))
40 (with-temp-buffer
41 ;; Conversion with point directly after address
42 (insert address)
43 (dns-mode-ipv6-to-nibbles nil)
44 (should (equal (buffer-string) "8.b.d.0.1.0.0.2.ip6.arpa. "))
45 ;; Kill ring contains the expected
46 (erase-buffer)
47 (yank)
48 (should (equal (buffer-string) address))
49 ;; Point at beginning of address (and prefix arg to command)
50 (goto-char (point-min))
51 (dns-mode-ipv6-to-nibbles t)
52 (should (equal (buffer-string) "2.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 "))
53 ;; Point separated from address by whitespace
54 (erase-buffer)
55 (insert address)
56 (insert " ")
57 (dns-mode-ipv6-to-nibbles nil)
58 (should (equal (buffer-string) "8.b.d.0.1.0.0.2.ip6.arpa. ")))))