diff options
| author | Ulf Jasper | 2014-10-28 21:33:12 +0100 |
|---|---|---|
| committer | Ulf Jasper | 2014-10-28 21:33:12 +0100 |
| commit | 45f0de5a7123f5f50ba858902b240b1cdb604e44 (patch) | |
| tree | 4898de9cc006d9672f5baccb081296f5289fba5f | |
| parent | 48ec7450255fe77ea17191c607d87e4335e17c8a (diff) | |
| download | emacs-45f0de5a7123f5f50ba858902b240b1cdb604e44.tar.gz emacs-45f0de5a7123f5f50ba858902b240b1cdb604e44.zip | |
xml.c:parse_region: Do not forget the first document child.
* src/xml.c (parse_region): Do not forget the first document child.
* test/automated/libxml-tests.el: New file.
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/xml.c | 2 | ||||
| -rw-r--r-- | test/ChangeLog | 4 | ||||
| -rw-r--r-- | test/automated/libxml-tests.el | 56 |
4 files changed, 65 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 64dabbbfadb..25009f8a310 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2014-10-28 Ulf Jasper <ulf.jasper@web.de> | ||
| 2 | |||
| 3 | * xml.c (parse_region): Do not forget the first document child. | ||
| 4 | |||
| 1 | 2014-10-25 Jan Djärv <jan.h.d@swipnet.se> | 5 | 2014-10-25 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 6 | ||
| 3 | * nsselect.m: pasteboard_changecount is new. | 7 | * nsselect.m: pasteboard_changecount is new. |
| @@ -216,7 +216,7 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html | |||
| 216 | { | 216 | { |
| 217 | /* If the document is just comments, then this should get us the | 217 | /* If the document is just comments, then this should get us the |
| 218 | nodes anyway. */ | 218 | nodes anyway. */ |
| 219 | xmlNode *n = doc->children->next; | 219 | xmlNode *n = doc->children; |
| 220 | Lisp_Object r = Qnil; | 220 | Lisp_Object r = Qnil; |
| 221 | 221 | ||
| 222 | while (n) { | 222 | while (n) { |
diff --git a/test/ChangeLog b/test/ChangeLog index fb19252cd34..86f8e240af4 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2014-10-28 Ulf Jasper <ulf.jasper@web.de> | ||
| 2 | |||
| 3 | * automated/libxml-tests.el: New file. | ||
| 4 | |||
| 1 | 2014-10-22 Noam Postavsky <npostavs@users.sourceforget.net> | 5 | 2014-10-22 Noam Postavsky <npostavs@users.sourceforget.net> |
| 2 | 6 | ||
| 3 | * test/automated/process-tests.el (process-test-quoted-batfile): | 7 | * test/automated/process-tests.el (process-test-quoted-batfile): |
diff --git a/test/automated/libxml-tests.el b/test/automated/libxml-tests.el new file mode 100644 index 00000000000..ced0df7b3c4 --- /dev/null +++ b/test/automated/libxml-tests.el | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | ;;; libxml-parse-tests.el --- Test suite for libxml parsing. | ||
| 2 | |||
| 3 | ;; Copyright (C) 2014 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Ulf Jasper <ulf.jasper@web.de> | ||
| 6 | ;; Keywords: internal | ||
| 7 | ;; Human-Keywords: internal | ||
| 8 | |||
| 9 | ;; This file is part of GNU Emacs. | ||
| 10 | |||
| 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 12 | ;; it under the terms of the GNU General Public License as published by | ||
| 13 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 14 | ;; (at your option) any later version. | ||
| 15 | |||
| 16 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 19 | ;; GNU General Public License for more details. | ||
| 20 | |||
| 21 | ;; You should have received a copy of the GNU General Public License | ||
| 22 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 23 | |||
| 24 | ;;; Commentary: | ||
| 25 | |||
| 26 | ;;; Code: | ||
| 27 | |||
| 28 | (require 'ert) | ||
| 29 | |||
| 30 | (defvar libxml-tests--data | ||
| 31 | `(;; simple case | ||
| 32 | ("<?xml version=\"1.0\"?><foo baz=\"true\">bar</foo>" | ||
| 33 | . (foo ((baz . "true")) "bar")) | ||
| 34 | ;; toplevel comments -- first document child must not get lost | ||
| 35 | (,(concat "<?xml version=\"1.0\"?><foo>bar</foo><!--comment-1-->" | ||
| 36 | "<!--comment-2-->") | ||
| 37 | . (top nil (foo nil "bar") (comment nil "comment-1") | ||
| 38 | (comment nil "comment-2"))) | ||
| 39 | (,(concat "<?xml version=\"1.0\"?><!--comment-a--><foo a=\"b\">" | ||
| 40 | "<bar>blub</bar></foo><!--comment-b--><!--comment-c-->") | ||
| 41 | . (top nil (comment nil "comment-a") (foo ((a . "b")) (bar nil "blub")) | ||
| 42 | (comment nil "comment-b") (comment nil "comment-c")))) | ||
| 43 | "Alist of XML strings and their expected parse trees.") | ||
| 44 | |||
| 45 | |||
| 46 | (ert-deftest libxml-tests () | ||
| 47 | "Test libxml." | ||
| 48 | (when (fboundp 'libxml-parse-xml-region) | ||
| 49 | (with-temp-buffer | ||
| 50 | (dolist (test libxml-tests--data) | ||
| 51 | (erase-buffer) | ||
| 52 | (insert (car test)) | ||
| 53 | (should (equal (cdr test) | ||
| 54 | (libxml-parse-xml-region (point-min) (point-max)))))))) | ||
| 55 | |||
| 56 | ;;; libxml-tests.el ends here | ||