Convert tests to ERT.

This commit is contained in:
Nikolaj Schumacher 2013-09-02 18:10:36 +02:00
parent 229c0561a3
commit d5b635f34e

View file

@ -1,35 +1,37 @@
(require 'elk-test) (require 'ert)
(require 'window-numbering)
(deftest "window-numbering-assign" (ert-deftest window-numbering-assign ()
(let ((window-numbering-windows (make-vector 10 nil)) (let ((window-numbering-windows (make-vector 10 nil))
(window-numbering-numbers (make-hash-table :size 10)) (window-numbering-numbers (make-hash-table :size 10))
(window-numbering-left '(1 2 3))) (window-numbering-left '(1 2 3)))
(assert-nonnil (window-numbering-assign 'xx 7)) (should (not (null (window-numbering-assign 'xx 7))))
(assert-nil (window-numbering-assign 'yy 7)) (should (null (window-numbering-assign 'yy 7)))
(assert-nonnil (window-numbering-assign 'zz 8)) (should (not (null (window-numbering-assign 'zz 8))))
(assert-equal 8 (gethash 'zz window-numbering-numbers)) (should (equal 8 (gethash 'zz window-numbering-numbers)))
(assert-equal 7 (gethash 'xx window-numbering-numbers)) (should (equal 7 (gethash 'xx window-numbering-numbers)))
(assert-equal 'zz (aref window-numbering-windows 8)) (should (equal 'zz (aref window-numbering-windows 8)))
(assert-equal 'xx (aref window-numbering-windows 7)) (should (equal 'xx (aref window-numbering-windows 7)))
)) ))
(deftest "window-numbering-assign auto"
(let ((window-numbering-windows (make-vector 10 nil))
(window-numbering-numbers (make-hash-table :size 10))
(window-numbering-left '(1 2 3 4)))
(assert-eq 1 (window-numbering-assign 'xx))
(assert-nonnil (window-numbering-assign 'yy 3))
(assert-eq 2 (window-numbering-assign 'zz))
(assert-eq 4 (window-numbering-assign 'aa))
))
(deftest "window-numbering-calculate-left" (ert-deftest window-numbering-assign-auto ()
(assert-equal '(6) (window-numbering-calculate-left (let ((window-numbering-windows (make-vector 10 nil))
[t t t t t nil t t t t])) (window-numbering-numbers (make-hash-table :size 10))
(assert-equal '(1 2 3) (window-numbering-calculate-left (window-numbering-left '(1 2 3 4)))
[nil nil nil t t t t t t t])) (should (eq 1 (window-numbering-assign 'xx)))
(assert-equal '(1 2 3 4 5 6 7 8 9 0) (should (not (null (window-numbering-assign 'yy 3))))
(window-numbering-calculate-left (should (eq 2 (window-numbering-assign 'zz)))
[nil nil nil nil nil nil nil nil nil nil])) (should (eq 4 (window-numbering-assign 'aa)))
))
(ert-deftest window-numbering-calculate-left ()
(should (equal '(6) (window-numbering-calculate-left
[t t t t t nil t t t t])))
(should (equal '(1 2 3) (window-numbering-calculate-left
[nil nil nil t t t t t t t])))
(should (equal '(1 2 3 4 5 6 7 8 9 0)
(window-numbering-calculate-left
[nil nil nil nil nil nil nil nil nil nil])))
) )