diff options
author | Gregory Heytings <gregory@heytings.org> | 2023-02-09 01:09:10 +0000 |
---|---|---|
committer | Gregory Heytings <gregory@heytings.org> | 2023-02-09 02:44:57 +0100 |
commit | 2956e54b1dda1647a9399211c7d09b208b85dcfa (patch) | |
tree | 158f805b12dab50b93e4a2991448deb13bc13e87 | |
parent | 79ce185ad1373845781646812638d4872b8aee69 (diff) | |
download | emacs-2956e54b1dda1647a9399211c7d09b208b85dcfa.tar.gz emacs-2956e54b1dda1647a9399211c7d09b208b85dcfa.tar.bz2 emacs-2956e54b1dda1647a9399211c7d09b208b85dcfa.zip |
Add an extensive test for labeled (locked) narrowing
* test/src/buffer-tests.el (test-labeled-narrowing): New test.
-rw-r--r-- | test/src/buffer-tests.el | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el index 9d4bbf3e040..0ae78c8d9d9 100644 --- a/test/src/buffer-tests.el +++ b/test/src/buffer-tests.el @@ -8539,4 +8539,110 @@ Finally, kill the buffer and its temporary file." (if f2 (delete-file f2)) ))) +(ert-deftest test-labeled-narrowing () + "Test `with-narrowing' and `without-narrowing'." + (with-current-buffer (generate-new-buffer " foo" t) + (insert (make-string 5000 ?a)) + (should (= (point-min) 1)) + (should (= (point-max) 5001)) + (with-narrowing + 100 500 :label 'foo + (should (= (point-min) 100)) + (should (= (point-max) 500)) + (widen) + (should (= (point-min) 100)) + (should (= (point-max) 500)) + (narrow-to-region 1 5000) + (should (= (point-min) 100)) + (should (= (point-max) 500)) + (narrow-to-region 50 150) + (should (= (point-min) 100)) + (should (= (point-max) 150)) + (widen) + (should (= (point-min) 100)) + (should (= (point-max) 500)) + (narrow-to-region 400 1000) + (should (= (point-min) 400)) + (should (= (point-max) 500)) + (without-narrowing + :label 'bar + (should (= (point-min) 100)) + (should (= (point-max) 500))) + (without-narrowing + :label 'foo + (should (= (point-min) 1)) + (should (= (point-max) 5001))) + (should (= (point-min) 400)) + (should (= (point-max) 500)) + (widen) + (should (= (point-min) 100)) + (should (= (point-max) 500)) + (with-narrowing + 50 250 :label 'bar + (should (= (point-min) 100)) + (should (= (point-max) 250)) + (widen) + (should (= (point-min) 100)) + (should (= (point-max) 250)) + (without-narrowing + :label 'bar + (should (= (point-min) 100)) + (should (= (point-max) 500)) + (without-narrowing + :label 'foo + (should (= (point-min) 1)) + (should (= (point-max) 5001))) + (should (= (point-min) 100)) + (should (= (point-max) 500))) + (should (= (point-min) 100)) + (should (= (point-max) 250))) + (should (= (point-min) 100)) + (should (= (point-max) 500)) + (with-narrowing + 50 250 :label 'bar + (should (= (point-min) 100)) + (should (= (point-max) 250)) + (with-narrowing + 150 500 :label 'baz + (should (= (point-min) 150)) + (should (= (point-max) 250)) + (without-narrowing + :label 'bar + (should (= (point-min) 150)) + (should (= (point-max) 250))) + (without-narrowing + :label 'foo + (should (= (point-min) 150)) + (should (= (point-max) 250))) + (without-narrowing + :label 'baz + (should (= (point-min) 100)) + (should (= (point-max) 250)) + (without-narrowing + :label 'foo + (should (= (point-min) 100)) + (should (= (point-max) 250))) + (without-narrowing + :label 'bar + (should (= (point-min) 100)) + (should (= (point-max) 500)) + (without-narrowing + :label 'foobar + (should (= (point-min) 100)) + (should (= (point-max) 500))) + (without-narrowing + :label 'foo + (should (= (point-min) 1)) + (should (= (point-max) 5001))) + (should (= (point-min) 100)) + (should (= (point-max) 500))) + (should (= (point-min) 100)) + (should (= (point-max) 250))) + (should (= (point-min) 150)) + (should (= (point-max) 250))) + (should (= (point-min) 100)) + (should (= (point-max) 250)))) + (should (= (point-min) 1)) + (should (= (point-max) 5001)))) + ;;; buffer-tests.el ends here |