test-ox-latex.el 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ;;; test-ox-latex.el --- tests for ox-latex.el -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2022 Ihor Radchenko
  3. ;; Author: Ihor Radchenko <yantar92@posteo.net>
  4. ;; This program is free software; you can redistribute it and/or modify
  5. ;; it under the terms of the GNU General Public License as published by
  6. ;; the Free Software Foundation, either version 3 of the License, or
  7. ;; (at your option) any later version.
  8. ;; This program is distributed in the hope that it will be useful,
  9. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;; GNU General Public License for more details.
  12. ;; You should have received a copy of the GNU General Public License
  13. ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. ;;; Commentary:
  15. ;; Tests checking validity of Org LaTeX export output.
  16. ;;; Code:
  17. (require 'ox-latex nil t)
  18. (unless (featurep 'ox-latex)
  19. (signal 'missing-test-dependency "org-export-latex"))
  20. (defmacro org-test-with-exported-text (backend source &rest body)
  21. "Run BODY in export buffer for SOURCE string via BACKEND."
  22. (declare (indent 2))
  23. `(org-test-with-temp-text ,source
  24. (let ((export-buffer (generate-new-buffer "Org temporary export")))
  25. (unwind-protect
  26. (progn
  27. (org-export-to-buffer ,backend export-buffer)
  28. (with-current-buffer export-buffer
  29. ,@body))
  30. (kill-buffer export-buffer)))))
  31. (ert-deftest test-ox-latex/verse ()
  32. "Test verse blocks."
  33. (org-test-with-exported-text
  34. 'latex
  35. "#+begin_verse
  36. lorem ipsum dolor
  37. lorem ipsum dolor
  38. lorem ipsum dolor
  39. lorem ipsum dolor
  40. lorem ipsum dolor
  41. lorem ipsum dolor
  42. #+end_verse
  43. "
  44. (goto-char (point-min))
  45. (should
  46. (search-forward
  47. "\\begin{verse}
  48. lorem ipsum dolor\\\\\\empty
  49. lorem ipsum dolor\\\\\\empty
  50. \\vspace*{1em}
  51. lorem ipsum dolor\\\\\\empty
  52. lorem ipsum dolor\\\\\\empty
  53. \\vspace*{1em}
  54. lorem ipsum dolor\\\\\\empty
  55. lorem ipsum dolor\\\\\\empty
  56. \\end{verse}"))))
  57. (provide 'test-ox-latex)
  58. ;;; test-ox-latex.el ends here