@@ -5,7 +5,8 @@ class TC_FXMat4f < Test::Unit::TestCase
55 include Fox
66
77 def setup
8- @hmat = FXMat4f . new
8+ @hmat = FXMat4f . new 59650271608832.0 , 1.52688322114599e+38 , 5.170800853465662e-13 , 2.0711191302720796e-42 , 1.0 , 2.2 , 2.586273209481682e-13 , 1.0355595651360398e-42 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 3.673819216381981e-39 , 7.006492321624085e-45 , 3.7991997507591117e-35
9+ @samples = [ -5.412440155462294e+24 , 9.504638999570352e+35 , 7.158709246972819e+30 , 1.0 , 2.2 , 3.3 , 4.4 , 1.0819492946742955e+37 , 66.6 , 777.7 , -4.0472602345783137e+31 , -33.3 , 5.332417885281655e+37 , -999.9 , 4.4 , -0.11 ]
910 end
1011
1112 def test_initialize
@@ -25,9 +26,9 @@ def test_from_elements
2526 a20 , a21 , a22 , a23 = 0.0 , 0.0 , 0.0 , 0.0
2627 a30 , a31 , a32 , a33 = 0.0 , 0.0 , 0.0 , 0.0
2728 h = FXMat4f . new ( a00 , a01 , a02 , a03 ,
28- a10 , a11 , a12 , a13 ,
29- a20 , a21 , a22 , a23 ,
30- a30 , a31 , a32 , a33 )
29+ a10 , a11 , a12 , a13 ,
30+ a20 , a21 , a22 , a23 ,
31+ a30 , a31 , a32 , a33 )
3132 assert_instance_of ( FXMat4f , h )
3233 end
3334
@@ -44,16 +45,16 @@ def test_copy
4445 anotherHMat = FXMat4f . new ( @hmat )
4546 assert_instance_of ( FXMat4f , anotherHMat )
4647 assert_not_same ( @hmat , anotherHMat )
47- # assert_equal(@hmat, anotherHMat)
48+ assert_equal ( @hmat , anotherHMat )
4849 end
4950
5051 def test_add
51- anotherMat = FXMat4f . new
52+ anotherMat = FXMat4f . new * @samples
5253 sum1 = anotherMat + @hmat
5354 sum2 = @hmat + anotherMat
5455 assert_instance_of ( FXMat4f , sum1 )
5556 assert_instance_of ( FXMat4f , sum2 )
56- # assert_equal(sum1, sum2)
57+ assert_equal ( sum1 , sum2 )
5758 end
5859
5960 def test_neg
@@ -62,31 +63,31 @@ def test_neg
6263 end
6364
6465 def test_sub
65- anotherMat = FXMat4f . new
66+ anotherMat = FXMat4f . new * @samples
6667 diff1 = anotherMat - @hmat
6768 diff2 = @hmat - anotherMat
6869 assert_instance_of ( FXMat4f , diff1 )
6970 assert_instance_of ( FXMat4f , diff2 )
70- # assert_equal(diff1, -diff2)
71+ assert_equal ( diff1 , -diff2 )
7172 end
7273
7374 def test_mul_matrices
74- a = FXMat4f . new
75- b = FXMat4f . new
75+ a = FXMat4f . new * @samples
76+ b = FXMat4f . new * @samples
7677 product = a *b
7778 assert_instance_of ( FXMat4f , product )
78- # assert_equal(product, b*a)
79+ assert_equal ( product , b *a )
7980 end
8081
8182 def test_mul_by_scalar
8283 p = FXMat4f . new . eye
8384 q = FXMat4f . new ( 4.0 , 0.0 , 0.0 , 0.0 ,
8485 0.0 , 4.0 , 0.0 , 0.0 ,
8586 0.0 , 0.0 , 4.0 , 0.0 ,
86- 0.0 , 0.0 , 0.0 , 4 .0)
87+ 0.0 , 0.0 , 0.0 , 1 .0)
8788 r = p *4.0
8889 assert_instance_of ( FXMat4f , r )
89- # assert_equal(q, r)
90+ assert_equal ( q , r )
9091 end
9192
9293 def test_div
@@ -225,4 +226,12 @@ def test_scale_vec
225226 scaled = @hmat . scale ( v )
226227 assert_same ( @hmat , scaled )
227228 end
229+
230+ def test_to_a
231+ assert_equal [ [ 59650271608832.0 , 1.52688322114599e+38 , 5.170800853465662e-13 , 2.0711191302720796e-42 ] , [ 1.0 , 2.200000047683716 , 2.586273209481682e-13 , 1.0355595651360398e-42 ] , [ 0.0 , 0.0 , 0.0 , 0.0 ] , [ 0.0 , 3.673819216381981e-39 , 7.006492321624085e-45 , 3.7991997507591117e-35 ] ] , @hmat . to_a
232+ end
233+
234+ def test_inspect
235+ assert_equal "[[59650271608832.0, 1.52688322114599e+38, 5.170800853465662e-13, 2.0711191302720796e-42], [1.0, 2.200000047683716, 2.586273209481682e-13, 1.0355595651360398e-42], [0.0, 0.0, 0.0, 0.0], [0.0, 3.673819216381981e-39, 7.006492321624085e-45, 3.7991997507591117e-35]]" , @hmat . inspect
236+ end
228237end
0 commit comments