From bcdfa2e7d551845c3d1be855cbac502e25f8975a Mon Sep 17 00:00:00 2001 From: David Shepherd Date: Sat, 19 Mar 2016 17:34:50 +0000 Subject: [PATCH 1/3] Add some basic tests for sgml-mode indentation --- test/lisp/textmodes/sgml-mode-tests.el | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/test/lisp/textmodes/sgml-mode-tests.el b/test/lisp/textmodes/sgml-mode-tests.el index 4184e2c..01624f4 100644 --- a/test/lisp/textmodes/sgml-mode-tests.el +++ b/test/lisp/textmodes/sgml-mode-tests.el @@ -3,6 +3,7 @@ ;; Copyright (C) 2015-2016 Free Software Foundation, Inc. ;; Author: Przemysław Wojnowski +;; David Shepherd ;; Keywords: tests ;; This file is part of GNU Emacs. @@ -131,5 +132,51 @@ sgml-with-content (sgml-delete-tag 1) (should (string= "Winter is comin'" (buffer-string))))) + +;;; sgml indentation + +(defun sgml-test-indentation (content expected) + "Insert CONTENT into a temporary `sgml-mode' buffer, indent it, +and compare with EXPECTED." + (let ((indent-tabs-mode nil)) + (sgml-with-content content + (indent-region (point-min) (point-max)) + (should (string= (buffer-substring (point-min) (point-max)) expected))))) + +(ert-deftest sgml-indent-should-indent-tag-contents () + (sgml-test-indentation " +
+test +
+" " +
+ test +
+")) + +(ert-deftest sgml-indent-should-align-attributes () + (sgml-test-indentation " +
+" " +
+")) + +(ert-deftest sgml-indent-should-align-strings () + (sgml-test-indentation " +
+" + ;; The indentation looks wrong below because \" is a single + ;; character in the buffer. +" +
+")) + + (provide 'sgml-mode-tests) ;;; sgml-mode-tests.el ends here -- 2.1.4