diff options
| author | Craig Jennings <c@cjennings.net> | 2025-10-27 21:05:06 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-10-27 21:05:06 -0500 |
| commit | d77ca19cf7106a0eecbff1588c13b8b52b98b85f (patch) | |
| tree | eea65ea265d4a11a9c4888357f09f5b471737a45 /tests/test-custom-file-buffer-copy-whole-buffer.el | |
| parent | a8a6bb0b6a49ba83903c84ad0790585c6e40f2b8 (diff) | |
refactor: Rename custom-file-buffer to custom-buffer-file
Renamed the module 'custom-file-buffer' to 'custom-buffer-file' to
ensure consistency across the codebase. This change affects module
imports and test files. Additionally, new module
'system-commands.el' has been created to handle system power and
session management commands, removing these functionalities from
'wip.el'.
Diffstat (limited to 'tests/test-custom-file-buffer-copy-whole-buffer.el')
| -rw-r--r-- | tests/test-custom-file-buffer-copy-whole-buffer.el | 194 |
1 files changed, 0 insertions, 194 deletions
diff --git a/tests/test-custom-file-buffer-copy-whole-buffer.el b/tests/test-custom-file-buffer-copy-whole-buffer.el deleted file mode 100644 index a0546b18..00000000 --- a/tests/test-custom-file-buffer-copy-whole-buffer.el +++ /dev/null @@ -1,194 +0,0 @@ -;;; test-custom-file-buffer-copy-whole-buffer.el --- Tests for cj/copy-whole-buffer -*- lexical-binding: t; -*- - -;;; Commentary: -;; Tests for the cj/copy-whole-buffer function from custom-file-buffer.el -;; -;; This function copies the entire contents of the current buffer to the kill ring. -;; Point and mark are left exactly where they were. No transient region is created. - -;;; Code: - -(require 'ert) -(require 'testutil-general) - -;; Add modules directory to load path -(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) - -;; Stub dependencies before loading the module -(defvar cj/custom-keymap (make-sparse-keymap) - "Stub keymap for testing.") - -;; Stub ps-print package -(provide 'ps-print) - -;; Now load the actual production module -(require 'custom-file-buffer) - -;;; Setup and Teardown - -(defun test-copy-whole-buffer-setup () - "Set up test environment." - (setq kill-ring nil)) - -(defun test-copy-whole-buffer-teardown () - "Clean up test environment." - (setq kill-ring nil)) - -;;; Normal Cases - -(ert-deftest test-copy-whole-buffer-simple-text () - "Should copy simple text content to kill ring." - (test-copy-whole-buffer-setup) - (unwind-protect - (with-temp-buffer - (insert "Hello, world!") - (cj/copy-whole-buffer) - (should (equal (car kill-ring) "Hello, world!"))) - (test-copy-whole-buffer-teardown))) - -(ert-deftest test-copy-whole-buffer-preserves-point () - "Should preserve point position." - (test-copy-whole-buffer-setup) - (unwind-protect - (with-temp-buffer - (insert "Hello, world!") - (goto-char 7) ; Position in middle - (cj/copy-whole-buffer) - (should (= (point) 7))) - (test-copy-whole-buffer-teardown))) - -(ert-deftest test-copy-whole-buffer-preserves-mark () - "Should preserve mark position." - (test-copy-whole-buffer-setup) - (unwind-protect - (with-temp-buffer - (insert "Hello, world!") - (push-mark 5) - (goto-char 10) - (cj/copy-whole-buffer) - (should (= (mark) 5)) - (should (= (point) 10))) - (test-copy-whole-buffer-teardown))) - -;;; Boundary Cases - -(ert-deftest test-copy-whole-buffer-empty () - "Should handle empty buffer." - (test-copy-whole-buffer-setup) - (unwind-protect - (with-temp-buffer - (cj/copy-whole-buffer) - (should (equal (car kill-ring) ""))) - (test-copy-whole-buffer-teardown))) - -(ert-deftest test-copy-whole-buffer-large () - "Should handle very large buffer." - (test-copy-whole-buffer-setup) - (unwind-protect - (with-temp-buffer - (let ((large-content (make-string 100000 ?x))) - (insert large-content) - (cj/copy-whole-buffer) - (should (equal (car kill-ring) large-content)))) - (test-copy-whole-buffer-teardown))) - -(ert-deftest test-copy-whole-buffer-unicode () - "Should handle unicode content (emoji, RTL text)." - (test-copy-whole-buffer-setup) - (unwind-protect - (with-temp-buffer - (insert "Hello 👋 Ù…Ø±ØØ¨Ø§") - (cj/copy-whole-buffer) - (should (equal (car kill-ring) "Hello 👋 Ù…Ø±ØØ¨Ø§"))) - (test-copy-whole-buffer-teardown))) - -(ert-deftest test-copy-whole-buffer-binary () - "Should handle binary content." - (test-copy-whole-buffer-setup) - (unwind-protect - (with-temp-buffer - (insert (string 0 1 2 255)) - (cj/copy-whole-buffer) - (should (equal (car kill-ring) (string 0 1 2 255)))) - (test-copy-whole-buffer-teardown))) - -(ert-deftest test-copy-whole-buffer-only-whitespace () - "Should handle buffer with only whitespace." - (test-copy-whole-buffer-setup) - (unwind-protect - (with-temp-buffer - (insert " \t\n ") - (cj/copy-whole-buffer) - (should (equal (car kill-ring) " \t\n "))) - (test-copy-whole-buffer-teardown))) - -(ert-deftest test-copy-whole-buffer-newlines-at-boundaries () - "Should handle newlines at start/end." - (test-copy-whole-buffer-setup) - (unwind-protect - (with-temp-buffer - (insert "\n\nHello\n\n") - (cj/copy-whole-buffer) - (should (equal (car kill-ring) "\n\nHello\n\n"))) - (test-copy-whole-buffer-teardown))) - -(ert-deftest test-copy-whole-buffer-narrowed () - "Should copy only visible region in narrowed buffer." - (test-copy-whole-buffer-setup) - (unwind-protect - (with-temp-buffer - (insert "Line 1\nLine 2\nLine 3\n") - (goto-char (point-min)) - (forward-line 1) - (narrow-to-region (point) (progn (forward-line 1) (point))) - (cj/copy-whole-buffer) - ;; Should copy only the narrowed region - (should (equal (car kill-ring) "Line 2\n"))) - (test-copy-whole-buffer-teardown))) - -(ert-deftest test-copy-whole-buffer-read-only () - "Should work in read-only buffer." - (test-copy-whole-buffer-setup) - (unwind-protect - (with-temp-buffer - (insert "Read-only content") - (read-only-mode 1) - (cj/copy-whole-buffer) - (should (equal (car kill-ring) "Read-only content"))) - (test-copy-whole-buffer-teardown))) - -(ert-deftest test-copy-whole-buffer-kill-ring-has-content () - "Should add to kill ring when it already has content." - (test-copy-whole-buffer-setup) - (unwind-protect - (with-temp-buffer - (insert "New content") - (kill-new "existing content") - (cj/copy-whole-buffer) - (should (equal (car kill-ring) "New content")) - (should (equal (cadr kill-ring) "existing content"))) - (test-copy-whole-buffer-teardown))) - -(ert-deftest test-copy-whole-buffer-multiline () - "Should preserve multiline content." - (test-copy-whole-buffer-setup) - (unwind-protect - (with-temp-buffer - (insert "Line 1\nLine 2\nLine 3") - (cj/copy-whole-buffer) - (should (equal (car kill-ring) "Line 1\nLine 2\nLine 3"))) - (test-copy-whole-buffer-teardown))) - -(ert-deftest test-copy-whole-buffer-no-properties () - "Should strip text properties." - (test-copy-whole-buffer-setup) - (unwind-protect - (with-temp-buffer - (insert (propertize "Hello" 'face 'bold)) - (cj/copy-whole-buffer) - (should (equal (car kill-ring) "Hello")) - (should (null (text-properties-at 0 (car kill-ring))))) - (test-copy-whole-buffer-teardown))) - -(provide 'test-custom-file-buffer-copy-whole-buffer) -;;; test-custom-file-buffer-copy-whole-buffer.el ends here |
