From: ueno Date: Sat, 19 Nov 2005 05:18:45 +0000 (+0000) Subject: New testcase. X-Git-Tag: riece-2_0_2~5 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=0bee7cffe967b8305c49f1cf2c9f2179e4271c24;p=elisp%2Friece.git New testcase. --- diff --git a/lisp/test/test-riece-cache.el b/lisp/test/test-riece-cache.el new file mode 100644 index 0000000..b378dd3 --- /dev/null +++ b/lisp/test/test-riece-cache.el @@ -0,0 +1,77 @@ +(require 'riece-cache) + +(luna-define-class test-riece-cache (lunit-test-case)) + +(luna-define-method test-riece-cache-get-set ((case test-riece-cache)) + (let ((cache (riece-make-cache 3))) + (riece-cache-set cache "0" 0) + (lunit-assert-2 + case + (= (riece-cache-get cache "0") 0)))) + +(luna-define-method test-riece-cache-set-overflow ((case test-riece-cache)) + (let ((cache (riece-make-cache 3))) + (riece-cache-set cache "0" 0) + (lunit-assert-2 + case + (= (riece-cache-hash-length cache) 1)) + (riece-cache-set cache "1" 1) + (lunit-assert-2 + case + (= (riece-cache-hash-length cache) 2)) + (riece-cache-set cache "2" 2) + (lunit-assert-2 + case + (= (riece-cache-hash-length cache) 3)) + (riece-cache-set cache "3" 3) + (lunit-assert-2 + case + (= (riece-cache-hash-length cache) 3)) + (lunit-assert-2 + case + (null (riece-cache-get cache "0"))))) + +(luna-define-method test-riece-cache-get-increase-key ((case test-riece-cache)) + (let ((cache (riece-make-cache 3))) + (riece-cache-set cache "0" 0) + (riece-cache-set cache "1" 1) + (riece-cache-set cache "2" 2) + (lunit-assert-2 + case + (equal (riece-cache-node-key (riece-cache-first cache)) "0")) + (lunit-assert-2 + case + (equal (riece-cache-node-key (riece-cache-last cache)) "2")) + (riece-cache-get cache "1") + (lunit-assert-2 + case + (equal (riece-cache-node-key (riece-cache-last cache)) "1")))) + +(luna-define-method test-riece-cache-delete ((case test-riece-cache)) + (let ((cache (riece-make-cache 3))) + (riece-cache-set cache "0" 0) + (riece-cache-set cache "1" 1) + (riece-cache-set cache "2" 2) + (riece-cache-delete cache "1") + (lunit-assert-2 + case + (= (riece-cache-hash-length cache) 2)) + (lunit-assert-2 + case + (null (riece-cache-get cache "1"))) + (riece-cache-set cache "1" 1) + (riece-cache-delete cache "0") + (lunit-assert-2 + case + (= (riece-cache-hash-length cache) 2)) + (lunit-assert-2 + case + (null (riece-cache-get cache "0"))) + (riece-cache-set cache "0" 0) + (riece-cache-delete cache "2") + (lunit-assert-2 + case + (= (riece-cache-hash-length cache) 2)) + (lunit-assert-2 + case + (null (riece-cache-get cache "2")))))