(defpackage :cl-tui-backend-test (:use :cl :fiveam :cl-tui.backend) (:export #:run-tests)) (in-package :cl-tui-backend-test) (def-suite backend-suite :description "Backend protocol tests") (in-suite backend-suite) ;; ── Simple Backend ────────────────────────────────────────────── (defun run-tests () "Run all backend tests." (let ((result (run 'backend-suite))) (fiveam:explain! result) (uiop:quit 0))) (test simple-backend-lifecycle "simple-backend can be created and shut down" (let ((b (make-simple-backend))) (is (typep b 'simple-backend)) (initialize-backend b) (is (capable-p b :truecolor) nil "simple backend has no truecolor") (shutdown-backend b))) (test simple-backend-draw-text "simple-backend renders text at position, ignoring style" (let ((b (make-simple-backend))) (initialize-backend b) (draw-text b 0 0 "hello" nil nil) (shutdown-backend b) (is-t t))) (test simple-backend-border-single "simple-backend draws ASCII single border" (let ((b (make-simple-backend))) (initialize-backend b) (draw-border b 0 0 10 5 :style :single) (shutdown-backend b) (is-t t))) (test simple-backend-border-rounded "simple-backend falls back to straight edges for rounded" (let ((b (make-simple-backend))) (initialize-backend b) (draw-border b 0 0 10 5 :style :rounded) (shutdown-backend b) (is-t t))) ;; ── Backend Capabilities ─────────────────────────────────────── (test capable-p-known-features "capable-p returns nil for all features on simple-backend" (let ((b (make-simple-backend))) (initialize-backend b) (dolist (f '(:truecolor :osc8 :sync :mouse :bracketed-paste :kitty-keyboard :sixel :cursor-style)) (is (capable-p b f) nil (format nil "~s should not be supported on simple-backend" f))) (shutdown-backend b))) ;; ── Backend Size ─────────────────────────────────────────────── (test backend-size-returns-integers "backend-size returns two integer values" (let ((b (make-simple-backend))) (initialize-backend b) (multiple-value-bind (cols lines) (backend-size b) (is (integerp cols)) (is (integerp lines)) (is (>= cols 10)) (is (>= lines 3))) (shutdown-backend b))) ;; ── Drawing Primitives ───────────────────────────────────────── (test draw-rect-fills-area "draw-rect fills a rectangular area with background" (let ((b (make-simple-backend))) (initialize-backend b) (draw-rect b 0 0 5 3 :bg nil) (shutdown-backend b) (is-t t))) (test draw-text-multi-line "draw-text handles strings with newlines" (let ((b (make-simple-backend))) (initialize-backend b) (draw-text b 0 0 "line1~%line2" nil nil) (shutdown-backend b) (is-t t))) ;; ── Synchronization ──────────────────────────────────────────── (test sync-is-noop-on-simple "begin-sync and end-sync are no-ops on simple-backend" (let ((b (make-simple-backend))) (initialize-backend b) (begin-sync b) (draw-text b 0 0 "in sync" nil nil) (end-sync b) (shutdown-backend b) (is-t t)))