diff options
Diffstat (limited to 'tests/algo1.lisp')
| -rw-r--r-- | tests/algo1.lisp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/algo1.lisp b/tests/algo1.lisp new file mode 100644 index 0000000..5d5f340 --- /dev/null +++ b/tests/algo1.lisp @@ -0,0 +1,70 @@ +(defpackage ffnn/tests/algo1 + (:use :cl + :ffnn + :ffnn.algo1 + :rove)) + +(in-package :ffnn/tests/algo1) + + +(deftest check-sum-one-row + (testing "sum-one-row" + (dolist (case '((foo ((foo) () (bar)) ((foo) (foo) (bar)) 1 (3 1)) + (foo ((bar) () (bar)) ((bar) (bar) (foo)) 1 (-1 1)) + (foo ((bar) () (bar)) ((bar) (bar) (bar)) 1 (1 3)) + (foo ((foo) () (bar)) ((foo) (foo) (bar)) nil (1 1)))) + (destructuring-bind (item input memory index expected) case + (ok (equal (ffnn.algo1::sum-one-row item input memory index) + expected)))))) + +(deftest check-sum-one-memory + (testing "Sum one memory" + (ok (equal (ffnn.algo1::sum-one-memory 'foo + '(((foo) (foo)) + ((bar) (bar))) ;; Input + '(((foo) (foo)) + ((bar) (bar))) ;; Memory + :rectified-polynomial (ffnn.algo1::make-rectified-polynomial 2) + :target-row 0 :target-col 0 + :start-row 0 :start-col 0) + 12)) + (ok (equal (ffnn.algo1::sum-one-memory 'foo + '(((foo) (foo)) + ((baz) (baz))) + '(((foo) (foo)) + ((foo) (foo))) + :rectified-polynomial (ffnn.algo1::make-rectified-polynomial 2) + :target-row 0 :target-col 0 + :start-row 0 :start-col 0) + 0)))) + +(deftest check-sum-memories + (testing "Sum memories" + (let ((memories '((((foo) (foo)) ((bar) (bar))) + (((baz) (baz)) ((foo) (foo))) + (((qux) (qux)) ((qux) (qux))))) + (poly-2 (ffnn.algo1::make-rectified-polynomial 2))) + (ok (sum-memories 'foo + '(((foo) (foo)) ((bar) (bar))) ;; Input + memories ;; The Library of templates + :rectified-polynomial poly-2 + :start-row 0 :start-col 0 + :target-row 0 :target-col 0)) + (ng (sum-memories 'foo + '(((qux) (qux)) ((qux) (qux))) + memories + :rectified-polynomial poly-2 + :start-row 0 :start-col 0 + :target-row 0 :target-col 0)) + (ng (sum-memories 'foo + '(((baz) (baz)) ((foo) (foo))) + memories + :rectified-polynomial poly-2 + :start-row 0 :start-col 0 + :target-row 0 :target-col 0)) + (ok (sum-memories 'foo + '(((baz) (baz)) ((foo) (foo))) + memories + :rectified-polynomial poly-2 + :start-row 0 :start-col 0 + :target-row 1 :target-col 0))))) |
