test/test_triangle.rb in gmath3D-0.1.1 vs test/test_triangle.rb in gmath3D-0.2.0

- old
+ new

@@ -1,5 +1,8 @@ +$LOAD_PATH.unshift(File.dirname(__FILE__)) +require 'helper' + include GMath3D MiniTest::Unit.autorun class TriangleTestCase < MiniTest::Unit::TestCase @@ -16,10 +19,14 @@ assert_equal(Vector3.new(0,0,0), @triangle_default.vertices[0]) assert_equal(Vector3.new(1,0,0), @triangle_default.vertices[1]) assert_equal(Vector3.new(0,1,0), @triangle_default.vertices[2]) end + def test_to_s + assert_equal("Triangle[[1, 2, 2], [1, 4, 2], [-1, 3, 0]]", @triangle.to_s) + end + def test_point assert_equal(@triangle.vertices[0], @triangle.point( Array.new([1,0,0]))) assert_equal(@triangle.vertices[1], @triangle.point( Array.new([0,1,0]))) assert_equal(@triangle.vertices[2], @triangle.point( Array.new([0,0,1]))) @@ -107,16 +114,16 @@ end end def test_contains check_point = @triangle.center + @triangle.normal*3.0 - assert( !@triangle.contains( check_point) ) - assert( @triangle.contains( @triangle.center) ) - assert( @triangle.contains( Vector3.new( 1,3,2))) - assert( @triangle.contains( Vector3.new(-1,3,0))) - assert( @triangle_default.contains( Vector3.new( 0.5, 0.5, 0.0 ) )) - assert( !@triangle_default.contains( Vector3.new( -1.0, 2.0, 0.0 ))) - assert( !@triangle_default.contains( Vector3.new( 1.0, 1.0, 0.0 ))) + assert( !@triangle.contains?( check_point) ) + assert( @triangle.contains?( @triangle.center) ) + assert( @triangle.contains?( Vector3.new( 1,3,2))) + assert( @triangle.contains?( Vector3.new(-1,3,0))) + assert( @triangle_default.contains?( Vector3.new( 0.5, 0.5, 0.0 ) )) + assert( !@triangle_default.contains?( Vector3.new( -1.0, 2.0, 0.0 ))) + assert( !@triangle_default.contains?( Vector3.new( 1.0, 1.0, 0.0 ))) end def test_distance_to_point # on inside check_point = @triangle.center + @triangle.normal*3.0