diff options
author | David Engster <dengste@eml.cc> | 2012-07-29 21:57:28 +0200 |
---|---|---|
committer | David Engster <dengste@eml.cc> | 2012-07-29 21:57:28 +0200 |
commit | c91562a619ba72b93196791a519e6481ff633fc1 (patch) | |
tree | ecb523323ec27c1f40a223353f38f79edad8178f /test | |
parent | 9052f9f01ea219b9e9819b3cb3c6bfd9a6751460 (diff) | |
download | emacs-c91562a619ba72b93196791a519e6481ff633fc1.tar.gz |
New tests for XML name expansion.
* automated/xml-parse-tests.el (xml-parse-tests--qnames): New
variable to hold test data for name expansion.
(xml-parse-tests): Test the two different types of name expansion.
Diffstat (limited to 'test')
-rw-r--r-- | test/ChangeLog | 6 | ||||
-rw-r--r-- | test/automated/xml-parse-tests.el | 43 |
2 files changed, 48 insertions, 1 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 54030e210ed..03d43d72b54 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,9 @@ +2012-07-29 David Engster <deng@randomsample.de> + + * automated/xml-parse-tests.el (xml-parse-tests--qnames): New + variable to hold test data for name expansion. + (xml-parse-tests): Test the two different types of name expansion. + 2012-07-29 Juri Linkov <juri@jurta.org> * automated/occur-tests.el (occur-test-case): Use predefined diff --git a/test/automated/xml-parse-tests.el b/test/automated/xml-parse-tests.el index e6553060345..35009ed36a2 100644 --- a/test/automated/xml-parse-tests.el +++ b/test/automated/xml-parse-tests.el @@ -74,6 +74,25 @@ "<f¿>abc</f¿>") "List of XML strings that should signal an error in the parser") +(defvar xml-parse-tests--qnames + '( ;; Test data for name expansion + ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><D:multistatus xmlns:D=\"DAV:\"><D:response><D:href>/calendar/events/</D:href><D:propstat><D:status>HTTP/1.1 200 OK</D:status></D:propstat></D:response></D:multistatus>" + ;; Result with qnames as cons + ((("DAV:" . "multistatus") + ((("http://www.w3.org/2000/xmlns/" . "D") . "DAV:")) + (("DAV:" . "response") nil (("DAV:" . "href") nil "/calendar/events/") + (("DAV:" . "propstat") nil (("DAV:" . "status") nil "HTTP/1.1 200 OK"))))) + ;; Result with qnames as symbols + ((DAV:multistatus + ((("http://www.w3.org/2000/xmlns/" . "D") . "DAV:")) + (DAV:response nil (DAV:href nil "/calendar/events/") + (DAV:propstat nil (DAV:status nil "HTTP/1.1 200 OK")))))) + ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><F:something>hi there</F:something>" + ((("FOOBAR:" . "something") nil "hi there")) + ((FOOBAR:something nil "hi there")))) + "List of strings which are parsed using namespace expansion. +Parser is called with and without 'symbol-qnames argument.") + (ert-deftest xml-parse-tests () "Test XML parsing." (with-temp-buffer @@ -85,7 +104,29 @@ (dolist (test xml-parse-tests--bad-data) (erase-buffer) (insert test) - (should-error (xml-parse-region)))))) + (should-error (xml-parse-region)))) + (let ((testdata (car xml-parse-tests--qnames))) + (erase-buffer) + (insert (car testdata)) + (should (equal (nth 1 testdata) + (xml-parse-region nil nil nil nil t))) + (should (equal (nth 2 testdata) + (xml-parse-region nil nil nil nil 'symbol-qnames)))) + (let ((testdata (nth 1 xml-parse-tests--qnames))) + (erase-buffer) + (insert (car testdata)) + ;; Provide additional namespace-URI mapping + (should (equal (nth 1 testdata) + (xml-parse-region + nil nil nil nil + (append xml-default-ns + '(("F" . "FOOBAR:")))))) + (should (equal (nth 2 testdata) + (xml-parse-region + nil nil nil nil + (cons 'symbol-qnames + (append xml-default-ns + '(("F" . "FOOBAR:")))))))))) ;; Local Variables: ;; no-byte-compile: t |