test/geometry/point.rb in geometry-2 vs test/geometry/point.rb in geometry-3
- old
+ new
@@ -1,11 +1,11 @@
-require_relative 'helper'
-require_relative '../lib/geometry/point'
+require_relative '../helper'
+require_relative '../../lib/geometry/point'
-class PointTest < Test::Unit::TestCase
- Point = Geometry::Point
+Point = Geometry::Point
+class PointTest < Test::Unit::TestCase
must "create a Point object using list syntax" do
point = Geometry::Point[2,1]
assert_equal(2, point.size)
assert_equal(2, point.x)
assert_equal(1, point.y)
@@ -82,7 +82,22 @@
assert_equal('Point[8, 9]', point.inspect)
end
must "implement to_s" do
point = Geometry::Point[10,11]
assert_equal('Point[10, 11]', point.to_s)
+ end
+end
+
+class PointArithmeticTest < Test::Unit::TestCase
+ def setup
+ @left = Point[1,2]
+ @right = Point[3,4]
+ end
+
+ must "return a Point when adding two Points" do
+ assert_kind_of(Point, @left+@right)
+ end
+
+ must "return a Point when subtracting two Points" do
+ assert_kind_of(Point, @left-@right)
end
end