Permalink
Browse files

Add tests for begin-end-(quote|verse)

  • Loading branch information...
smiller committed Feb 2, 2015
1 parent 5d94203 commit a74da1a951d6b68f63352ab403f1cd80901adcc2
Showing with 108 additions and 1 deletion.
  1. +108 −1 mods-org.el
View
@@ -94,7 +94,7 @@
(defun remove-old-formatting-code ()
(setq in (filter-buffer-substring (region-beginning) (region-end) t))
(setq out (replace-regexp-in-string "^> " "" in))
(setq out2 (replace-regexp-in-string " <br/>$" "" out))
(setq out2 (replace-regexp-in-string "\s*<br/>$" "" out))
(insert out2)
)
@@ -104,3 +104,110 @@
(indent-region (region-beginning) (region-end) 4)
)
)
(ert-deftest test-begin-end-quote-new-content ()
"Tests begin-end-quote without selected region string"
(should (string= (with-temp-buffer
(begin-end-quote)
(buffer-string))
"#+begin_quote\n\n#+end_quote\n")))
(ert-deftest test-begin-end-quote-new-point ()
"Tests begin-end-quote without selected region cursor position"
(should (equal (with-temp-buffer
(begin-end-quote)
(point))
(length "#+begin_quote\n\n"))))
(ert-deftest test-begin-end-verse-new-content ()
"Tests begin-end-verse without selected region string"
(should (string= (with-temp-buffer
(begin-end-verse)
(buffer-string))
"#+begin_verse\n\n#+end_verse\n")))
(ert-deftest test-begin-end-verse-new-point ()
"Tests begin-end-verse without selected region cursor position"
(should (equal (with-temp-buffer
(begin-end-quote)
(point))
(length "#+begin_verse\n\n"))))
(ert-deftest test-begin-end-quote-region ()
"Tests begin-end-quote with selected region"
(should (string= (with-temp-buffer
(insert "> Dear Sir, your astonishment’s odd;\n")
(set-mark 0)
(begin-end-quote)
(buffer-string))
"#+begin_quote\n Dear Sir, your astonishment’s odd;\n#+end_quote\n")))
(ert-deftest test-begin-end-verse-region ()
"Tests begin-end-verse with selected region, two spaces before <br/>"
(should (string= (with-temp-buffer
(insert "> Dear Sir, your astonishment’s odd; <br/>\n")
(set-mark 0)
(end-of-buffer)
(begin-end-verse)
(buffer-string))
"#+begin_verse\n Dear Sir, your astonishment’s odd;\n#+end_verse\n")))
(ert-deftest test-begin-end-verse-region-one-space ()
"Tests begin-end-verse with selected region, one space before <br/>"
(should (string= (with-temp-buffer
(insert "> Dear Sir, your astonishment’s odd; <br/>\n")
(set-mark 0)
(end-of-buffer)
(begin-end-verse)
(buffer-string))
"#+begin_verse\n Dear Sir, your astonishment’s odd;\n#+end_verse\n")))
(ert-deftest test-begin-end-verse-region-no-space ()
"Tests begin-end-verse with selected region, no space before <br/>"
(should (string= (with-temp-buffer
(insert "> Dear Sir, your astonishment’s odd;<br/>\n")
(set-mark 0)
(end-of-buffer)
(begin-end-verse)
(buffer-string))
"#+begin_verse\n Dear Sir, your astonishment’s odd;\n#+end_verse\n")))
(ert-deftest test-begin-end-quote-region-newer-styling ()
"Tests begin-end-quote with selected region, new styling"
(should (string= (with-temp-buffer
(insert " talsernilli barenya-tar falon enyi\n")
(set-mark 0)
(end-of-buffer)
(begin-end-quote)
(buffer-string))
"#+begin_quote\n talsernilli barenya-tar falon enyi\n#+end_quote\n")))
(ert-deftest test-begin-end-verse-region-newer-styling ()
"Tests begin-end-verse with selected region, new styling"
(should (string= (with-temp-buffer
(insert " i talessen\n talalor ar-entai kirenyi\n basleth solth sares\n")
(set-mark 0)
(end-of-buffer)
(begin-end-verse)
(buffer-string))
"#+begin_verse\n i talessen\n talalor ar-entai kirenyi\n basleth solth sares\n#+end_verse\n")))
(ert-deftest test-begin-end-quote-region-newer-styling-with-medial-gt ()
"Tests begin-end-quote with selected region, new styling, with > in line"
(should (string= (with-temp-buffer
(insert " count > 42\n")
(set-mark 0)
(end-of-buffer)
(begin-end-quote)
(buffer-string))
"#+begin_quote\n count > 42\n#+end_quote\n")))
(ert-deftest test-begin-end-verse-region-newer-styling-with-medial-gt ()
"Tests begin-end-verse with selected region, new styling, with > in line"
(should (string= (with-temp-buffer
(insert " count > 42<br/>\n")
(set-mark 0)
(end-of-buffer)
(begin-end-verse)
(buffer-string))
"#+begin_verse\n count > 42\n#+end_verse\n")))

0 comments on commit a74da1a

Please sign in to comment.