]> git.eshelyaron.com Git - emacs.git/commitdiff
New tests for XML name expansion.
authorDavid Engster <dengste@eml.cc>
Sun, 29 Jul 2012 19:57:28 +0000 (21:57 +0200)
committerDavid Engster <dengste@eml.cc>
Sun, 29 Jul 2012 19:57:28 +0000 (21:57 +0200)
* 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.

test/ChangeLog
test/automated/xml-parse-tests.el

index 54030e210ede27251922b163817d4dee8583324a..03d43d72b543889dcbfdb1d8b408123727e87fc1 100644 (file)
@@ -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
index e65530603450f73bdf245dd2da928e420271f084..35009ed36a29dbe7a5fc33b08c2c6e024d537a57 100644 (file)
     "<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
       (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