Permalink
Browse files

Change crop_resized tests to resize_to_fill. Add tests for omitted 2n…

…d argument to resize_to_fill, resize_to_fit.
  • Loading branch information...
1 parent c325d23 commit d587148b64f383088d13305aba005d324f95cd59 rmagick committed Jan 5, 2008
Showing with 79 additions and 46 deletions.
  1. +0 −46 test/Image2.rb
  2. +79 −0 test/Image3.rb
View
@@ -155,52 +155,6 @@ def test_crop!
end
end
- def test_crop_resized_0
- changed = @img.crop_resized(@img.columns,@img.rows)
- assert_equal(@img.columns, changed.columns)
- assert_equal(@img.rows, changed.rows)
- assert_not_same(changed, @img)
- end
-
- def test_crop_resized_1
- @img = Magick::Image.new(200, 250)
- @img.crop_resized!(100,100)
- assert_equal(100, @img.columns)
- assert_equal(100, @img.rows)
- end
-
- def test_crop_resized_2
- @img = Magick::Image.new(200, 250)
- changed = @img.crop_resized(300,100)
- assert_equal(300, changed.columns)
- assert_equal(100, changed.rows)
- end
-
- def test_crop_resized_3
- @img = Magick::Image.new(200, 250)
- changed = @img.crop_resized(100,300)
- assert_equal(100, changed.columns)
- assert_equal(300, changed.rows)
- end
-
- def test_crop_resized_4
- @img = Magick::Image.new(200, 250)
- changed = @img.crop_resized(300,350)
- assert_equal(300, changed.columns)
- assert_equal(350, changed.rows)
- end
-
- def test_crop_resized_5
- changed = @img.crop_resized(20,400)
- assert_equal(20, changed.columns)
- assert_equal(400, changed.rows)
- end
- def test_crop_resized_6
- changed = @img.crop_resized(3000,400)
- assert_equal(3000, changed.columns)
- assert_equal(400, changed.rows)
- end
-
def test_cycle_colormap
assert_nothing_raised do
res = @img.cycle_colormap(5)
View
@@ -213,16 +213,95 @@ def test_resize!
assert_raise(FreezeError) { @img.resize!(0.50) }
end
+ def test_resize_to_fill_0
+ changed = @img.resize_to_fill(@img.columns,@img.rows)
+ assert_equal(@img.columns, changed.columns)
+ assert_equal(@img.rows, changed.rows)
+ assert_not_same(changed, @img)
+ end
+
+ def test_resize_to_fill_1
+ @img = Magick::Image.new(200, 250)
+ @img.resize_to_fill!(100,100)
+ assert_equal(100, @img.columns)
+ assert_equal(100, @img.rows)
+ end
+
+ def test_resize_to_fill_2
+ @img = Magick::Image.new(200, 250)
+ changed = @img.resize_to_fill(300,100)
+ assert_equal(300, changed.columns)
+ assert_equal(100, changed.rows)
+ end
+
+ def test_resize_to_fill_3
+ @img = Magick::Image.new(200, 250)
+ changed = @img.resize_to_fill(100,300)
+ assert_equal(100, changed.columns)
+ assert_equal(300, changed.rows)
+ end
+
+ def test_resize_to_fill_4
+ @img = Magick::Image.new(200, 250)
+ changed = @img.resize_to_fill(300,350)
+ assert_equal(300, changed.columns)
+ assert_equal(350, changed.rows)
+ end
+
+ def test_resize_to_fill_5
+ changed = @img.resize_to_fill(20,400)
+ assert_equal(20, changed.columns)
+ assert_equal(400, changed.rows)
+ end
+ def test_resize_to_fill_6
+ changed = @img.resize_to_fill(3000,400)
+ assert_equal(3000, changed.columns)
+ assert_equal(400, changed.rows)
+ end
+
+ # Make sure the old name is still around
+ def test_resize_to_fill_7
+ assert_block {@img.respond_to? :crop_resized}
+ assert_block {@img.respond_to? :crop_resized!}
+ end
+
+ # 2nd argument defaults to the same value as the 1st argument
+ def test_resize_to_fill_8
+ changed = @img.resize_to_fill(100)
+ assert_equal(100, changed.columns)
+ assert_equal(100, changed.rows)
+ end
+
def test_resize_to_fit
img = Magick::Image.new(200, 250)
res = nil
assert_nothing_raised { res = img.resize_to_fit(50, 50) }
assert_not_nil(res)
assert_instance_of(Magick::Image, res)
+ assert_not_same(img, res)
assert_equal(40, res.columns)
assert_equal(50, res.rows)
end
+ def test_resize_to_fit2
+ img = Magick::Image.new(200, 300)
+ changed = img.resize_to_fit(100)
+ assert_instance_of(Magick::Image, changed)
+ assert_not_same(img, changed)
+ assert_equal(67, changed.columns)
+ assert_equal(100, changed.rows)
+ end
+
+ def test_resize_to_fit3
+ img = Magick::Image.new(200, 300)
+ keep = img
+ img.resize_to_fit!(100)
+ assert_instance_of(Magick::Image, img)
+ assert_same(img, keep)
+ assert_equal(67, img.columns)
+ assert_equal(100, img.rows)
+ end
+
def test_roll
assert_nothing_raised do
res = @img.roll(5, 5)

0 comments on commit d587148

Please sign in to comment.