aboutsummaryrefslogtreecommitdiff
path: root/tests/test-card-type-multicloze.el
blob: 9aaa58fc796565748505eff27450c887151fd2b2 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
;;; test-card-type-multicloze.el --- Tests for multicloze card type variants

;;; Commentary:
;; Tests for various multicloze card type variants in org-drill.
;;
;; Multicloze variants:
;; - multicloze (alias for hide1cloze)
;; - hide1cloze, hide2cloze (hide N clozes)
;; - show1cloze, show2cloze (show N clozes, hide rest)
;; - hidefirst, hidelast (hide specific positions)
;; - hide1_firstmore, show1_lastmore, show1_firstless (weighted variants)

;;; Code:

(require 'ert)
(require 'assess)
(require 'org-drill)

;;; Normal Cases - Multicloze Variants

(ert-deftest test-card-type-multicloze-normal-hide2cloze-exists ()
  "Test that hide2cloze variant exists."
  (let ((entry (assoc "hide2cloze" org-drill-card-type-alist)))
    (should entry)
    (should (eq (cadr entry) 'org-drill-present-multicloze-hide2))))

(ert-deftest test-card-type-multicloze-normal-show2cloze-exists ()
  "Test that show2cloze variant exists."
  (let ((entry (assoc "show2cloze" org-drill-card-type-alist)))
    (should entry)
    (should (eq (cadr entry) 'org-drill-present-multicloze-show2))))

(ert-deftest test-card-type-multicloze-normal-hidefirst-exists ()
  "Test that hidefirst variant exists."
  (let ((entry (assoc "hidefirst" org-drill-card-type-alist)))
    (should entry)
    (should (eq (cadr entry) 'org-drill-present-multicloze-hide-first))))

(ert-deftest test-card-type-multicloze-normal-hidelast-exists ()
  "Test that hidelast variant exists."
  (let ((entry (assoc "hidelast" org-drill-card-type-alist)))
    (should entry)
    (should (eq (cadr entry) 'org-drill-present-multicloze-hide-last))))

;;; Normal Cases - Weighted Variants

(ert-deftest test-card-type-multicloze-normal-hide1-firstmore-exists ()
  "Test that hide1_firstmore variant exists."
  (let ((entry (assoc "hide1_firstmore" org-drill-card-type-alist)))
    (should entry)
    (should (eq (cadr entry) 'org-drill-present-multicloze-hide1-firstmore))))

(ert-deftest test-card-type-multicloze-normal-show1-lastmore-exists ()
  "Test that show1_lastmore variant exists."
  (let ((entry (assoc "show1_lastmore" org-drill-card-type-alist)))
    (should entry)
    (should (eq (cadr entry) 'org-drill-present-multicloze-show1-lastmore))))

(ert-deftest test-card-type-multicloze-normal-show1-firstless-exists ()
  "Test that show1_firstless variant exists."
  (let ((entry (assoc "show1_firstless" org-drill-card-type-alist)))
    (should entry)
    (should (eq (cadr entry) 'org-drill-present-multicloze-show1-firstless))))

;;; Boundary Cases - Hide vs Show Counts

(ert-deftest test-card-type-multicloze-boundary-hide1-vs-hide2 ()
  "Test that hide1cloze and hide2cloze use different functions."
  (let ((hide1-fn (cadr (assoc "hide1cloze" org-drill-card-type-alist)))
        (hide2-fn (cadr (assoc "hide2cloze" org-drill-card-type-alist))))
    (should-not (eq hide1-fn hide2-fn))
    (should (eq hide1-fn 'org-drill-present-multicloze-hide1))
    (should (eq hide2-fn 'org-drill-present-multicloze-hide2))))

(ert-deftest test-card-type-multicloze-boundary-show1-vs-show2 ()
  "Test that show1cloze and show2cloze use different functions."
  (let ((show1-fn (cadr (assoc "show1cloze" org-drill-card-type-alist)))
        (show2-fn (cadr (assoc "show2cloze" org-drill-card-type-alist))))
    (should-not (eq show1-fn show2-fn))
    (should (eq show1-fn 'org-drill-present-multicloze-show1))
    (should (eq show2-fn 'org-drill-present-multicloze-show2))))

;;; Boundary Cases - Position-based Variants

(ert-deftest test-card-type-multicloze-boundary-hidefirst-vs-hidelast ()
  "Test that hidefirst and hidelast use different functions."
  (let ((first-fn (cadr (assoc "hidefirst" org-drill-card-type-alist)))
        (last-fn (cadr (assoc "hidelast" org-drill-card-type-alist))))
    (should-not (eq first-fn last-fn))
    (should (eq first-fn 'org-drill-present-multicloze-hide-first))
    (should (eq last-fn 'org-drill-present-multicloze-hide-last))))

;;; Semantics - Variant Coverage

(ert-deftest test-card-type-multicloze-normal-all-variants-registered ()
  "Test that all documented multicloze variants are registered.
This ensures the card type system is complete."
  (let ((variants '("multicloze" "hide1cloze" "hide2cloze"
                    "show1cloze" "show2cloze"
                    "hidefirst" "hidelast"
                    "hide1_firstmore" "show1_lastmore" "show1_firstless")))
    (dolist (variant variants)
      (let ((entry (assoc variant org-drill-card-type-alist)))
        (should entry)
        (should (cadr entry))))))

(ert-deftest test-card-type-multicloze-normal-function-naming-convention ()
  "Test that multicloze functions follow naming convention.
All should start with org-drill-present-multicloze-"
  (let ((multicloze-types '("hide1cloze" "hide2cloze" "show1cloze" "show2cloze"
                            "hidefirst" "hidelast")))
    (dolist (type multicloze-types)
      (let* ((entry (assoc type org-drill-card-type-alist))
             (fn (cadr entry))
             (fn-name (symbol-name fn)))
        (should (string-prefix-p "org-drill-present-multicloze-" fn-name))))))

(provide 'test-card-type-multicloze)
;;; test-card-type-multicloze.el ends here