1 ;;; libxml-parse-tests.el --- Test suite for libxml parsing.
3 ;; Copyright (C) 2014-2015 Free Software Foundation, Inc.
5 ;; Author: Ulf Jasper <ulf.jasper@web.de>
7 ;; Human-Keywords: internal
9 ;; This file is part of GNU Emacs.
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.
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.
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/>.
30 (defvar libxml-tests--data-comments-preserved
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-->"
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 for preserved comments.")
45 (defvar libxml-tests--data-comments-discarded
47 ("<?xml version=\"1.0\"?><foo baz=\"true\">bar</foo>"
48 .
(foo ((baz .
"true")) "bar"))
49 ;; toplevel comments -- first document child must not get lost
50 (,(concat "<?xml version=\"1.0\"?><foo>bar</foo><!--comment-1-->"
53 (,(concat "<?xml version=\"1.0\"?><!--comment-a--><foo a=\"b\">"
54 "<bar>blub</bar></foo><!--comment-b--><!--comment-c-->")
55 .
(foo ((a .
"b")) (bar nil
"blub"))))
56 "Alist of XML strings and their expected parse trees for discarded comments.")
59 (ert-deftest libxml-tests
()
61 (when (fboundp 'libxml-parse-xml-region
)
63 (dolist (test libxml-tests--data-comments-preserved
)
66 (should (equal (cdr test
)
67 (libxml-parse-xml-region (point-min) (point-max)))))
68 (dolist (test libxml-tests--data-comments-discarded
)
71 (should (equal (cdr test
)
72 (libxml-parse-xml-region (point-min) (point-max) nil t
)))))))
74 ;;; libxml-tests.el ends here