emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 68d6ea3 23/57: Make name of vdiff-test consistent with pre


From: Justin Burkett
Subject: [elpa] master 68d6ea3 23/57: Make name of vdiff-test consistent with prefixes
Date: Tue, 3 Nov 2020 14:32:21 -0500 (EST)

branch: master
commit 68d6ea37ae73a8a8a44e8400d826b2115eddb952
Author: Justin Burkett <justin@burkett.cc>
Commit: Justin Burkett <justin@burkett.cc>

    Make name of vdiff-test consistent with prefixes
    
    Introduce macro for setting up testing environment
---
 Makefile       |   2 +-
 vdiff-test.el  | 106 ++++++++++++++++++++++++++++++++++++
 vdiff-tests.el | 168 ---------------------------------------------------------
 3 files changed, 107 insertions(+), 169 deletions(-)

diff --git a/Makefile b/Makefile
index 4e3a180..6504277 100644
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,7 @@ ELPA_DIR = \
 
 test: elpa
        $(CASK) exec $(EMACS) -Q -batch $(LOADPATH) \
-               -l vdiff-tests.el -f ert-run-tests-batch-and-exit
+               -l vdiff-test.el -f ert-run-tests-batch-and-exit
 
 elpa: $(ELPA_DIR)
 $(ELPA_DIR): Cask
