X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/f315b69922db769f3358e15616aa76c965be8a89..59e7fe6d0c6988687b53c279941c9ebb3f887eed:/test/automated/tildify-tests.el diff --git a/test/automated/tildify-tests.el b/test/automated/tildify-tests.el index 55d2d57672..b53f58c279 100644 --- a/test/automated/tildify-tests.el +++ b/test/automated/tildify-tests.el @@ -1,6 +1,6 @@ ;;; tildify-test.el --- ERT tests for tildify.el -*- lexical-binding: t -*- -;; Copyright (C) 2014 Free Software Foundation, Inc. +;; Copyright (C) 2014-2015 Free Software Foundation, Inc. ;; Author: Michal Nazarewicz ;; Version: 4.5 @@ -185,6 +185,77 @@ The function must terminate as soon as callback returns nil." (+ (point-min) 10) (+ (point-min) 20)))) ; start at "3" end past "5" +(defun tildify-space-test--test (modes nbsp env-open &optional set-space-string) + (with-temp-buffer + (dolist (mode modes) + (funcall mode) + (when set-space-string + (setq-local tildify-space-string nbsp)) + (let ((header (concat "Testing `tildify-space' in " + (symbol-name mode) "\n"))) + ;; Replace space with hard space. + (erase-buffer) + (insert header "Lorem v ") + (should (tildify-space)) + (should (string-equal (concat header "Lorem v" nbsp) (buffer-string))) + ;; Inside and ignore environment, replacing does not happen. + (erase-buffer) + (insert header env-open "Lorem v ") + (should (not (tildify-space))) + (should (string-equal (concat header env-open "Lorem v ") + (buffer-string))))))) + +(ert-deftest tildify-space-test-html () + "Tests auto-tildification in an HTML document" + (tildify-space-test--test '(html-mode sgml-mode) " " "
"))
+
+(ert-deftest tildify-space-test-html-nbsp ()
+  "Tests auto-tildification in an HTML document"
+  (tildify-space-test--test '(html-mode sgml-mode) " " "
" t))
+
+(ert-deftest tildify-space-test-xml ()
+  "Tests auto-tildification in an XML document"
+  (tildify-space-test--test '(nxml-mode) " " ""))
+
+(ert-deftest tildify-space-undo-test-html-nbsp ()
+  "Tests auto-tildification in an HTML document"
+  (tildify-space-undo-test--test '(html-mode sgml-mode) " " "
" t))
+
+(ert-deftest tildify-space-undo-test-xml ()
+  "Tests auto-tildification in an XML document"
+  (tildify-space-undo-test--test '(nxml-mode) " " "