Add unit tests for matrices

This commit is contained in:
Renaud Casenave-Péré 2014-01-02 20:17:53 +09:00
parent 04544e9742
commit 3f317bb1da

View file

@ -10,7 +10,7 @@
:cl-test-more))
(in-package :stoe-test.maths)
(plan 17)
(plan 23)
(diag "Vector Constructor Tests")
(is (v:vec 1 2 3) #(1.0 2.0 3.0) "Float Vector Constructor" :test #'equalp)
@ -43,4 +43,26 @@
(is (v:* *vector4* 2) #(14.0 16.0 18.0 20.0) "Multiply f4" :test #'equalp)
(is (v:/ *vector2* 5) #(0.4 0.6) "Divide f2" :test #'equalp)
(diag "Matrix Constructor Tests")
(is (m:mat 1 2 3 4 5 6 7 8 9 10 11 12) #2A((1.0 2.0 3.0 4.0) (5.0 6.0 7.0 8.0) (9.0 10.0 11.0 12.0))
"Matrix Constructor" :test #'equalp)
(defvar *matrix22* (f22:mat 1 2
3 4))
(defvar *matrix33* (f33:mat 1 2 3
4 5 6
7 8 9))
(defvar *matrix44* (f44:mat 1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16))
(is *matrix22* #2a((1.0 2.0) (3.0 4.0)) "Matrix22 Constructor" :test #'equalp)
(is *matrix33* #2a((1.0 2.0 3.0) (4.0 5.0 6.0) (7.0 8.0 9.0)) "Matrix33 Constructor" :test #'equalp)
(is *matrix44* #2a((1.0 2.0 3.0 4.0) (5.0 6.0 7.0 8.0) (9.0 10.0 11.0 12.0) (13.0 14.0 15.0 16.0))
"Matrix44 Constructor" :test #'equalp)
(diag "Simple Matrix Operations")
(is (m:+ *matrix22* (f22:mat-ident)) #2a((2.0 2.0) (3.0 5.0)) "Add f22" :test #'equalp)
(finalize)