diff --git a/vdiff-test.el b/vdiff-test.el
new file mode 100644
index 0000000..f885e17
--- /dev/null
+++ b/vdiff-test.el
@@ -0,0 +1,106 @@
+;;; vdiff-test.el --- tests for vdiff.el -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2018  Free Software Foundation, Inc.
+
+;; Author: Justin Burkett <justin@burkett.cc>
+;; Maintainer: Justin Burkett <justin@burkett.cc>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+(require 'vdiff)
+
+(defun vdiff-test-buffer-string ()
+  (replace-regexp-in-string "\n" "|" (buffer-string)))
+
+(defmacro vdiff-test-with-buffers (a-string b-string &rest body)
+  `(let ((buffer-a (get-buffer-create "vdiff-tests-buffer-a"))
+         (buffer-b (get-buffer-create "vdiff-tests-buffer-b"))
+         (vdiff--testing-mode t))
+     (unwind-protect
+         (progn
+           (with-current-buffer buffer-a
+             (erase-buffer)
+             (insert ,(replace-regexp-in-string "|" "\n" a-string)))
+           (with-current-buffer buffer-b
+             (erase-buffer)
+             (insert ,(replace-regexp-in-string "|" "\n" b-string)))
+           (vdiff-buffers buffer-a buffer-b nil nil nil t)
+           ,@body)
+       (with-current-buffer buffer-a
+         (vdiff-quit)))))
+
+(ert-deftest vdiff-test-parsing ()
+  "Test parsing of unified diff format."
+  (with-temp-buffer
+    (insert "--- test1.txt     2018-04-13 11:11:41.000000000 -0400
++++ test2.txt  2018-04-13 11:11:46.000000000 -0400
+@@ -1,3 +1,6 @@
++
++
++
+ 1
+ 2
+ 3
+@@ -9,6 +12,8 @@
+ 9
+ 10
+ 11
++11
++11
+ 12
+ 13
+ 14
+@@ -16,7 +21,8 @@
+ 16
+ 17
+ 18
+-19
+-20
++18
++29
+ 21
+ 22
++23
+")
+    (should (equal (vdiff--parse-diff-u (current-buffer))
+                   '(((1) (1 . 3)) ((12) (15 . 16)) ((19 . 20) (24 . 25)) 
((23) (28 . 28)))))))
+
+(ert-deftest vdiff-test-transmiting ()
+  "Test transmitting changes."
+  (vdiff-test-with-buffers
+   "1|2|3|4|5|6|7|8|9|10|"
+   "1|2|4|4|5|6|8|8|9|10|"
+   (with-current-buffer buffer-a
+     (vdiff-send-changes (point-min) (point-max)))
+   (with-current-buffer buffer-b
+     (should (string= (vdiff-test-buffer-string)
+                      "1|2|3|4|5|6|7|8|9|10|")))))
+
+(ert-deftest vdiff-test-receiving ()
+  "Test receiving changes."
+  (vdiff-test-with-buffers
+   "1|2|3|4|5|6|7|8|9|10|"
+   "1|2|4|4|5|6|8|8|9|10|"
+   (with-current-buffer buffer-b
+     (vdiff-receive-changes (point-min) (point-max)))
+   (with-current-buffer buffer-b
+     (should (string= (vdiff-test-buffer-string)
+                      "1|2|3|4|5|6|7|8|9|10|")))))
+
+
+(provide 'vdiff-test)
+;;; vdiff-test.el ends here
diff --git a/vdiff-tests.el b/vdiff-tests.el
deleted file mode 100644
index 58e6a75..0000000
--- a/vdiff-tests.el
+++ /dev/null
@@ -1,168 +0,0 @@
-;;; vdiff-tests.el --- tests for vdiff.el -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2018  Free Software Foundation, Inc.
-
-;; Author: Justin Burkett <justin@burkett.cc>
-;; Maintainer: Justin Burkett <justin@burkett.cc>
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Code:
-
-(require 'ert)
-(require 'vdiff)
-
-(ert-deftest vdiff-test-parsing ()
-  "Test parsing of unified diff format."
-  (with-temp-buffer
-    (insert "--- test1.txt     2018-04-13 11:11:41.000000000 -0400
-+++ test2.txt  2018-04-13 11:11:46.000000000 -0400
-@@ -1,3 +1,6 @@
-+
-+
-+
- 1
- 2
- 3
-@@ -9,6 +12,8 @@
- 9
- 10
- 11
-+11
-+11
- 12
- 13
- 14
-@@ -16,7 +21,8 @@
- 16
- 17
- 18
--19
--20
-+18
-+29
- 21
- 22
-+23
-")
-    (should (equal (vdiff--parse-diff-u (current-buffer))
-                   '(((1) (1 . 3)) ((12) (15 . 16)) ((19 . 20) (24 . 25)) 
((23) (28 . 28)))))))
-
-(ert-deftest vdiff-test-transmiting ()
-  "Test transmitting changes."
-  (let ((bufa (get-buffer-create "vdiff-tests-bufa"))
-        (bufb (get-buffer-create "vdiff-tests-bufb"))
-        (vdiff--testing-mode t))
-    (unwind-protect
-        (progn
-          (with-current-buffer bufa
-            (erase-buffer)
-            (insert "1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-"))
-          (with-current-buffer bufb
-            (erase-buffer)
-            (insert "1
-2
-4
-4
-5
-6
-8
-8
-9
-10
-"))
-          (vdiff-buffers bufa bufb)
-          (with-current-buffer bufa
-            (vdiff-send-changes (point-min) (point-max)))
-          (with-current-buffer bufb
-            (should (string= (buffer-string)
-                             "1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-"))))
-      (kill-buffer bufa)
-      (kill-buffer bufb))))
-
-(ert-deftest vdiff-test-receiving ()
-  "Test receiving changes."
-  (let ((bufa (get-buffer-create "vdiff-tests-bufa"))
-        (bufb (get-buffer-create "vdiff-tests-bufb"))
-        (vdiff--testing-mode t))
-    (unwind-protect
-        (progn
-          (with-current-buffer bufa
-            (erase-buffer)
-            (insert "1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-"))
-          (with-current-buffer bufb
-            (erase-buffer)
-            (insert "1
-2
-4
-4
-5
-6
-8
-8
-9
-10
-"))
-          (vdiff-buffers bufa bufb)
-          (with-current-buffer bufb
-            (vdiff-receive-changes (point-min) (point-max)))
-          (with-current-buffer bufb
-            (should (string= (buffer-string)
-                             "1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-"))))
-      (kill-buffer bufa)
-      (kill-buffer bufb))))
-
-
-(provide 'vdiff-tests)
-;;; vdiff-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]