Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

104 lines (75 sloc) 3.087 kb
#! /usr/local/bin/ruby -w
require 'RMagick'
require 'test/unit'
require 'test/unit/ui/console/testrunner'
class Info_UT < Test::Unit::TestCase
def setup
@info = Magick::Image::Info.new
end
def test_options
# 1-argument form
assert_nothing_raised { @info['fill'] }
assert_nil(@info['fill'])
assert_nothing_raised { @info['fill'] = 'red' }
assert_equal("red", @info['fill'])
assert_nothing_raised { @info['fill'] = nil }
assert_nil(@info['fill'])
# 2-argument form
assert_nothing_raised { @info['tiff', 'bits-per-sample'] = 2 }
assert_equal("2", @info['tiff', 'bits-per-sample'])
# define and undefine
assert_nothing_raised { @info.define('tiff', 'bits-per-sample', 4) }
assert_equal("4", @info['tiff', 'bits-per-sample'])
assert_nothing_raised { @info.undefine('tiff', 'bits-per-sample') }
assert_nil(@info['tiff', 'bits-per-sample'])
end
def test_attenuate
assert_nothing_raised { @info.attenuate = 10 }
assert_equal(10, @info.attenuate)
assert_nothing_raised { @info.attenuate = 5.25 }
assert_equal(5.25, @info.attenuate)
assert_nothing_raised { @info.attenuate = nil }
assert_equal(nil, @info.attenuate)
end
def test_channel
assert_nothing_raised { @info.channel(Magick::RedChannel) }
assert_nothing_raised { @info.channel(Magick::RedChannel, Magick::BlueChannel) }
assert_raise(TypeError) { @info.channel(1) }
assert_raise(TypeError) { @info.channel(Magick::RedChannel, 1) }
end
def test_fill
assert_nothing_raised { @info.fill }
assert_nil(@info.fill)
assert_nothing_raised { @info.fill = 'white' }
assert_equal("white", @info.fill)
assert_nothing_raised { @info.fill = nil }
assert_nil(@info.fill)
assert_raise(ArgumentError) { @info.fill = 'xxx' }
end
def test_stroke
assert_nothing_raised { @info.stroke }
assert_nil(@info.stroke)
assert_nothing_raised { @info.stroke = 'white' }
assert_equal("white", @info.stroke)
assert_nothing_raised { @info.stroke = nil }
assert_nil(@info.stroke)
assert_raise(ArgumentError) { @info.stroke = 'xxx' }
end
def test_stroke_width
assert_nothing_raised { @info.stroke_width = 10 }
assert_equal(10, @info.stroke_width)
assert_nothing_raised { @info.stroke_width = 5.25 }
assert_equal(5.25, @info.stroke_width)
assert_nothing_raised { @info.stroke_width = nil }
assert_equal(nil, @info.stroke_width)
end
def test_undercolor
assert_nothing_raised { @info.undercolor }
assert_nil(@info.undercolor)
assert_nothing_raised { @info.undercolor = 'white' }
assert_equal("white", @info.undercolor)
assert_nothing_raised { @info.undercolor = nil }
assert_nil(@info.undercolor)
assert_raise(ArgumentError) { @info.undercolor = 'xxx' }
end
end
Jump to Line
Something went wrong with that request. Please try again.