diff options
| author | Craig Jennings <c@cjennings.net> | 2025-11-13 13:16:44 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-11-13 13:16:44 -0600 |
| commit | a064c5d7659d84393fd8f586bb1c7d18a5436b38 (patch) | |
| tree | 58ce7ac137226bc6f40a2a359b138ee58cbb33db /tests/test-card-type-twosided.el | |
| parent | c4c64e2762d7b75f588c20bc7d43ddf8ba30c97e (diff) | |
| download | org-drill-a064c5d7659d84393fd8f586bb1c7d18a5436b38.tar.gz org-drill-a064c5d7659d84393fd8f586bb1c7d18a5436b38.zip | |
test: Add boundary, error, and edge case tests
Added 66 comprehensive tests covering:
- Entry detection with extreme values and Unicode
- SM2 algorithm with boundary conditions
- Workflow error handling with malformed data
- Card types with complex content structures
Diffstat (limited to 'tests/test-card-type-twosided.el')
| -rw-r--r-- | tests/test-card-type-twosided.el | 345 |
1 files changed, 345 insertions, 0 deletions
diff --git a/tests/test-card-type-twosided.el b/tests/test-card-type-twosided.el index cda508f..bda4f79 100644 --- a/tests/test-card-type-twosided.el +++ b/tests/test-card-type-twosided.el @@ -214,5 +214,350 @@ Two sides for word translation pairs." (should (eq twosided-fn 'org-drill-present-two-sided-card)) (should (eq simple-fn 'org-drill-present-simple-card)))) +;;; Aggressive Edge Cases + +(ert-deftest test-card-type-twosided-edge-unicode-in-sides () + "Test two-sided card with Unicode in both sides. +Unicode characters should be preserved correctly." + (let ((content "* Unicode Card :drill: +:PROPERTIES: +:DRILL_CARD_TYPE: twosided +:END: + +** English + +Hello + +** 日本語 + +こんにちは +")) + (test-card-type-twosided--with-card + content + (lambda () + (should (org-drill-entry-p)) + (should (= 2 (test-card-type-twosided--count-subheadings))))))) + +(ert-deftest test-card-type-twosided-edge-very-long-side-content () + "Test two-sided card with very long content in sides. +Should handle large amounts of text without issues." + (let* ((long-text (make-string 5000 ?x)) + (content (format "* Long Sides :drill: +:PROPERTIES: +:DRILL_CARD_TYPE: twosided +:END: + +** Side A + +%s + +** Side B + +%s +" long-text long-text))) + (test-card-type-twosided--with-card + content + (lambda () + (should (org-drill-entry-p)) + (should (= 2 (test-card-type-twosided--count-subheadings))))))) + +(ert-deftest test-card-type-twosided-edge-sides-with-lists () + "Test two-sided card with org-mode lists in sides." + (let ((content "* Lists Card :drill: +:PROPERTIES: +:DRILL_CARD_TYPE: twosided +:END: + +** Question + +What are primary colors? + +** Answer + +- Red +- Blue +- Yellow +")) + (test-card-type-twosided--with-card + content + (lambda () + (should (org-drill-entry-p)) + (should (= 2 (test-card-type-twosided--count-subheadings))))))) + +(ert-deftest test-card-type-twosided-edge-sides-with-tables () + "Test two-sided card with org-mode tables in sides." + (let ((content "* Table Card :drill: +:PROPERTIES: +:DRILL_CARD_TYPE: twosided +:END: + +** Question + +Temperature conversion? + +** Table + +| Celsius | Fahrenheit | +|---------+------------| +| 0 | 32 | +| 100 | 212 | +")) + (test-card-type-twosided--with-card + content + (lambda () + (should (org-drill-entry-p)) + (should (= 2 (test-card-type-twosided--count-subheadings))))))) + +(ert-deftest test-card-type-twosided-edge-sides-with-code-blocks () + "Test two-sided card with source code blocks in sides." + (let ((content "* Code Card :drill: +:PROPERTIES: +:DRILL_CARD_TYPE: twosided +:END: + +** Question + +Python hello world? + +** Code + +#+BEGIN_SRC python +print(\"Hello, World!\") +#+END_SRC +")) + (test-card-type-twosided--with-card + content + (lambda () + (should (org-drill-entry-p)) + (should (= 2 (test-card-type-twosided--count-subheadings))))))) + +(ert-deftest test-card-type-twosided-edge-sides-with-links () + "Test two-sided card with org-mode links in sides." + (let ((content "* Links Card :drill: +:PROPERTIES: +:DRILL_CARD_TYPE: twosided +:END: + +** Term + +Emacs + +** Definition + +A [[https://www.gnu.org/software/emacs/][powerful text editor]]. +")) + (test-card-type-twosided--with-card + content + (lambda () + (should (org-drill-entry-p)) + (should (= 2 (test-card-type-twosided--count-subheadings))))))) + +(ert-deftest test-card-type-twosided-edge-sides-with-formatting () + "Test two-sided card with org-mode text formatting in sides." + (let ((content "* Formatted Card :drill: +:PROPERTIES: +:DRILL_CARD_TYPE: twosided +:END: + +** Question + +What is *bold*, /italic/, =code=? + +** Answer + +These are *org-mode* /text/ =formatting= options. +")) + (test-card-type-twosided--with-card + content + (lambda () + (should (org-drill-entry-p)) + (should (= 2 (test-card-type-twosided--count-subheadings))))))) + +(ert-deftest test-card-type-twosided-edge-sides-with-tags () + "Test two-sided card where sides have tags. +Tags on subheadings should not interfere with card." + (let ((content "* Card with Tagged Sides :drill: +:PROPERTIES: +:DRILL_CARD_TYPE: twosided +:END: + +** Question :important: + +What is the answer? + +** Answer :note: + +42 +")) + (test-card-type-twosided--with-card + content + (lambda () + (should (org-drill-entry-p)) + (should (= 2 (test-card-type-twosided--count-subheadings))))))) + +(ert-deftest test-card-type-twosided-edge-nested-subheadings-in-sides () + "Test two-sided card with nested subheadings within sides. +Nested content should be part of the side." + (let ((content "* Nested Content :drill: +:PROPERTIES: +:DRILL_CARD_TYPE: twosided +:END: + +** Side A + +Content A + +*** Nested Under A + +More details. + +** Side B + +Content B +")) + (test-card-type-twosided--with-card + content + (lambda () + (should (org-drill-entry-p)) + (should (= 2 (test-card-type-twosided--count-subheadings))))))) + +(ert-deftest test-card-type-twosided-edge-empty-headings () + "Test two-sided card where heading text is minimal." + (let ((content "* Minimal Headings :drill: +:PROPERTIES: +:DRILL_CARD_TYPE: twosided +:END: + +** A + +Full content for A. + +** B + +Full content for B. +")) + (test-card-type-twosided--with-card + content + (lambda () + (should (org-drill-entry-p)) + (should (= 2 (test-card-type-twosided--count-subheadings))))))) + +(ert-deftest test-card-type-twosided-edge-special-characters-in-sides () + "Test two-sided card with special characters in side content." + (let ((content "* Special Chars :drill: +:PROPERTIES: +:DRILL_CARD_TYPE: twosided +:END: + +** Question + +What are these: @#$%^&*()? + +** Answer + +Special programming characters. +")) + (test-card-type-twosided--with-card + content + (lambda () + (should (org-drill-entry-p)) + (should (= 2 (test-card-type-twosided--count-subheadings))))))) + +(ert-deftest test-card-type-twosided-edge-many-extra-sides () + "Test two-sided card with many subheadings (10+). +Only first two should be used for presentation." + (let ((content "* Many Sides :drill: +:PROPERTIES: +:DRILL_CARD_TYPE: twosided +:END: + +** Side 1 + +Content 1 + +** Side 2 + +Content 2 + +** Side 3 + +Extra + +** Side 4 + +Extra + +** Side 5 + +Extra + +** Side 6 + +Extra + +** Side 7 + +Extra + +** Side 8 + +Extra + +** Side 9 + +Extra + +** Side 10 + +Extra +")) + (test-card-type-twosided--with-card + content + (lambda () + (should (org-drill-entry-p)) + (should (>= (test-card-type-twosided--count-subheadings) 10)))))) + +(ert-deftest test-card-type-twosided-edge-no-subheadings () + "Test two-sided card with no subheadings at all. +Card is invalid but should not crash." + (let ((content "* No Sides :drill: +:PROPERTIES: +:DRILL_CARD_TYPE: twosided +:END: + +Just main body, no subheadings. +")) + (test-card-type-twosided--with-card + content + (lambda () + (should (org-drill-entry-p)) + (should (= 0 (test-card-type-twosided--count-subheadings))))))) + +(ert-deftest test-card-type-twosided-edge-sides-with-drawers () + "Test two-sided card with drawers in sides. +Drawers should be preserved." + (let ((content "* Drawer Card :drill: +:PROPERTIES: +:DRILL_CARD_TYPE: twosided +:END: + +** Side A + +:LOGBOOK: +- Note taken on [2024-01-01] +:END: + +Content A + +** Side B + +Content B +")) + (test-card-type-twosided--with-card + content + (lambda () + (should (org-drill-entry-p)) + (should (= 2 (test-card-type-twosided--count-subheadings))))))) + (provide 'test-card-type-twosided) ;;; test-card-type-twosided.el ends here |
