test/Image2.rb in rmagick-2.13.4 vs test/Image2.rb in rmagick-2.14.0
- old
+ new
@@ -1,14 +1,13 @@
-#! /usr/local/bin/ruby -w
+#!/usr/bin/env ruby -w
-require 'RMagick'
+require 'rmagick'
require 'test/unit'
-require 'test/unit/ui/console/testrunner' if !RUBY_VERSION[/^1\.9|^2/]
+require 'test/unit/ui/console/testrunner' unless RUBY_VERSION[/^1\.9|^2/]
# TODO: improve exif tests - need a benchmark image with EXIF data
-
class Image2_UT < Test::Unit::TestCase
FreezeError = RUBY_VERSION[/^1\.9|^2/] ? RuntimeError : TypeError
def setup
@img = Magick::Image.new(20, 20)
@@ -36,11 +35,11 @@
end
end
def test_composite_mathematics
bg = Magick::Image.new(50, 50)
- fg = Magick::Image.new(50, 50) {self.background_color = "black" }
+ fg = Magick::Image.new(50, 50) {self.background_color = 'black' }
res = nil
assert_nothing_raised { res = bg.composite_mathematics(fg, 1, 0, 0, 0, Magick::CenterGravity) }
assert_instance_of(Magick::Image, res)
assert_not_same(bg, res)
assert_not_same(fg, res)
@@ -53,11 +52,11 @@
assert_raise(ArgumentError) { bg.composite_mathematics(fg, 1, 0, 0, 0, Magick::CenterGravity, 0.0, 0.0, 'x') }
end
def test_composite_tiled
bg = Magick::Image.new(200,200)
- fg = Magick::Image.new(50,100) { self.background_color = "black" }
+ fg = Magick::Image.new(50,100) { self.background_color = 'black' }
res = nil
assert_nothing_raised do
res = bg.composite_tiled(fg)
end
assert_instance_of(Magick::Image, res)
@@ -106,11 +105,10 @@
assert_nothing_raised { @img.contrast_stretch_channel(25, 50, Magick::RedChannel, Magick::GreenChannel) }
assert_raise(TypeError) { @img.contrast_stretch_channel(25, 50, 'x') }
assert_raise(ArgumentError) { @img.contrast_stretch_channel }
assert_raise(ArgumentError) { @img.contrast_stretch_channel('x') }
assert_raise(ArgumentError) { @img.contrast_stretch_channel(25, 'x') }
-
end
def test_convolve
kernel = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
order = 3
@@ -120,11 +118,11 @@
assert_not_same(@img, res)
end
assert_raise(ArgumentError) { @img.convolve }
assert_raise(ArgumentError) { @img.convolve(order) }
assert_raise(IndexError) { @img.convolve(5, kernel) }
- assert_raise(IndexError) { @img.convolve(order, "x") }
+ assert_raise(IndexError) { @img.convolve(order, 'x') }
assert_raise(TypeError) { @img.convolve(3, [1.0, 1.0, 1.0, 1.0, 'x', 1.0, 1.0, 1.0, 1.0]) }
assert_raise(Magick::ImageMagickError) { @img.convolve(-1, [1.0, 1.0, 1.0, 1.0]) }
end
def test_convolve_channel
@@ -161,15 +159,15 @@
res = @img.crop(0, 0, @img.columns/2, @img.rows/2)
assert_instance_of(Magick::Image, res)
assert_not_same(@img, res)
end
gravity = [
- Magick::NorthEastGravity,
- Magick::EastGravity,
- Magick::SouthWestGravity,
- Magick::SouthGravity,
- Magick::SouthEastGravity]
+ Magick::NorthEastGravity,
+ Magick::EastGravity,
+ Magick::SouthWestGravity,
+ Magick::SouthGravity,
+ Magick::SouthEastGravity]
# 3-argument form
gravity.each do |grav|
assert_nothing_raised { @img.crop(grav, @img.columns/2, @img.rows/2) }
end
@@ -208,12 +206,12 @@
end
def test_decipher # tests encipher, too.
res = res2 = nil
assert_nothing_raised do
- res = @img.encipher "passphrase"
- res2 = res.decipher "passphrase"
+ res = @img.encipher 'passphrase'
+ res2 = res.decipher 'passphrase'
end
assert_instance_of(Magick::Image, res)
assert_not_same(@img, res)
assert_equal(@img.columns, res.columns)
assert_equal(@img.rows, res.rows)
@@ -223,25 +221,25 @@
assert_equal(@img.rows, res2.rows)
assert_equal(@img, res2)
end
def test_define
- assert_nothing_raised { @img.define("deskew:auto-crop", 40) }
- assert_nothing_raised { @img.undefine("deskew:auto-crop") }
+ assert_nothing_raised { @img.define('deskew:auto-crop', 40) }
+ assert_nothing_raised { @img.undefine('deskew:auto-crop') }
end
def test_deskew
assert_nothing_raised do
res = @img.deskew
assert_instance_of(Magick::Image, res)
assert_not_same(@img, res)
- end
+ end
assert_nothing_raised { @img.deskew(0.10) }
- assert_nothing_raised { @img.deskew("95%") }
- assert_raise(ArgumentError) { @img.deskew("x") }
- assert_raise(TypeError) {@img.deskew(0.40, "x") }
+ assert_nothing_raised { @img.deskew('95%') }
+ assert_raise(ArgumentError) { @img.deskew('x') }
+ assert_raise(TypeError) {@img.deskew(0.40, 'x') }
assert_raise(ArgumentError) {@img.deskew(0.40, 20, [1]) }
end
def test_despeckle
assert_nothing_raised do
@@ -268,18 +266,18 @@
methods.each do |method|
arity = @img.method(method).arity
method = method.to_s
case
- when method == "[]="
+ when method == '[]='
assert_raises(Magick::DestroyedImageError) { @img['foo'] = 1 }
- when method == "difference"
+ when method == 'difference'
other = Magick::Image.new(20,20)
assert_raises(Magick::DestroyedImageError) { @img.difference(other) }
- when method == "get_iptc_dataset"
+ when method == 'get_iptc_dataset'
assert_raises(Magick::DestroyedImageError) { @img.get_iptc_dataset('x') }
- when method == "profile!"
+ when method == 'profile!'
assert_raises(Magick::DestroyedImageError) { @img.profile!('x', 'y') }
when /=\Z/.match(method)
assert_raises(Magick::DestroyedImageError) { @img.send(method, 1) }
when arity == 0
assert_raises(Magick::DestroyedImageError) { @img.send(method) }
@@ -289,48 +287,49 @@
when arity > 0
args = (1..(arity)).to_a
assert_raises(Magick::DestroyedImageError) { @img.send(method, *args) }
else
# Don't know how to test!
- flunk("don't know how to test method #{method}" )
+ flunk("don't know how to test method #{method}")
end
end
end
# ensure destroy! works
def test_destroy2
- begin # ensure Magick.trace_proc gets set to nil even if this test asserts
- images = {}
- GC.disable
- Magick.trace_proc = Proc.new do |which, id, addr, method|
- m = id.split(/ /)
- name = File.basename m[0]
- format = m[1]
- size = m[2]
- geometry = m[3]
- image_class = m[4]
+ images = {}
+ GC.disable
- assert(which == :c || which == :d, "unexpected value for which: #{which}")
- assert_equal(:destroy!, method) if which == :d
- if which == :c
- assert(!images.has_key?(addr), "duplicate image addresses")
- images[addr] = name
- else
- assert(images.has_key?(addr), "destroying image that was not created")
- assert_equal(name, images[addr])
- end
- end
- unmapped = Magick::ImageList.new(IMAGES_DIR+"/Hot_Air_Balloons.jpg", IMAGES_DIR+"/Violin.jpg", IMAGES_DIR+"/Polynesia.jpg")
- map = Magick::ImageList.new "netscape:"
- mapped = unmapped.map map, false
- unmapped.each {|i| i.destroy!}
- map.destroy!
- mapped.each {|i| i.destroy!}
- ensure
- GC.enable
- Magick.trace_proc = nil
+ Magick.trace_proc = proc do |which, id, addr, method|
+ m = id.split(/ /)
+ name = File.basename m[0]
+ format = m[1]
+ size = m[2]
+ geometry = m[3]
+ image_class = m[4]
+
+ assert(which == :c || which == :d, "unexpected value for which: #{which}")
+ assert_equal(:destroy!, method) if which == :d
+
+ if which == :c
+ assert(!images.has_key?(addr), 'duplicate image addresses')
+ images[addr] = name
+ else
+ assert(images.has_key?(addr), 'destroying image that was not created')
+ assert_equal(name, images[addr])
end
+ end
+
+ unmapped = Magick::ImageList.new(IMAGES_DIR+'/Hot_Air_Balloons.jpg', IMAGES_DIR+'/Violin.jpg', IMAGES_DIR+'/Polynesia.jpg')
+ map = Magick::ImageList.new 'netscape:'
+ mapped = unmapped.map map, false
+ unmapped.each {|i| i.destroy!}
+ map.destroy!
+ mapped.each {|i| i.destroy!}
+ ensure
+ GC.enable
+ Magick.trace_proc = nil
end
def test_difference
img1 = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
img2 = Magick::Image.read(IMAGES_DIR+'/Button_1.gif').first
@@ -347,11 +346,11 @@
img2.destroy!
assert_raise(Magick::DestroyedImageError) { img1.difference(img2) }
end
def test_displace
- @img2 = Magick::Image.new(20,20) {self.background_color = "black"}
+ @img2 = Magick::Image.new(20,20) {self.background_color = 'black'}
assert_nothing_raised { @img.displace(@img2, 25) }
res = @img.displace(@img2, 25)
assert_instance_of(Magick::Image, res)
assert_not_same(@img, res)
assert_nothing_raised { @img.displace(@img2, 25, 25) }
@@ -373,11 +372,11 @@
def test_dissolve
src = Magick::Image.new(@img.columns, @img.rows)
src_list = Magick::ImageList.new
src_list << src.copy
- assert_nothing_raised { @img.dissolve(src, 0.50 ) }
+ assert_nothing_raised { @img.dissolve(src, 0.50) }
assert_nothing_raised { @img.dissolve(src_list, 0.50) }
assert_nothing_raised { @img.dissolve(src, '50%') }
assert_nothing_raised { @img.dissolve(src, 0.50, 0.10) }
assert_nothing_raised { @img.dissolve(src, 0.50, 0.10, 10) }
assert_nothing_raised { @img.dissolve(src, 0.50, 0.10, Magick::NorthEastGravity) }
@@ -437,19 +436,19 @@
ditto = @img.dup
assert_equal(@img.tainted?, ditto.tainted?)
end
def test_each_profile
- @img.iptc_profile = "test profile"
+ @img.iptc_profile = 'test profile'
assert_nothing_raised do
@img.each_profile do |name, value|
- assert_equal("iptc", name)
+ assert_equal('iptc', name)
# As of 6.3.1
- if IM_VERSION < Gem::Version.new("6.6.4") || (IM_VERSION == Gem::Version.new("6.6.4") && IM_REVISION < Gem::Version.new("5"))
+ if IM_VERSION < Gem::Version.new('6.6.4') || (IM_VERSION == Gem::Version.new('6.6.4') && IM_REVISION < Gem::Version.new('5'))
assert_equal("8BIM\004\004\000\000\000\000\001\340test profile", value)
else
- assert_equal("test profile", value)
+ assert_equal('test profile', value)
end
end
end
end
@@ -483,11 +482,10 @@
assert_instance_of(Magick::Image, res)
assert_not_same(@img, res)
end
end
-
def test_equalize
assert_nothing_raised do
res = @img.equalize
assert_instance_of(Magick::Image, res)
assert_not_same(@img, res)
@@ -528,82 +526,81 @@
def test_export_pixels
assert_nothing_raised do
res = @img.export_pixels
assert_instance_of(Array, res)
- assert_equal(@img.columns*@img.rows*"RGB".length, res.length)
+ assert_equal(@img.columns*@img.rows*'RGB'.length, res.length)
res.each do |p|
assert_kind_of(Integer, p)
end
end
assert_nothing_raised { res = @img.export_pixels(0) }
assert_nothing_raised { res = @img.export_pixels(0, 0) }
assert_nothing_raised { res = @img.export_pixels(0, 0, 10) }
assert_nothing_raised { res = @img.export_pixels(0, 0, 10, 10) }
assert_nothing_raised do
res = @img.export_pixels(0, 0, 10, 10, 'RGBA')
- assert_equal(10*10*"RGBA".length, res.length)
- end
+ assert_equal(10*10*'RGBA'.length, res.length)
+ end
assert_nothing_raised do
res = @img.export_pixels(0, 0, 10, 10, 'I')
- assert_equal(10*10*"I".length, res.length)
+ assert_equal(10*10*'I'.length, res.length)
end
# too many arguments
assert_raise(ArgumentError) { @img.export_pixels(0, 0, 10, 10, 'I', 2) }
-
end
def test_export_pixels_to_str
assert_nothing_raised do
res = @img.export_pixels_to_str
assert_instance_of(String, res)
- assert_equal(@img.columns*@img.rows*"RGB".length, res.length)
+ assert_equal(@img.columns*@img.rows*'RGB'.length, res.length)
end
assert_nothing_raised { @img.export_pixels_to_str(0) }
assert_nothing_raised { @img.export_pixels_to_str(0, 0) }
assert_nothing_raised { @img.export_pixels_to_str(0, 0, 10) }
assert_nothing_raised { @img.export_pixels_to_str(0, 0, 10, 10) }
assert_nothing_raised do
- res = @img.export_pixels_to_str(0, 0, 10, 10, "RGBA")
- assert_equal(10*10*"RGBA".length, res.length)
+ res = @img.export_pixels_to_str(0, 0, 10, 10, 'RGBA')
+ assert_equal(10*10*'RGBA'.length, res.length)
end
assert_nothing_raised do
- res = @img.export_pixels_to_str(0, 0, 10, 10, "I")
- assert_equal(10*10*"I".length, res.length)
+ res = @img.export_pixels_to_str(0, 0, 10, 10, 'I')
+ assert_equal(10*10*'I'.length, res.length)
end
assert_nothing_raised do
- res = @img.export_pixels_to_str(0, 0, 10, 10, "I", Magick::CharPixel)
+ res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::CharPixel)
assert_equal(10*10*1, res.length)
end
assert_nothing_raised do
- res = @img.export_pixels_to_str(0, 0, 10, 10, "I", Magick::ShortPixel)
+ res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::ShortPixel)
assert_equal(10*10*2, res.length)
end
assert_nothing_raised do
- res = @img.export_pixels_to_str(0, 0, 10, 10, "I", Magick::IntegerPixel)
+ res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::IntegerPixel)
assert_equal(10*10*4, res.length)
end
assert_nothing_raised do
- res = @img.export_pixels_to_str(0, 0, 10, 10, "I", Magick::LongPixel)
- assert_equal(10*10*[1].pack("L!").length, res.length)
+ res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::LongPixel)
+ assert_equal(10*10*[1].pack('L!').length, res.length)
end
assert_nothing_raised do
- res = @img.export_pixels_to_str(0, 0, 10, 10, "I", Magick::FloatPixel)
+ res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::FloatPixel)
assert_equal(10*10*4, res.length)
end
assert_nothing_raised do
- res = @img.export_pixels_to_str(0, 0, 10, 10, "I", Magick::DoublePixel)
+ res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::DoublePixel)
assert_equal(10*10*8, res.length)
end
- assert_nothing_raised { @img.export_pixels_to_str(0, 0, 10, 10, "I", Magick::QuantumPixel) }
+ assert_nothing_raised { @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::QuantumPixel) }
# too many arguments
- assert_raise(ArgumentError) { @img.export_pixels_to_str(0, 0, 10, 10, "I", Magick::QuantumPixel, 1) }
+ assert_raise(ArgumentError) { @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::QuantumPixel, 1) }
# last arg s/b StorageType
- assert_raise(TypeError) { @img.export_pixels_to_str(0, 0, 10, 10, "I", 2) }
+ assert_raise(TypeError) { @img.export_pixels_to_str(0, 0, 10, 10, 'I', 2) }
end
def test_extent
assert_nothing_raised { @img.extent(40, 40) }
res = @img.extent(40, 40)
@@ -620,11 +617,11 @@
assert_raises(TypeError) { @img.extent(40, 40, 'x') }
assert_raises(TypeError) { @img.extent(40, 40, 5, 'x') }
end
def test_find_similar_region
- girl = Magick::Image.read(IMAGES_DIR+"/Flower_Hat.jpg").first
+ girl = Magick::Image.read(IMAGES_DIR+'/Flower_Hat.jpg').first
region = girl.crop(10, 10, 50, 50)
assert_nothing_raised do
x, y = girl.find_similar_region(region)
assert_not_nil(x)
assert_not_nil(y)
@@ -648,21 +645,19 @@
x, y = girl.find_similar_region(list, 0, 0)
assert_equal(10, x)
assert_equal(10, y)
end
-
x = girl.find_similar_region(@img)
assert_nil(x)
assert_raise(ArgumentError) { girl.find_similar_region(region, 10, 10, 10) }
assert_raise(TypeError) { girl.find_similar_region(region, 10, 'x') }
assert_raise(TypeError) { girl.find_similar_region(region, 'x') }
region.destroy!
assert_raise(Magick::DestroyedImageError) { girl.find_similar_region(region) }
-
end
def test_flip
assert_nothing_raised do
res = @img.flip
@@ -722,11 +717,11 @@
assert_nothing_raised { @img.gamma_channel(0.8, Magick::RedChannel, Magick::BlueChannel) }
assert_raise(TypeError) { @img.gamma_channel(0.8, Magick::RedChannel, 2) }
end
def test_function_channel
- img = Magick::Image.read("gradient:") {self.size = "20x600"}
+ img = Magick::Image.read('gradient:') {self.size = '20x600'}
img = img.first
img.rotate!(90)
assert_nothing_raised { img.function_channel Magick::PolynomialFunction, 0.33 }
assert_nothing_raised { img.function_channel Magick::PolynomialFunction, 4, -1.5 }
assert_nothing_raised { img.function_channel Magick::PolynomialFunction, 4, -4, 1 }
@@ -823,14 +818,14 @@
assert_equal(@img.columns, pixels.length)
assert_block do
pixels.all? { |p| p.is_a? Magick::Pixel }
end
end
- assert_raise(RangeError) { @img.get_pixels( 0, 0, -1, 1) }
- assert_raise(RangeError) { @img.get_pixels( 0, 0, @img.columns, -1) }
- assert_raise(RangeError) { @img.get_pixels( 0, 0, @img.columns+1, 1) }
- assert_raise(RangeError) { @img.get_pixels( 0, 0, @img.columns, @img.rows+1) }
+ assert_raise(RangeError) { @img.get_pixels(0, 0, -1, 1) }
+ assert_raise(RangeError) { @img.get_pixels(0, 0, @img.columns, -1) }
+ assert_raise(RangeError) { @img.get_pixels(0, 0, @img.columns+1, 1) }
+ assert_raise(RangeError) { @img.get_pixels(0, 0, @img.columns, @img.rows+1) }
end
def test_gray?
gray = Magick::Image.new(20, 20) { self.background_color = 'gray50' }
assert(gray.gray?)
@@ -850,36 +845,36 @@
assert_not_same(@img, res)
end
end
def test_import_pixels
- pixels = @img.export_pixels(0, 0, @img.columns, 1, "RGB")
+ pixels = @img.export_pixels(0, 0, @img.columns, 1, 'RGB')
assert_nothing_raised do
- res = @img.import_pixels(0, 0, @img.columns, 1, "RGB", pixels)
+ res = @img.import_pixels(0, 0, @img.columns, 1, 'RGB', pixels)
assert_same(@img, res)
end
assert_raise(ArgumentError) { @img.import_pixels }
assert_raise(ArgumentError) { @img.import_pixels(0) }
assert_raise(ArgumentError) { @img.import_pixels(0, 0) }
assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns) }
assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, 1) }
- assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, 1, "RGB") }
- assert_raise(TypeError) { @img.import_pixels('x', 0, @img.columns, 1, "RGB", pixels) }
- assert_raise(TypeError) { @img.import_pixels(0, 'x', @img.columns, 1, "RGB", pixels) }
- assert_raise(TypeError) { @img.import_pixels(0, 0, 'x', 1, "RGB", pixels) }
- assert_raise(TypeError) { @img.import_pixels(0, 0, @img.columns, 'x', "RGB", pixels) }
+ assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, 1, 'RGB') }
+ assert_raise(TypeError) { @img.import_pixels('x', 0, @img.columns, 1, 'RGB', pixels) }
+ assert_raise(TypeError) { @img.import_pixels(0, 'x', @img.columns, 1, 'RGB', pixels) }
+ assert_raise(TypeError) { @img.import_pixels(0, 0, 'x', 1, 'RGB', pixels) }
+ assert_raise(TypeError) { @img.import_pixels(0, 0, @img.columns, 'x', 'RGB', pixels) }
assert_raise(TypeError) { @img.import_pixels(0, 0, @img.columns, 1, [2], pixels) }
- assert_raise(ArgumentError) { @img.import_pixels(-1, 0, @img.columns, 1, "RGB", pixels) }
- assert_raise(ArgumentError) { @img.import_pixels(0, -1, @img.columns, 1, "RGB", pixels) }
- assert_raise(ArgumentError) { @img.import_pixels(0, 0, -1, 1, "RGB", pixels) }
- assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, -1, "RGB", pixels) }
+ assert_raise(ArgumentError) { @img.import_pixels(-1, 0, @img.columns, 1, 'RGB', pixels) }
+ assert_raise(ArgumentError) { @img.import_pixels(0, -1, @img.columns, 1, 'RGB', pixels) }
+ assert_raise(ArgumentError) { @img.import_pixels(0, 0, -1, 1, 'RGB', pixels) }
+ assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, -1, 'RGB', pixels) }
# pixel array is too small
- assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, 2, "RGB", pixels) }
+ assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, 2, 'RGB', pixels) }
# pixel array doesn't contain a multiple of the map length
pixels.shift
- assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, 1, "RGB", pixels) }
+ assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, 1, 'RGB', pixels) }
end
def test_level
assert_nothing_raised do
res = @img.level
@@ -926,26 +921,26 @@
end
def level_colors
res = nil
assert_nothing_raised do
- res = @img.level_colors()
+ res = @img.level_colors
end
assert_instance_of(Magick::Image, res)
assert_not_same(@img, res)
- assert_nothing_raised { @img.level_colors("black") }
- assert_nothing_raised { @img.level_colors("black", Pixel.new(0,0,0)) }
+ assert_nothing_raised { @img.level_colors('black') }
+ assert_nothing_raised { @img.level_colors('black', Pixel.new(0,0,0)) }
assert_nothing_raised { @img.level_colors(Pixel.new(0,0,0), Pixel.new(Magick::QuantumRange,Magick::QuantumRange,Magick::QuantumRange)) }
- assert_nothing_raised { @img.level_colors("black", "white") }
- assert_nothing_raised { @img.level_colors("black", "white", false) }
+ assert_nothing_raised { @img.level_colors('black', 'white') }
+ assert_nothing_raised { @img.level_colors('black', 'white', false) }
# too many arguments
- assert_raises(ArgumentError) { @img.level_colors("black", "white", false, 1) }
+ assert_raises(ArgumentError) { @img.level_colors('black', 'white', false, 1) }
# not a pixel or a string
assert_raises(ArgumentError) { @img.level_colors([]) }
# not a color name
- assert_raises(ArgumentError) { @img.level_colors("xxx") }
+ assert_raises(ArgumentError) { @img.level_colors('xxx') }
end
def levelize_channel
res = nil
assert_nothing_raised do
@@ -958,38 +953,36 @@
assert_nothing_raised { @img.levelize_channel(0, Magick::QuantumRange, 0.5, Magick::RedChannel) }
assert_nothing_raised { @img.levelize_channel(0, Magick::QuantumRange, 0.5, Magick::RedChannel, Magick::BlueChannel) }
# too many arguments
assert_raise(ArgumentError) { @img.levelize_channel(0, Magick::QuantumRange, 0.5, 1, Magick::RedChannel) }
# not enough arguments
- assert_raise(ArgumentError) { @img.levelize_channel() }
+ assert_raise(ArgumentError) { @img.levelize_channel }
end
-=begin
- def test_liquid_rescale
- begin
- @img.liquid_rescale(15,15)
- rescue NotImplementedError
- puts "liquid_rescale not implemented."
- return
- end
+# def test_liquid_rescale
+# begin
+# @img.liquid_rescale(15,15)
+# rescue NotImplementedError
+# puts "liquid_rescale not implemented."
+# return
+# end
+#
+# res = nil
+# assert_nothing_raised do
+# res = @img.liquid_rescale(15, 15)
+# end
+# assert_equal(15, res.columns)
+# assert_equal(15, res.rows)
+# assert_nothing_raised { @img.liquid_rescale(15, 15, 0, 0) }
+# assert_raise(ArgumentError) { @img.liquid_rescale(15) }
+# assert_raise(ArgumentError) { @img.liquid_rescale(15, 15, 0, 0, 0) }
+# assert_raise(TypeError) { @img.liquid_rescale([], 15) }
+# assert_raise(TypeError) { @img.liquid_rescale(15, []) }
+# assert_raise(TypeError) { @img.liquid_rescale(15, 15, []) }
+# assert_raise(TypeError) { @img.liquid_rescale(15, 15, 0, []) }
+# end
- res = nil
- assert_nothing_raised do
- res = @img.liquid_rescale(15, 15)
- end
- assert_equal(15, res.columns)
- assert_equal(15, res.rows)
- assert_nothing_raised { @img.liquid_rescale(15, 15, 0, 0) }
- assert_raise(ArgumentError) { @img.liquid_rescale(15) }
- assert_raise(ArgumentError) { @img.liquid_rescale(15, 15, 0, 0, 0) }
- assert_raise(TypeError) { @img.liquid_rescale([], 15) }
- assert_raise(TypeError) { @img.liquid_rescale(15, []) }
- assert_raise(TypeError) { @img.liquid_rescale(15, 15, []) }
- assert_raise(TypeError) { @img.liquid_rescale(15, 15, 0, []) }
- end
-=end
-
def test_magnify
assert_nothing_raised do
res = @img.magnify
assert_instance_of(Magick::Image, res)
assert_not_same(@img, res)
@@ -998,11 +991,11 @@
res = @img.magnify!
assert_same(@img, res)
end
def test_map
- map = Magick::Image.read("netscape:").first
+ map = Magick::Image.read('netscape:').first
assert_nothing_raised do
res = @img.map(map)
assert_instance_of(Magick::Image, res)
assert_not_same(@img, res)
end
@@ -1238,31 +1231,31 @@
assert_raise(ArgumentError) { @img.ordered_dither(2, 1) }
end
def test_paint_transparent
res = nil
- assert_nothing_raised { res = @img.paint_transparent("red") }
+ assert_nothing_raised { res = @img.paint_transparent('red') }
assert_not_nil(res)
assert_instance_of(Magick::Image, res)
assert_not_same(res, @img)
- assert_nothing_raised { @img.paint_transparent("red", Magick::TransparentOpacity) }
- assert_nothing_raised { @img.paint_transparent("red", Magick::TransparentOpacity, true) }
- assert_nothing_raised { @img.paint_transparent("red", Magick::TransparentOpacity, true, 50) }
+ assert_nothing_raised { @img.paint_transparent('red', Magick::TransparentOpacity) }
+ assert_nothing_raised { @img.paint_transparent('red', Magick::TransparentOpacity, true) }
+ assert_nothing_raised { @img.paint_transparent('red', Magick::TransparentOpacity, true, 50) }
# Too many arguments
- assert_raise(ArgumentError) { @img.paint_transparent("red", Magick::TransparentOpacity, true, 50, 50) }
+ assert_raise(ArgumentError) { @img.paint_transparent('red', Magick::TransparentOpacity, true, 50, 50) }
# Not enough
- assert_raise(ArgumentError) { @img.paint_transparent() }
- assert_raise(TypeError) { @img.paint_transparent("red", Magick::TransparentOpacity, true, []) }
- assert_raise(TypeError) { @img.paint_transparent("red", "blue") }
+ assert_raise(ArgumentError) { @img.paint_transparent }
+ assert_raise(TypeError) { @img.paint_transparent('red', Magick::TransparentOpacity, true, []) }
+ assert_raise(TypeError) { @img.paint_transparent('red', 'blue') }
assert_raise(TypeError) { @img.paint_transparent(50) }
end
def test_palette?
img = Magick::Image.read(IMAGES_DIR+'/Flower_Hat.jpg').first
assert_nothing_raised do
- assert_block { ! img.palette? }
+ assert_block { !img.palette? }
end
img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
assert_block { img.palette? }
end
@@ -1300,13 +1293,12 @@
end
assert_nothing_raised { @img.posterize(5) }
assert_nothing_raised { @img.posterize(5, true) }
assert_raise(ArgumentError) { @img.posterize(5, true, 'x') }
end
-
end
-if __FILE__ == $0
+if __FILE__ == $PROGRAM_NAME
IMAGES_DIR = '../doc/ex/images'
FILES = Dir[IMAGES_DIR+'/Button_*.gif']
-Test::Unit::UI::Console::TestRunner.run(Image2_UT) if !RUBY_VERSION[/^1\.9|^2/]
+Test::Unit::UI::Console::TestRunner.run(Image2_UT) unless RUBY_VERSION[/^1\.9|^2/]
end