[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 21c8997 4/5: Add more shr HTML rendering tests
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master 21c8997 4/5: Add more shr HTML rendering tests |
Date: |
Sun, 20 Mar 2016 12:43:50 +0000 |
branch: master
commit 21c89971c31d8f5c14814d2a18749495ed191d8f
Author: Lars Magne Ingebrigtsen <address@hidden>
Commit: Lars Magne Ingebrigtsen <address@hidden>
Add more shr HTML rendering tests
---
test/data/shr/div-div.html | 1 +
test/data/shr/div-div.txt | 2 ++
test/data/shr/div-p.html | 2 +-
test/data/shr/li-div.html | 10 ++++++++++
test/data/shr/li-div.txt | 6 ++++++
test/lisp/net/shr-tests.el | 13 +++++++++----
6 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/test/data/shr/div-div.html b/test/data/shr/div-div.html
new file mode 100644
index 0000000..1c191ae
--- /dev/null
+++ b/test/data/shr/div-div.html
@@ -0,0 +1 @@
+<div>foo</div><div>Bar</div>
diff --git a/test/data/shr/div-div.txt b/test/data/shr/div-div.txt
new file mode 100644
index 0000000..62715e1
--- /dev/null
+++ b/test/data/shr/div-div.txt
@@ -0,0 +1,2 @@
+foo
+Bar
diff --git a/test/data/shr/div-p.html b/test/data/shr/div-p.html
index 810b2f7..fcbdfc4 100644
--- a/test/data/shr/div-p.html
+++ b/test/data/shr/div-p.html
@@ -1 +1 @@
-<div>foo</div><p>Bar
+<div>foo</div><p>Bar</p>
diff --git a/test/data/shr/li-div.html b/test/data/shr/li-div.html
new file mode 100644
index 0000000..eca3c51
--- /dev/null
+++ b/test/data/shr/li-div.html
@@ -0,0 +1,10 @@
+<ul>
+ <li>
+ <div>
+ <p >This is the first paragraph of a list item.</div>
+ <p >This is the second paragraph of a list item.</li>
+ <li>
+ <div>This is the first paragraph of a list item.</div>
+ <div>This is the second paragraph of a list item.</div>
+ </li>
+</ul>
diff --git a/test/data/shr/li-div.txt b/test/data/shr/li-div.txt
new file mode 100644
index 0000000..9fc54f2
--- /dev/null
+++ b/test/data/shr/li-div.txt
@@ -0,0 +1,6 @@
+* This is the first paragraph of a list item.
+
+ This is the second paragraph of a list item.
+
+* This is the first paragraph of a list item.
+ This is the second paragraph of a list item.
diff --git a/test/lisp/net/shr-tests.el b/test/lisp/net/shr-tests.el
index 6078817..6606ec5 100644
--- a/test/lisp/net/shr-tests.el
+++ b/test/lisp/net/shr-tests.el
@@ -23,10 +23,14 @@
;;; Code:
+(require 'shr)
+
(defun shr-test (name)
(with-temp-buffer
(insert-file-contents (format "data/shr/%s.html" name))
- (let ((dom (libxml-parse-html-region (point-min) (point-max))))
+ (let ((dom (libxml-parse-html-region (point-min) (point-max)))
+ (shr-width 80)
+ (shr-use-fonts nil))
(erase-buffer)
(shr-insert-document dom)
(cons (buffer-substring-no-properties (point-min) (point-max))
@@ -37,9 +41,10 @@
(ert-deftest rendering ()
(skip-unless (fboundp 'libxml-parse-html-region))
(dolist (file (directory-files "data/shr" nil "\\.html\\'"))
- (let ((result (shr-test (replace-regexp-in-string
- "\\.html\\'" "" file))))
- (should (equal (car result) (cdr result))))))
+ (let* ((name (replace-regexp-in-string "\\.html\\'" "" file))
+ (result (shr-test name)))
+ (unless (equal (car result) (cdr result))
+ (should (not (list name (car result) (cdr result))))))))
(require 'shr)