aboutsummaryrefslogtreecommitdiff
path: root/tests/test-wttrin-debug-clear-log.el
blob: 10e4c2100b576b95542d73f0e4dea68d0c1ae01e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
;;; test-wttrin-debug-clear-log.el --- Tests for wttrin-debug-clear-log -*- lexical-binding: t; -*-

;; Copyright (C) 2025-2026 Craig Jennings

;;; Commentary:

;; Unit tests for wttrin-debug-clear-log.  Verifies the interactive
;; command empties the debug log alist regardless of prior state.

;;; Code:

(require 'ert)
(require 'wttrin)
(require 'testutil-wttrin)

(require 'wttrin-debug
         (expand-file-name "wttrin-debug.el"
                           (file-name-directory (locate-library "wttrin"))))

;;; Normal Cases

(ert-deftest test-wttrin-debug-clear-log-normal-empties-populated-log ()
  "Clearing a non-empty log leaves it nil."
  (let ((wttrin--debug-log '(("00:00:01.000" . "one")
                             ("00:00:02.000" . "two"))))
    (wttrin-debug-clear-log)
    (should-not wttrin--debug-log)))

(ert-deftest test-wttrin-debug-clear-log-normal-multiple-calls-stay-empty ()
  "Calling clear twice in a row leaves the log empty."
  (let ((wttrin--debug-log '(("00:00:01.000" . "one"))))
    (wttrin-debug-clear-log)
    (wttrin-debug-clear-log)
    (should-not wttrin--debug-log)))

;;; Boundary Cases

(ert-deftest test-wttrin-debug-clear-log-boundary-clearing-already-empty-log ()
  "Clearing an already-empty log is a no-op and leaves it nil."
  (let ((wttrin--debug-log nil))
    (wttrin-debug-clear-log)
    (should-not wttrin--debug-log)))

(provide 'test-wttrin-debug-clear-log)
;;; test-wttrin-debug-clear-log.el ends here