rmagick 2.15.0 → 2.15.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rmagick might be problematic. Click here for more details.

@@ -0,0 +1,25 @@
1
+ RSpec.describe Magick::ImageList do
2
+ # issue 202
3
+ describe 'images_from_imagelist' do
4
+ it 'works with identical instances' do
5
+ expect do
6
+ img = Magick::Image.new(1, 1)
7
+ list = Magick::ImageList.new
8
+ list << img << img
9
+ res = list.append(false)
10
+ expect(res.columns).to eq(2)
11
+ expect(res.rows).to eq(1)
12
+ end.not_to raise_error
13
+
14
+ expect do
15
+ img = Magick::Image.new(1, 1)
16
+ img2 = Magick::Image.new(3, 3)
17
+ list = Magick::ImageList.new
18
+ list.concat([img, img2, img, img2, img])
19
+ res = list.append(false)
20
+ expect(res.columns).to eq(9)
21
+ expect(res.rows).to eq(3)
22
+ end.not_to raise_error
23
+ end
24
+ end
25
+ end
@@ -10,46 +10,46 @@ class Image2_UT < Test::Unit::TestCase
10
10
  FreezeError = RUBY_VERSION[/^1\.9|^2/] ? RuntimeError : TypeError
11
11
 
12
12
  def setup
13
- @img = Magick::Image.new(20, 20)
13
+ @img = Magick::Image.new(20, 20)
14
14
  end
15
15
 
16
16
  def test_composite!
17
- img1 = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
18
- img2 = Magick::Image.read(IMAGES_DIR+'/Button_1.gif').first
19
- assert_nothing_raised do
20
- res = img1.composite!(img2, Magick::NorthWestGravity, Magick::OverCompositeOp)
21
- assert_same(img1, res)
22
- end
23
- img1.freeze
24
- assert_raise(FreezeError) { img1.composite!(img2, Magick::NorthWestGravity, Magick::OverCompositeOp) }
17
+ img1 = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
18
+ img2 = Magick::Image.read(IMAGES_DIR+'/Button_1.gif').first
19
+ assert_nothing_raised do
20
+ res = img1.composite!(img2, Magick::NorthWestGravity, Magick::OverCompositeOp)
21
+ assert_same(img1, res)
22
+ end
23
+ img1.freeze
24
+ assert_raise(FreezeError) { img1.composite!(img2, Magick::NorthWestGravity, Magick::OverCompositeOp) }
25
25
  end
26
26
 
27
27
  def test_composite_affine
28
- affine = Magick::AffineMatrix.new(1, 0, 1, 0, 0, 0)
29
- img1 = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
30
- img2 = Magick::Image.read(IMAGES_DIR+'/Button_1.gif').first
31
- assert_nothing_raised do
32
- res = img1.composite_affine(img2, affine)
33
- assert_instance_of(Magick::Image, res)
34
- assert_not_same(@img, res)
35
- end
28
+ affine = Magick::AffineMatrix.new(1, 0, 1, 0, 0, 0)
29
+ img1 = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
30
+ img2 = Magick::Image.read(IMAGES_DIR+'/Button_1.gif').first
31
+ assert_nothing_raised do
32
+ res = img1.composite_affine(img2, affine)
33
+ assert_instance_of(Magick::Image, res)
34
+ assert_not_same(@img, res)
35
+ end
36
36
  end
37
37
 
38
38
  def test_composite_mathematics
39
- bg = Magick::Image.new(50, 50)
40
- fg = Magick::Image.new(50, 50) {self.background_color = 'black' }
41
- res = nil
42
- assert_nothing_raised { res = bg.composite_mathematics(fg, 1, 0, 0, 0, Magick::CenterGravity) }
43
- assert_instance_of(Magick::Image, res)
44
- assert_not_same(bg, res)
45
- assert_not_same(fg, res)
46
- assert_nothing_raised { res = bg.composite_mathematics(fg, 1, 0, 0, 0, 0.0, 0.0) }
47
- assert_nothing_raised { res = bg.composite_mathematics(fg, 1, 0, 0, 0, Magick::CenterGravity, 0.0, 0.0) }
48
-
49
- # too few arguments
50
- assert_raise(ArgumentError) { bg.composite_mathematics(fg, 1, 0, 0, 0) }
51
- # too many arguments
52
- assert_raise(ArgumentError) { bg.composite_mathematics(fg, 1, 0, 0, 0, Magick::CenterGravity, 0.0, 0.0, 'x') }
39
+ bg = Magick::Image.new(50, 50)
40
+ fg = Magick::Image.new(50, 50) {self.background_color = 'black' }
41
+ res = nil
42
+ assert_nothing_raised { res = bg.composite_mathematics(fg, 1, 0, 0, 0, Magick::CenterGravity) }
43
+ assert_instance_of(Magick::Image, res)
44
+ assert_not_same(bg, res)
45
+ assert_not_same(fg, res)
46
+ assert_nothing_raised { res = bg.composite_mathematics(fg, 1, 0, 0, 0, 0.0, 0.0) }
47
+ assert_nothing_raised { res = bg.composite_mathematics(fg, 1, 0, 0, 0, Magick::CenterGravity, 0.0, 0.0) }
48
+
49
+ # too few arguments
50
+ assert_raise(ArgumentError) { bg.composite_mathematics(fg, 1, 0, 0, 0) }
51
+ # too many arguments
52
+ assert_raise(ArgumentError) { bg.composite_mathematics(fg, 1, 0, 0, 0, Magick::CenterGravity, 0.0, 0.0, 'x') }
53
53
  end
54
54
 
55
55
  def test_composite_tiled
@@ -73,136 +73,136 @@ class Image2_UT < Test::Unit::TestCase
73
73
  end
74
74
 
75
75
  def test_compress_colormap!
76
- # DirectClass images are converted to PseudoClass
77
- assert_equal(Magick::DirectClass, @img.class_type)
78
- assert_nothing_raised { @img.compress_colormap! }
79
- assert_equal(Magick::PseudoClass, @img.class_type)
80
- img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
81
- assert_equal(Magick::PseudoClass, @img.class_type)
82
- assert_nothing_raised { @img.compress_colormap! }
76
+ # DirectClass images are converted to PseudoClass
77
+ assert_equal(Magick::DirectClass, @img.class_type)
78
+ assert_nothing_raised { @img.compress_colormap! }
79
+ assert_equal(Magick::PseudoClass, @img.class_type)
80
+ img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
81
+ assert_equal(Magick::PseudoClass, @img.class_type)
82
+ assert_nothing_raised { @img.compress_colormap! }
83
83
  end
84
84
 
85
85
  def test_contrast
86
- assert_nothing_raised do
87
- res = @img.contrast
88
- assert_instance_of(Magick::Image, res)
89
- assert_not_same(@img, res)
90
- end
91
- assert_nothing_raised { @img.contrast(true) }
92
- assert_raise(ArgumentError) { @img.contrast(true, 2) }
86
+ assert_nothing_raised do
87
+ res = @img.contrast
88
+ assert_instance_of(Magick::Image, res)
89
+ assert_not_same(@img, res)
90
+ end
91
+ assert_nothing_raised { @img.contrast(true) }
92
+ assert_raise(ArgumentError) { @img.contrast(true, 2) }
93
93
  end
94
94
 
95
95
  def test_contrast_stretch_channel
96
- assert_nothing_raised do
97
- res = @img.contrast_stretch_channel(25)
98
- assert_instance_of(Magick::Image, res)
99
- assert_not_same(@img, res)
100
- end
101
- assert_nothing_raised { @img.contrast_stretch_channel(25, 50) }
102
- assert_nothing_raised { @img.contrast_stretch_channel('10%') }
103
- assert_nothing_raised { @img.contrast_stretch_channel('10%', '50%') }
104
- assert_nothing_raised { @img.contrast_stretch_channel(25, 50, Magick::RedChannel) }
105
- assert_nothing_raised { @img.contrast_stretch_channel(25, 50, Magick::RedChannel, Magick::GreenChannel) }
106
- assert_raise(TypeError) { @img.contrast_stretch_channel(25, 50, 'x') }
107
- assert_raise(ArgumentError) { @img.contrast_stretch_channel }
108
- assert_raise(ArgumentError) { @img.contrast_stretch_channel('x') }
109
- assert_raise(ArgumentError) { @img.contrast_stretch_channel(25, 'x') }
96
+ assert_nothing_raised do
97
+ res = @img.contrast_stretch_channel(25)
98
+ assert_instance_of(Magick::Image, res)
99
+ assert_not_same(@img, res)
100
+ end
101
+ assert_nothing_raised { @img.contrast_stretch_channel(25, 50) }
102
+ assert_nothing_raised { @img.contrast_stretch_channel('10%') }
103
+ assert_nothing_raised { @img.contrast_stretch_channel('10%', '50%') }
104
+ assert_nothing_raised { @img.contrast_stretch_channel(25, 50, Magick::RedChannel) }
105
+ assert_nothing_raised { @img.contrast_stretch_channel(25, 50, Magick::RedChannel, Magick::GreenChannel) }
106
+ assert_raise(TypeError) { @img.contrast_stretch_channel(25, 50, 'x') }
107
+ assert_raise(ArgumentError) { @img.contrast_stretch_channel }
108
+ assert_raise(ArgumentError) { @img.contrast_stretch_channel('x') }
109
+ assert_raise(ArgumentError) { @img.contrast_stretch_channel(25, 'x') }
110
110
  end
111
111
 
112
112
  def test_convolve
113
- kernel = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
114
- order = 3
115
- assert_nothing_raised do
116
- res = @img.convolve(order, kernel)
117
- assert_instance_of(Magick::Image, res)
118
- assert_not_same(@img, res)
119
- end
120
- assert_raise(ArgumentError) { @img.convolve }
121
- assert_raise(ArgumentError) { @img.convolve(order) }
122
- assert_raise(IndexError) { @img.convolve(5, kernel) }
123
- assert_raise(IndexError) { @img.convolve(order, 'x') }
124
- assert_raise(TypeError) { @img.convolve(3, [1.0, 1.0, 1.0, 1.0, 'x', 1.0, 1.0, 1.0, 1.0]) }
125
- assert_raise(Magick::ImageMagickError) { @img.convolve(-1, [1.0, 1.0, 1.0, 1.0]) }
113
+ kernel = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
114
+ order = 3
115
+ assert_nothing_raised do
116
+ res = @img.convolve(order, kernel)
117
+ assert_instance_of(Magick::Image, res)
118
+ assert_not_same(@img, res)
119
+ end
120
+ assert_raise(ArgumentError) { @img.convolve }
121
+ assert_raise(ArgumentError) { @img.convolve(order) }
122
+ assert_raise(IndexError) { @img.convolve(5, kernel) }
123
+ assert_raise(IndexError) { @img.convolve(order, 'x') }
124
+ assert_raise(TypeError) { @img.convolve(3, [1.0, 1.0, 1.0, 1.0, 'x', 1.0, 1.0, 1.0, 1.0]) }
125
+ assert_raise(Magick::ImageMagickError) { @img.convolve(-1, [1.0, 1.0, 1.0, 1.0]) }
126
126
  end
127
127
 
128
128
  def test_convolve_channel
129
- assert_raise(ArgumentError) { @img.convolve_channel }
130
- assert_raise(ArgumentError) { @img.convolve_channel(3) }
131
- kernel = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
132
- order = 3
133
- assert_nothing_raised do
134
- res = @img.convolve_channel(order, kernel, Magick::RedChannel)
135
- assert_instance_of(Magick::Image, res)
136
- assert_not_same(@img, res)
137
- end
129
+ assert_raise(ArgumentError) { @img.convolve_channel }
130
+ assert_raise(ArgumentError) { @img.convolve_channel(3) }
131
+ kernel = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
132
+ order = 3
133
+ assert_nothing_raised do
134
+ res = @img.convolve_channel(order, kernel, Magick::RedChannel)
135
+ assert_instance_of(Magick::Image, res)
136
+ assert_not_same(@img, res)
137
+ end
138
138
 
139
- assert_nothing_raised { @img.convolve_channel(order, kernel, Magick::RedChannel, Magick:: BlueChannel) }
140
- assert_raise(TypeError) { @img.convolve_channel(order, kernel, Magick::RedChannel, 2) }
139
+ assert_nothing_raised { @img.convolve_channel(order, kernel, Magick::RedChannel, Magick:: BlueChannel) }
140
+ assert_raise(TypeError) { @img.convolve_channel(order, kernel, Magick::RedChannel, 2) }
141
141
  end
142
142
 
143
143
  def test_copy
144
- assert_nothing_raised do
145
- ditto = @img.copy
146
- assert_equal(@img, ditto)
147
- end
148
- ditto = @img.copy
149
- assert_equal(@img.tainted?, ditto.tainted?)
150
- @img.taint
144
+ assert_nothing_raised do
151
145
  ditto = @img.copy
152
- assert_equal(@img.tainted?, ditto.tainted?)
146
+ assert_equal(@img, ditto)
147
+ end
148
+ ditto = @img.copy
149
+ assert_equal(@img.tainted?, ditto.tainted?)
150
+ @img.taint
151
+ ditto = @img.copy
152
+ assert_equal(@img.tainted?, ditto.tainted?)
153
153
  end
154
154
 
155
155
  def test_crop
156
- assert_raise(ArgumentError) { @img.crop }
157
- assert_raise(ArgumentError) { @img.crop(0, 0) }
158
- assert_nothing_raised do
159
- res = @img.crop(0, 0, @img.columns/2, @img.rows/2)
160
- assert_instance_of(Magick::Image, res)
161
- assert_not_same(@img, res)
162
- end
163
- gravity = [
164
- Magick::NorthEastGravity,
165
- Magick::EastGravity,
166
- Magick::SouthWestGravity,
167
- Magick::SouthGravity,
168
- Magick::SouthEastGravity]
169
-
170
- # 3-argument form
171
- gravity.each do |grav|
172
- assert_nothing_raised { @img.crop(grav, @img.columns/2, @img.rows/2) }
173
- end
174
- assert_raise(TypeError) { @img.crop(2, @img.columns/2, @img.rows/2) }
175
- assert_raise(TypeError) { @img.crop(Magick::NorthWestGravity, @img.columns/2, @img.rows/2, 2) }
176
-
177
- # 4-argument form
178
- assert_raise(TypeError) { @img.crop(0, 0, @img.columns/2, 'x') }
179
- assert_raise(TypeError) { @img.crop(0, 0, 'x', @img.rows/2) }
180
- assert_raise(TypeError) { @img.crop(0, 'x', @img.columns/2, @img.rows/2) }
181
- assert_raise(TypeError) { @img.crop('x', 0, @img.columns/2, @img.rows/2) }
182
- assert_raise(TypeError) { @img.crop(0, 0, @img.columns/2, @img.rows/2, 2) }
183
-
184
- # 5-argument form
185
- gravity.each do |grav|
186
- assert_nothing_raised { @img.crop(grav, 0, 0, @img.columns/2, @img.rows/2) }
187
- end
156
+ assert_raise(ArgumentError) { @img.crop }
157
+ assert_raise(ArgumentError) { @img.crop(0, 0) }
158
+ assert_nothing_raised do
159
+ res = @img.crop(0, 0, @img.columns/2, @img.rows/2)
160
+ assert_instance_of(Magick::Image, res)
161
+ assert_not_same(@img, res)
162
+ end
163
+ gravity = [
164
+ Magick::NorthEastGravity,
165
+ Magick::EastGravity,
166
+ Magick::SouthWestGravity,
167
+ Magick::SouthGravity,
168
+ Magick::SouthEastGravity]
169
+
170
+ # 3-argument form
171
+ gravity.each do |grav|
172
+ assert_nothing_raised { @img.crop(grav, @img.columns/2, @img.rows/2) }
173
+ end
174
+ assert_raise(TypeError) { @img.crop(2, @img.columns/2, @img.rows/2) }
175
+ assert_raise(TypeError) { @img.crop(Magick::NorthWestGravity, @img.columns/2, @img.rows/2, 2) }
176
+
177
+ # 4-argument form
178
+ assert_raise(TypeError) { @img.crop(0, 0, @img.columns/2, 'x') }
179
+ assert_raise(TypeError) { @img.crop(0, 0, 'x', @img.rows/2) }
180
+ assert_raise(TypeError) { @img.crop(0, 'x', @img.columns/2, @img.rows/2) }
181
+ assert_raise(TypeError) { @img.crop('x', 0, @img.columns/2, @img.rows/2) }
182
+ assert_raise(TypeError) { @img.crop(0, 0, @img.columns/2, @img.rows/2, 2) }
183
+
184
+ # 5-argument form
185
+ gravity.each do |grav|
186
+ assert_nothing_raised { @img.crop(grav, 0, 0, @img.columns/2, @img.rows/2) }
187
+ end
188
188
 
189
- assert_raise(ArgumentError) { @img.crop(Magick::NorthWestGravity, 0, 0, @img.columns/2, @img.rows/2, 2) }
189
+ assert_raise(ArgumentError) { @img.crop(Magick::NorthWestGravity, 0, 0, @img.columns/2, @img.rows/2, 2) }
190
190
  end
191
191
 
192
192
  def test_crop!
193
- assert_nothing_raised do
194
- res = @img.crop!(0, 0, @img.columns/2, @img.rows/2)
195
- assert_same(@img, res)
196
- end
193
+ assert_nothing_raised do
194
+ res = @img.crop!(0, 0, @img.columns/2, @img.rows/2)
195
+ assert_same(@img, res)
196
+ end
197
197
  end
198
198
 
199
199
  def test_cycle_colormap
200
- assert_nothing_raised do
201
- res = @img.cycle_colormap(5)
202
- assert_instance_of(Magick::Image, res)
203
- assert_not_same(@img, res)
204
- assert_equal(Magick::PseudoClass, res.class_type)
205
- end
200
+ assert_nothing_raised do
201
+ res = @img.cycle_colormap(5)
202
+ assert_instance_of(Magick::Image, res)
203
+ assert_not_same(@img, res)
204
+ assert_equal(Magick::PseudoClass, res.class_type)
205
+ end
206
206
  end
207
207
 
208
208
  def test_decipher # tests encipher, too.
@@ -228,11 +228,11 @@ class Image2_UT < Test::Unit::TestCase
228
228
  end
229
229
 
230
230
  def test_deskew
231
- assert_nothing_raised do
231
+ assert_nothing_raised do
232
232
  res = @img.deskew
233
233
  assert_instance_of(Magick::Image, res)
234
234
  assert_not_same(@img, res)
235
- end
235
+ end
236
236
 
237
237
  assert_nothing_raised { @img.deskew(0.10) }
238
238
  assert_nothing_raised { @img.deskew('95%') }
@@ -242,20 +242,20 @@ class Image2_UT < Test::Unit::TestCase
242
242
  end
243
243
 
244
244
  def test_despeckle
245
- assert_nothing_raised do
246
- res = @img.despeckle
247
- assert_instance_of(Magick::Image, res)
248
- assert_not_same(@img, res)
249
- end
245
+ assert_nothing_raised do
246
+ res = @img.despeckle
247
+ assert_instance_of(Magick::Image, res)
248
+ assert_not_same(@img, res)
249
+ end
250
250
  end
251
251
 
252
252
  # ensure methods detect destroyed images
253
253
  def test_destroy
254
254
  methods = Magick::Image.instance_methods(false).sort
255
255
  if RUBY_VERSION[/^1\.9|^2/]
256
- methods -= [:__display__, :destroy!, :destroyed?, :inspect, :cur_image, :marshal_load]
256
+ methods -= [:__display__, :destroy!, :destroyed?, :inspect, :cur_image, :marshal_load]
257
257
  else
258
- methods -= %w{ __display__ destroy! destroyed? inspect cur_image marshal_load}
258
+ methods -= %w{ __display__ destroy! destroyed? inspect cur_image marshal_load}
259
259
  end
260
260
 
261
261
  assert_equal(false, @img.destroyed?)
@@ -264,33 +264,33 @@ class Image2_UT < Test::Unit::TestCase
264
264
  assert_raises(Magick::DestroyedImageError) { @img.check_destroyed }
265
265
 
266
266
  methods.each do |method|
267
- arity = @img.method(method).arity
268
- method = method.to_s
269
-
270
- case
271
- when method == '[]='
272
- assert_raises(Magick::DestroyedImageError) { @img['foo'] = 1 }
273
- when method == 'difference'
274
- other = Magick::Image.new(20,20)
275
- assert_raises(Magick::DestroyedImageError) { @img.difference(other) }
276
- when method == 'get_iptc_dataset'
277
- assert_raises(Magick::DestroyedImageError) { @img.get_iptc_dataset('x') }
278
- when method == 'profile!'
279
- assert_raises(Magick::DestroyedImageError) { @img.profile!('x', 'y') }
280
- when /=\Z/.match(method)
281
- assert_raises(Magick::DestroyedImageError) { @img.send(method, 1) }
282
- when arity == 0
283
- assert_raises(Magick::DestroyedImageError) { @img.send(method) }
284
- when arity < 0
285
- args = (1..(-arity)).to_a
286
- assert_raises(Magick::DestroyedImageError) { @img.send(method, *args) }
287
- when arity > 0
288
- args = (1..(arity)).to_a
289
- assert_raises(Magick::DestroyedImageError) { @img.send(method, *args) }
290
- else
291
- # Don't know how to test!
292
- flunk("don't know how to test method #{method}")
293
- end
267
+ arity = @img.method(method).arity
268
+ method = method.to_s
269
+
270
+ case
271
+ when method == '[]='
272
+ assert_raises(Magick::DestroyedImageError) { @img['foo'] = 1 }
273
+ when method == 'difference'
274
+ other = Magick::Image.new(20,20)
275
+ assert_raises(Magick::DestroyedImageError) { @img.difference(other) }
276
+ when method == 'get_iptc_dataset'
277
+ assert_raises(Magick::DestroyedImageError) { @img.get_iptc_dataset('x') }
278
+ when method == 'profile!'
279
+ assert_raises(Magick::DestroyedImageError) { @img.profile!('x', 'y') }
280
+ when /=\Z/.match(method)
281
+ assert_raises(Magick::DestroyedImageError) { @img.send(method, 1) }
282
+ when arity == 0
283
+ assert_raises(Magick::DestroyedImageError) { @img.send(method) }
284
+ when arity < 0
285
+ args = (1..(-arity)).to_a
286
+ assert_raises(Magick::DestroyedImageError) { @img.send(method, *args) }
287
+ when arity > 0
288
+ args = (1..(arity)).to_a
289
+ assert_raises(Magick::DestroyedImageError) { @img.send(method, *args) }
290
+ else
291
+ # Don't know how to test!
292
+ flunk("don't know how to test method #{method}")
293
+ end
294
294
  end
295
295
  end
296
296
 
@@ -331,20 +331,20 @@ class Image2_UT < Test::Unit::TestCase
331
331
  end
332
332
 
333
333
  def test_difference
334
- img1 = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
335
- img2 = Magick::Image.read(IMAGES_DIR+'/Button_1.gif').first
336
- assert_nothing_raised do
337
- res = img1.difference(img2)
338
- assert_instance_of(Array, res)
339
- assert_equal(3, res.length)
340
- assert_instance_of(Float, res[0])
341
- assert_instance_of(Float, res[1])
342
- assert_instance_of(Float, res[2])
343
- end
334
+ img1 = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
335
+ img2 = Magick::Image.read(IMAGES_DIR+'/Button_1.gif').first
336
+ assert_nothing_raised do
337
+ res = img1.difference(img2)
338
+ assert_instance_of(Array, res)
339
+ assert_equal(3, res.length)
340
+ assert_instance_of(Float, res[0])
341
+ assert_instance_of(Float, res[1])
342
+ assert_instance_of(Float, res[2])
343
+ end
344
344
 
345
- assert_raise(NoMethodError) { img1.difference(2) }
346
- img2.destroy!
347
- assert_raise(Magick::DestroyedImageError) { img1.difference(img2) }
345
+ assert_raise(NoMethodError) { img1.difference(2) }
346
+ img2.destroy!
347
+ assert_raise(Magick::DestroyedImageError) { img1.difference(img2) }
348
348
  end
349
349
 
350
350
  def test_displace
@@ -371,234 +371,234 @@ class Image2_UT < Test::Unit::TestCase
371
371
  end
372
372
 
373
373
  def test_dissolve
374
- src = Magick::Image.new(@img.columns, @img.rows)
375
- src_list = Magick::ImageList.new
376
- src_list << src.copy
377
- assert_nothing_raised { @img.dissolve(src, 0.50) }
378
- assert_nothing_raised { @img.dissolve(src_list, 0.50) }
379
- assert_nothing_raised { @img.dissolve(src, '50%') }
380
- assert_nothing_raised { @img.dissolve(src, 0.50, 0.10) }
381
- assert_nothing_raised { @img.dissolve(src, 0.50, 0.10, 10) }
382
- assert_nothing_raised { @img.dissolve(src, 0.50, 0.10, Magick::NorthEastGravity) }
383
- assert_nothing_raised { @img.dissolve(src, 0.50, 0.10, Magick::NorthEastGravity, 10) }
384
- assert_nothing_raised { @img.dissolve(src, 0.50, 0.10, Magick::NorthEastGravity, 10, 10) }
385
-
386
- assert_raise(ArgumentError) { @img.dissolve(src, 'x') }
387
- assert_raise(ArgumentError) { @img.dissolve(src, 0.50, 'x') }
388
- assert_raise(TypeError) { @img.dissolve(src, 0.50, Magick::NorthEastGravity, 'x') }
389
- assert_raise(TypeError) { @img.dissolve(src, 0.50, Magick::NorthEastGravity, 10, 'x') }
390
-
391
- src.destroy!
392
- assert_raise(Magick::DestroyedImageError) { @img.dissolve(src, 0.50) }
374
+ src = Magick::Image.new(@img.columns, @img.rows)
375
+ src_list = Magick::ImageList.new
376
+ src_list << src.copy
377
+ assert_nothing_raised { @img.dissolve(src, 0.50) }
378
+ assert_nothing_raised { @img.dissolve(src_list, 0.50) }
379
+ assert_nothing_raised { @img.dissolve(src, '50%') }
380
+ assert_nothing_raised { @img.dissolve(src, 0.50, 0.10) }
381
+ assert_nothing_raised { @img.dissolve(src, 0.50, 0.10, 10) }
382
+ assert_nothing_raised { @img.dissolve(src, 0.50, 0.10, Magick::NorthEastGravity) }
383
+ assert_nothing_raised { @img.dissolve(src, 0.50, 0.10, Magick::NorthEastGravity, 10) }
384
+ assert_nothing_raised { @img.dissolve(src, 0.50, 0.10, Magick::NorthEastGravity, 10, 10) }
385
+
386
+ assert_raise(ArgumentError) { @img.dissolve(src, 'x') }
387
+ assert_raise(ArgumentError) { @img.dissolve(src, 0.50, 'x') }
388
+ assert_raise(TypeError) { @img.dissolve(src, 0.50, Magick::NorthEastGravity, 'x') }
389
+ assert_raise(TypeError) { @img.dissolve(src, 0.50, Magick::NorthEastGravity, 10, 'x') }
390
+
391
+ src.destroy!
392
+ assert_raise(Magick::DestroyedImageError) { @img.dissolve(src, 0.50) }
393
393
  end
394
394
 
395
395
  def test_distort
396
- @img = Magick::Image.new(200, 200)
397
- assert_nothing_raised { @img.distort(Magick::AffineDistortion, [2,60, 2,60, 32,60, 32,60, 2,30, 17,35]) }
398
- assert_nothing_raised { @img.distort(Magick::AffineProjectionDistortion, [1,0,0,1,0,0]) }
399
- assert_nothing_raised { @img.distort(Magick::BilinearDistortion, [7,40, 4,30, 4,124, 4,123, 85,122, 100,123, 85,2, 100,30]) }
400
- assert_nothing_raised { @img.distort(Magick::PerspectiveDistortion, [7,40, 4,30, 4,124, 4,123, 85,122, 100,123, 85,2, 100,30]) }
401
- assert_nothing_raised { @img.distort(Magick::ScaleRotateTranslateDistortion, [28,24, 0.4,0.8 -110, 37.5,60]) }
402
- assert_raise(ArgumentError) { @img.distort }
403
- assert_raise(ArgumentError) { @img.distort(Magick::AffineDistortion) }
404
- assert_raise(TypeError) { @img.distort(1, [1]) }
396
+ @img = Magick::Image.new(200, 200)
397
+ assert_nothing_raised { @img.distort(Magick::AffineDistortion, [2,60, 2,60, 32,60, 32,60, 2,30, 17,35]) }
398
+ assert_nothing_raised { @img.distort(Magick::AffineProjectionDistortion, [1,0,0,1,0,0]) }
399
+ assert_nothing_raised { @img.distort(Magick::BilinearDistortion, [7,40, 4,30, 4,124, 4,123, 85,122, 100,123, 85,2, 100,30]) }
400
+ assert_nothing_raised { @img.distort(Magick::PerspectiveDistortion, [7,40, 4,30, 4,124, 4,123, 85,122, 100,123, 85,2, 100,30]) }
401
+ assert_nothing_raised { @img.distort(Magick::ScaleRotateTranslateDistortion, [28,24, 0.4,0.8 -110, 37.5,60]) }
402
+ assert_raise(ArgumentError) { @img.distort }
403
+ assert_raise(ArgumentError) { @img.distort(Magick::AffineDistortion) }
404
+ assert_raise(TypeError) { @img.distort(1, [1]) }
405
405
  end
406
406
 
407
407
  def test_distortion_channel
408
- assert_nothing_raised do
409
- metric = @img.distortion_channel(@img, Magick::MeanAbsoluteErrorMetric)
410
- assert_instance_of(Float, metric)
411
- assert_equal(0.0, metric)
412
- end
413
- assert_nothing_raised { @img.distortion_channel(@img, Magick::MeanSquaredErrorMetric) }
414
- assert_nothing_raised { @img.distortion_channel(@img, Magick::PeakAbsoluteErrorMetric) }
415
- assert_nothing_raised { @img.distortion_channel(@img, Magick::PeakSignalToNoiseRatioMetric) }
416
- assert_nothing_raised { @img.distortion_channel(@img, Magick::RootMeanSquaredErrorMetric) }
417
- assert_nothing_raised { @img.distortion_channel(@img, Magick::MeanSquaredErrorMetric, Magick::RedChannel, Magick:: BlueChannel) }
418
- assert_raise(TypeError) { @img.distortion_channel(@img, 2) }
419
- assert_raise(TypeError) { @img.distortion_channel(@img, Magick::RootMeanSquaredErrorMetric, 2) }
420
- assert_raise(ArgumentError) { @img.distortion_channel }
421
- assert_raise(ArgumentError) { @img.distortion_channel(@img) }
408
+ assert_nothing_raised do
409
+ metric = @img.distortion_channel(@img, Magick::MeanAbsoluteErrorMetric)
410
+ assert_instance_of(Float, metric)
411
+ assert_equal(0.0, metric)
412
+ end
413
+ assert_nothing_raised { @img.distortion_channel(@img, Magick::MeanSquaredErrorMetric) }
414
+ assert_nothing_raised { @img.distortion_channel(@img, Magick::PeakAbsoluteErrorMetric) }
415
+ assert_nothing_raised { @img.distortion_channel(@img, Magick::PeakSignalToNoiseRatioMetric) }
416
+ assert_nothing_raised { @img.distortion_channel(@img, Magick::RootMeanSquaredErrorMetric) }
417
+ assert_nothing_raised { @img.distortion_channel(@img, Magick::MeanSquaredErrorMetric, Magick::RedChannel, Magick:: BlueChannel) }
418
+ assert_raise(TypeError) { @img.distortion_channel(@img, 2) }
419
+ assert_raise(TypeError) { @img.distortion_channel(@img, Magick::RootMeanSquaredErrorMetric, 2) }
420
+ assert_raise(ArgumentError) { @img.distortion_channel }
421
+ assert_raise(ArgumentError) { @img.distortion_channel(@img) }
422
422
 
423
- img = Magick::Image.new(20,20)
424
- img.destroy!
425
- assert_raise(Magick::DestroyedImageError) { @img.distortion_channel(img, Magick::MeanSquaredErrorMetric) }
423
+ img = Magick::Image.new(20,20)
424
+ img.destroy!
425
+ assert_raise(Magick::DestroyedImageError) { @img.distortion_channel(img, Magick::MeanSquaredErrorMetric) }
426
426
  end
427
427
 
428
428
  def test_dup
429
- assert_nothing_raised do
430
- ditto = @img.dup
431
- assert_equal(@img, ditto)
432
- end
433
- ditto = @img.dup
434
- assert_equal(@img.tainted?, ditto.tainted?)
435
- @img.taint
429
+ assert_nothing_raised do
436
430
  ditto = @img.dup
437
- assert_equal(@img.tainted?, ditto.tainted?)
431
+ assert_equal(@img, ditto)
432
+ end
433
+ ditto = @img.dup
434
+ assert_equal(@img.tainted?, ditto.tainted?)
435
+ @img.taint
436
+ ditto = @img.dup
437
+ assert_equal(@img.tainted?, ditto.tainted?)
438
438
  end
439
439
 
440
440
  def test_each_profile
441
- @img.iptc_profile = 'test profile'
442
- assert_nothing_raised do
443
- @img.each_profile do |name, value|
444
- assert_equal('iptc', name)
445
- # As of 6.3.1
446
- if IM_VERSION < Gem::Version.new('6.6.4') || (IM_VERSION == Gem::Version.new('6.6.4') && IM_REVISION < Gem::Version.new('5'))
447
- assert_equal("8BIM\004\004\000\000\000\000\001\340test profile", value)
448
- else
449
- assert_equal('test profile', value)
450
- end
451
- end
441
+ @img.iptc_profile = 'test profile'
442
+ assert_nothing_raised do
443
+ @img.each_profile do |name, value|
444
+ assert_equal('iptc', name)
445
+ # As of 6.3.1
446
+ if IM_VERSION < Gem::Version.new('6.6.4') || (IM_VERSION == Gem::Version.new('6.6.4') && IM_REVISION < Gem::Version.new('5'))
447
+ assert_equal("8BIM\004\004\000\000\000\000\001\340test profile", value)
448
+ else
449
+ assert_equal('test profile', value)
450
+ end
452
451
  end
452
+ end
453
453
  end
454
454
 
455
455
  def test_edge
456
- assert_nothing_raised do
457
- res = @img.edge
458
- assert_instance_of(Magick::Image, res)
459
- assert_not_same(@img, res)
460
- end
461
- assert_nothing_raised { @img.edge(2.0) }
462
- assert_raise(ArgumentError) { @img.edge(2.0, 2) }
463
- assert_raise(TypeError) { @img.edge('x') }
456
+ assert_nothing_raised do
457
+ res = @img.edge
458
+ assert_instance_of(Magick::Image, res)
459
+ assert_not_same(@img, res)
460
+ end
461
+ assert_nothing_raised { @img.edge(2.0) }
462
+ assert_raise(ArgumentError) { @img.edge(2.0, 2) }
463
+ assert_raise(TypeError) { @img.edge('x') }
464
464
  end
465
465
 
466
466
  def test_emboss
467
- assert_nothing_raised do
468
- res = @img.emboss
469
- assert_instance_of(Magick::Image, res)
470
- assert_not_same(@img, res)
471
- end
472
- assert_nothing_raised { @img.emboss(1.0) }
473
- assert_nothing_raised { @img.emboss(1.0, 0.5) }
474
- assert_raise(ArgumentError) { @img.emboss(1.0, 0.5, 2) }
475
- assert_raise(TypeError) { @img.emboss(1.0, 'x') }
476
- assert_raise(TypeError) { @img.emboss('x', 1.0) }
467
+ assert_nothing_raised do
468
+ res = @img.emboss
469
+ assert_instance_of(Magick::Image, res)
470
+ assert_not_same(@img, res)
471
+ end
472
+ assert_nothing_raised { @img.emboss(1.0) }
473
+ assert_nothing_raised { @img.emboss(1.0, 0.5) }
474
+ assert_raise(ArgumentError) { @img.emboss(1.0, 0.5, 2) }
475
+ assert_raise(TypeError) { @img.emboss(1.0, 'x') }
476
+ assert_raise(TypeError) { @img.emboss('x', 1.0) }
477
477
  end
478
478
 
479
479
  def test_enhance
480
- assert_nothing_raised do
481
- res = @img.enhance
482
- assert_instance_of(Magick::Image, res)
483
- assert_not_same(@img, res)
484
- end
480
+ assert_nothing_raised do
481
+ res = @img.enhance
482
+ assert_instance_of(Magick::Image, res)
483
+ assert_not_same(@img, res)
484
+ end
485
485
  end
486
486
 
487
487
  def test_equalize
488
- assert_nothing_raised do
489
- res = @img.equalize
490
- assert_instance_of(Magick::Image, res)
491
- assert_not_same(@img, res)
492
- end
488
+ assert_nothing_raised do
489
+ res = @img.equalize
490
+ assert_instance_of(Magick::Image, res)
491
+ assert_not_same(@img, res)
492
+ end
493
493
  end
494
494
 
495
495
  def test_equalize_channel
496
- assert_nothing_raised do
497
- res = @img.equalize_channel
498
- assert_instance_of(Magick::Image, res)
499
- assert_not_same(@img, res)
500
- end
501
- assert_nothing_raised { @img.equalize_channel }
502
- assert_nothing_raised { @img.equalize_channel(Magick::RedChannel) }
503
- assert_nothing_raised { @img.equalize_channel(Magick::RedChannel, Magick::BlueChannel) }
504
- assert_raise(TypeError) { @img.equalize_channel(Magick::RedChannel, 2) }
496
+ assert_nothing_raised do
497
+ res = @img.equalize_channel
498
+ assert_instance_of(Magick::Image, res)
499
+ assert_not_same(@img, res)
500
+ end
501
+ assert_nothing_raised { @img.equalize_channel }
502
+ assert_nothing_raised { @img.equalize_channel(Magick::RedChannel) }
503
+ assert_nothing_raised { @img.equalize_channel(Magick::RedChannel, Magick::BlueChannel) }
504
+ assert_raise(TypeError) { @img.equalize_channel(Magick::RedChannel, 2) }
505
505
  end
506
506
 
507
507
  def test_erase!
508
- assert_nothing_raised do
509
- res = @img.erase!
510
- assert_same(@img, res)
511
- end
508
+ assert_nothing_raised do
509
+ res = @img.erase!
510
+ assert_same(@img, res)
511
+ end
512
512
  end
513
513
 
514
514
  def test_excerpt
515
- res = nil
516
- img = Magick::Image.new(200, 200)
517
- assert_nothing_raised { res = @img.excerpt(20,20,50,100) }
518
- assert_not_same(img, res)
519
- assert_equal(50, res.columns)
520
- assert_equal(100, res.rows)
515
+ res = nil
516
+ img = Magick::Image.new(200, 200)
517
+ assert_nothing_raised { res = @img.excerpt(20,20,50,100) }
518
+ assert_not_same(img, res)
519
+ assert_equal(50, res.columns)
520
+ assert_equal(100, res.rows)
521
521
 
522
- assert_nothing_raised { img.excerpt!(20,20,50,100) }
523
- assert_equal(50, img.columns)
524
- assert_equal(100, img.rows)
522
+ assert_nothing_raised { img.excerpt!(20,20,50,100) }
523
+ assert_equal(50, img.columns)
524
+ assert_equal(100, img.rows)
525
525
  end
526
526
 
527
527
  def test_export_pixels
528
- assert_nothing_raised do
529
- res = @img.export_pixels
530
- assert_instance_of(Array, res)
531
- assert_equal(@img.columns*@img.rows*'RGB'.length, res.length)
532
- res.each do |p|
533
- assert_kind_of(Integer, p)
534
- end
535
- end
536
- assert_nothing_raised { res = @img.export_pixels(0) }
537
- assert_nothing_raised { res = @img.export_pixels(0, 0) }
538
- assert_nothing_raised { res = @img.export_pixels(0, 0, 10) }
539
- assert_nothing_raised { res = @img.export_pixels(0, 0, 10, 10) }
540
- assert_nothing_raised do
541
- res = @img.export_pixels(0, 0, 10, 10, 'RGBA')
542
- assert_equal(10*10*'RGBA'.length, res.length)
528
+ assert_nothing_raised do
529
+ res = @img.export_pixels
530
+ assert_instance_of(Array, res)
531
+ assert_equal(@img.columns*@img.rows*'RGB'.length, res.length)
532
+ res.each do |p|
533
+ assert_kind_of(Integer, p)
543
534
  end
544
- assert_nothing_raised do
545
- res = @img.export_pixels(0, 0, 10, 10, 'I')
546
- assert_equal(10*10*'I'.length, res.length)
547
- end
535
+ end
536
+ assert_nothing_raised { res = @img.export_pixels(0) }
537
+ assert_nothing_raised { res = @img.export_pixels(0, 0) }
538
+ assert_nothing_raised { res = @img.export_pixels(0, 0, 10) }
539
+ assert_nothing_raised { res = @img.export_pixels(0, 0, 10, 10) }
540
+ assert_nothing_raised do
541
+ res = @img.export_pixels(0, 0, 10, 10, 'RGBA')
542
+ assert_equal(10*10*'RGBA'.length, res.length)
543
+ end
544
+ assert_nothing_raised do
545
+ res = @img.export_pixels(0, 0, 10, 10, 'I')
546
+ assert_equal(10*10*'I'.length, res.length)
547
+ end
548
548
 
549
- # too many arguments
550
- assert_raise(ArgumentError) { @img.export_pixels(0, 0, 10, 10, 'I', 2) }
549
+ # too many arguments
550
+ assert_raise(ArgumentError) { @img.export_pixels(0, 0, 10, 10, 'I', 2) }
551
551
  end
552
552
 
553
553
  def test_export_pixels_to_str
554
- assert_nothing_raised do
555
- res = @img.export_pixels_to_str
556
- assert_instance_of(String, res)
557
- assert_equal(@img.columns*@img.rows*'RGB'.length, res.length)
558
- end
559
- assert_nothing_raised { @img.export_pixels_to_str(0) }
560
- assert_nothing_raised { @img.export_pixels_to_str(0, 0) }
561
- assert_nothing_raised { @img.export_pixels_to_str(0, 0, 10) }
562
- assert_nothing_raised { @img.export_pixels_to_str(0, 0, 10, 10) }
563
- assert_nothing_raised do
564
- res = @img.export_pixels_to_str(0, 0, 10, 10, 'RGBA')
565
- assert_equal(10*10*'RGBA'.length, res.length)
566
- end
567
- assert_nothing_raised do
568
- res = @img.export_pixels_to_str(0, 0, 10, 10, 'I')
569
- assert_equal(10*10*'I'.length, res.length)
570
- end
554
+ assert_nothing_raised do
555
+ res = @img.export_pixels_to_str
556
+ assert_instance_of(String, res)
557
+ assert_equal(@img.columns*@img.rows*'RGB'.length, res.length)
558
+ end
559
+ assert_nothing_raised { @img.export_pixels_to_str(0) }
560
+ assert_nothing_raised { @img.export_pixels_to_str(0, 0) }
561
+ assert_nothing_raised { @img.export_pixels_to_str(0, 0, 10) }
562
+ assert_nothing_raised { @img.export_pixels_to_str(0, 0, 10, 10) }
563
+ assert_nothing_raised do
564
+ res = @img.export_pixels_to_str(0, 0, 10, 10, 'RGBA')
565
+ assert_equal(10*10*'RGBA'.length, res.length)
566
+ end
567
+ assert_nothing_raised do
568
+ res = @img.export_pixels_to_str(0, 0, 10, 10, 'I')
569
+ assert_equal(10*10*'I'.length, res.length)
570
+ end
571
571
 
572
- assert_nothing_raised do
573
- res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::CharPixel)
574
- assert_equal(10*10*1, res.length)
575
- end
576
- assert_nothing_raised do
577
- res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::ShortPixel)
578
- assert_equal(10*10*2, res.length)
579
- end
580
- assert_nothing_raised do
581
- res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::IntegerPixel)
582
- assert_equal(10*10*4, res.length)
583
- end
584
- assert_nothing_raised do
585
- res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::LongPixel)
586
- assert_equal(10*10*[1].pack('L!').length, res.length)
587
- end
588
- assert_nothing_raised do
589
- res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::FloatPixel)
590
- assert_equal(10*10*4, res.length)
591
- end
592
- assert_nothing_raised do
593
- res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::DoublePixel)
594
- assert_equal(10*10*8, res.length)
595
- end
596
- assert_nothing_raised { @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::QuantumPixel) }
572
+ assert_nothing_raised do
573
+ res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::CharPixel)
574
+ assert_equal(10*10*1, res.length)
575
+ end
576
+ assert_nothing_raised do
577
+ res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::ShortPixel)
578
+ assert_equal(10*10*2, res.length)
579
+ end
580
+ assert_nothing_raised do
581
+ res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::IntegerPixel)
582
+ assert_equal(10*10*4, res.length)
583
+ end
584
+ assert_nothing_raised do
585
+ res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::LongPixel)
586
+ assert_equal(10*10*[1].pack('L!').length, res.length)
587
+ end
588
+ assert_nothing_raised do
589
+ res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::FloatPixel)
590
+ assert_equal(10*10*4, res.length)
591
+ end
592
+ assert_nothing_raised do
593
+ res = @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::DoublePixel)
594
+ assert_equal(10*10*8, res.length)
595
+ end
596
+ assert_nothing_raised { @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::QuantumPixel) }
597
597
 
598
- # too many arguments
599
- assert_raise(ArgumentError) { @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::QuantumPixel, 1) }
600
- # last arg s/b StorageType
601
- assert_raise(TypeError) { @img.export_pixels_to_str(0, 0, 10, 10, 'I', 2) }
598
+ # too many arguments
599
+ assert_raise(ArgumentError) { @img.export_pixels_to_str(0, 0, 10, 10, 'I', Magick::QuantumPixel, 1) }
600
+ # last arg s/b StorageType
601
+ assert_raise(TypeError) { @img.export_pixels_to_str(0, 0, 10, 10, 'I', 2) }
602
602
  end
603
603
 
604
604
  def test_extent
@@ -619,305 +619,305 @@ class Image2_UT < Test::Unit::TestCase
619
619
  end
620
620
 
621
621
  def test_find_similar_region
622
- girl = Magick::Image.read(IMAGES_DIR+'/Flower_Hat.jpg').first
623
- region = girl.crop(10, 10, 50, 50)
624
- assert_nothing_raised do
625
- x, y = girl.find_similar_region(region)
626
- assert_not_nil(x)
627
- assert_not_nil(y)
628
- assert_equal(10, x)
629
- assert_equal(10, y)
630
- end
631
- assert_nothing_raised do
632
- x, y = girl.find_similar_region(region, 0)
633
- assert_equal(10, x)
634
- assert_equal(10, y)
635
- end
636
- assert_nothing_raised do
637
- x, y = girl.find_similar_region(region, 0, 0)
638
- assert_equal(10, x)
639
- assert_equal(10, y)
640
- end
622
+ girl = Magick::Image.read(IMAGES_DIR+'/Flower_Hat.jpg').first
623
+ region = girl.crop(10, 10, 50, 50)
624
+ assert_nothing_raised do
625
+ x, y = girl.find_similar_region(region)
626
+ assert_not_nil(x)
627
+ assert_not_nil(y)
628
+ assert_equal(10, x)
629
+ assert_equal(10, y)
630
+ end
631
+ assert_nothing_raised do
632
+ x, y = girl.find_similar_region(region, 0)
633
+ assert_equal(10, x)
634
+ assert_equal(10, y)
635
+ end
636
+ assert_nothing_raised do
637
+ x, y = girl.find_similar_region(region, 0, 0)
638
+ assert_equal(10, x)
639
+ assert_equal(10, y)
640
+ end
641
641
 
642
- list = Magick::ImageList.new
643
- list << region
644
- assert_nothing_raised do
645
- x, y = girl.find_similar_region(list, 0, 0)
646
- assert_equal(10, x)
647
- assert_equal(10, y)
648
- end
642
+ list = Magick::ImageList.new
643
+ list << region
644
+ assert_nothing_raised do
645
+ x, y = girl.find_similar_region(list, 0, 0)
646
+ assert_equal(10, x)
647
+ assert_equal(10, y)
648
+ end
649
649
 
650
- x = girl.find_similar_region(@img)
651
- assert_nil(x)
650
+ x = girl.find_similar_region(@img)
651
+ assert_nil(x)
652
652
 
653
- assert_raise(ArgumentError) { girl.find_similar_region(region, 10, 10, 10) }
654
- assert_raise(TypeError) { girl.find_similar_region(region, 10, 'x') }
655
- assert_raise(TypeError) { girl.find_similar_region(region, 'x') }
653
+ assert_raise(ArgumentError) { girl.find_similar_region(region, 10, 10, 10) }
654
+ assert_raise(TypeError) { girl.find_similar_region(region, 10, 'x') }
655
+ assert_raise(TypeError) { girl.find_similar_region(region, 'x') }
656
656
 
657
- region.destroy!
658
- assert_raise(Magick::DestroyedImageError) { girl.find_similar_region(region) }
657
+ region.destroy!
658
+ assert_raise(Magick::DestroyedImageError) { girl.find_similar_region(region) }
659
659
  end
660
660
 
661
661
  def test_flip
662
- assert_nothing_raised do
663
- res = @img.flip
664
- assert_instance_of(Magick::Image, res)
665
- assert_not_same(@img, res)
666
- end
662
+ assert_nothing_raised do
663
+ res = @img.flip
664
+ assert_instance_of(Magick::Image, res)
665
+ assert_not_same(@img, res)
666
+ end
667
667
  end
668
668
 
669
669
  def test_flip!
670
- assert_nothing_raised do
671
- res = @img.flip!
672
- assert_same(@img, res)
673
- end
670
+ assert_nothing_raised do
671
+ res = @img.flip!
672
+ assert_same(@img, res)
673
+ end
674
674
  end
675
675
 
676
676
  def test_flop
677
- assert_nothing_raised do
678
- res = @img.flop
679
- assert_instance_of(Magick::Image, res)
680
- assert_not_same(@img, res)
681
- end
677
+ assert_nothing_raised do
678
+ res = @img.flop
679
+ assert_instance_of(Magick::Image, res)
680
+ assert_not_same(@img, res)
681
+ end
682
682
  end
683
683
 
684
684
  def test_flop!
685
- assert_nothing_raised do
686
- res = @img.flop!
687
- assert_same(@img, res)
688
- end
685
+ assert_nothing_raised do
686
+ res = @img.flop!
687
+ assert_same(@img, res)
688
+ end
689
689
  end
690
690
 
691
691
  def test_frame
692
- assert_nothing_raised do
693
- res = @img.frame
694
- assert_instance_of(Magick::Image, res)
695
- assert_not_same(@img, res)
696
- end
697
- assert_nothing_raised { @img.frame(50) }
698
- assert_nothing_raised { @img.frame(50, 50) }
699
- assert_nothing_raised { @img.frame(50, 50, 25) }
700
- assert_nothing_raised { @img.frame(50, 50, 25, 25) }
701
- assert_nothing_raised { @img.frame(50, 50, 25, 25, 6) }
702
- assert_nothing_raised { @img.frame(50, 50, 25, 25, 6, 6) }
703
- assert_nothing_raised { @img.frame(50, 50, 25, 25, 6, 6, 'red') }
704
- red = Magick::Pixel.new(Magick::QuantumRange)
705
- assert_nothing_raised { @img.frame(50, 50, 25, 25, 6, 6, red) }
706
- assert_raise(TypeError) { @img.frame(50, 50, 25, 25, 6, 6, 2) }
692
+ assert_nothing_raised do
693
+ res = @img.frame
694
+ assert_instance_of(Magick::Image, res)
695
+ assert_not_same(@img, res)
696
+ end
697
+ assert_nothing_raised { @img.frame(50) }
698
+ assert_nothing_raised { @img.frame(50, 50) }
699
+ assert_nothing_raised { @img.frame(50, 50, 25) }
700
+ assert_nothing_raised { @img.frame(50, 50, 25, 25) }
701
+ assert_nothing_raised { @img.frame(50, 50, 25, 25, 6) }
702
+ assert_nothing_raised { @img.frame(50, 50, 25, 25, 6, 6) }
703
+ assert_nothing_raised { @img.frame(50, 50, 25, 25, 6, 6, 'red') }
704
+ red = Magick::Pixel.new(Magick::QuantumRange)
705
+ assert_nothing_raised { @img.frame(50, 50, 25, 25, 6, 6, red) }
706
+ assert_raise(TypeError) { @img.frame(50, 50, 25, 25, 6, 6, 2) }
707
707
  end
708
708
 
709
709
  def test_gamma_channel
710
- assert_nothing_raised do
711
- res = @img.gamma_channel(0.8)
712
- assert_instance_of(Magick::Image, res)
713
- assert_not_same(@img, res)
714
- end
715
- assert_raise(ArgumentError) { @img.gamma_channel }
716
- assert_nothing_raised { @img.gamma_channel(0.8, Magick::RedChannel) }
717
- assert_nothing_raised { @img.gamma_channel(0.8, Magick::RedChannel, Magick::BlueChannel) }
718
- assert_raise(TypeError) { @img.gamma_channel(0.8, Magick::RedChannel, 2) }
710
+ assert_nothing_raised do
711
+ res = @img.gamma_channel(0.8)
712
+ assert_instance_of(Magick::Image, res)
713
+ assert_not_same(@img, res)
714
+ end
715
+ assert_raise(ArgumentError) { @img.gamma_channel }
716
+ assert_nothing_raised { @img.gamma_channel(0.8, Magick::RedChannel) }
717
+ assert_nothing_raised { @img.gamma_channel(0.8, Magick::RedChannel, Magick::BlueChannel) }
718
+ assert_raise(TypeError) { @img.gamma_channel(0.8, Magick::RedChannel, 2) }
719
719
  end
720
720
 
721
721
  def test_function_channel
722
- img = Magick::Image.read('gradient:') {self.size = '20x600'}
723
- img = img.first
724
- img.rotate!(90)
725
- assert_nothing_raised { img.function_channel Magick::PolynomialFunction, 0.33 }
726
- assert_nothing_raised { img.function_channel Magick::PolynomialFunction, 4, -1.5 }
727
- assert_nothing_raised { img.function_channel Magick::PolynomialFunction, 4, -4, 1 }
728
- assert_nothing_raised { img.function_channel Magick::PolynomialFunction, -25, 53, -36, 8.3, 0.2 }
729
-
730
- assert_nothing_raised { img.function_channel Magick::SinusoidFunction, 1 }
731
- assert_nothing_raised { img.function_channel Magick::SinusoidFunction, 1, 90 }
732
- assert_nothing_raised { img.function_channel Magick::SinusoidFunction, 5, 90, 0.25, 0.75 }
733
-
734
- assert_nothing_raised { img.function_channel Magick::ArcsinFunction, 1 }
735
- assert_nothing_raised { img.function_channel Magick::ArcsinFunction, 0.5 }
736
- assert_nothing_raised { img.function_channel Magick::ArcsinFunction, 0.4, 0.7 }
737
- assert_nothing_raised { img.function_channel Magick::ArcsinFunction, 0.5, 0.5, 0.5, 0.5 }
738
-
739
- assert_nothing_raised { img.function_channel Magick::ArctanFunction, 1 }
740
- assert_nothing_raised { img.function_channel Magick::ArctanFunction, 10, 0.7 }
741
- assert_nothing_raised { img.function_channel Magick::ArctanFunction, 5, 0.7, 1.2 }
742
- assert_nothing_raised { img.function_channel Magick::ArctanFunction, 15, 0.7, 0.5, 0.75 }
743
-
744
- # with channel args
745
- assert_nothing_raised { img.function_channel Magick::PolynomialFunction, 0.33, Magick::RedChannel }
746
- assert_nothing_raised { img.function_channel Magick::SinusoidFunction, 1, Magick::RedChannel, Magick::BlueChannel }
747
-
748
- # invalid args
749
- assert_raise(ArgumentError) { img.function_channel }
750
- assert_raise(TypeError) { img.function_channel 1 }
751
- assert_raise(ArgumentError) { img.function_channel Magick::PolynomialFunction }
752
- assert_raise(TypeError) { img.function_channel Magick::PolynomialFunction, [] }
753
- assert_raise(ArgumentError) { img.function_channel Magick::SinusoidFunction, 5, 90, 0.25, 0.75, 0.1 }
754
- assert_raise(ArgumentError) { img.function_channel Magick::ArcsinFunction, 0.5, 0.5, 0.5, 0.5, 0.1 }
755
- assert_raise(ArgumentError) { img.function_channel Magick::ArctanFunction, 15, 0.7, 0.5, 0.75, 0.1 }
722
+ img = Magick::Image.read('gradient:') {self.size = '20x600'}
723
+ img = img.first
724
+ img.rotate!(90)
725
+ assert_nothing_raised { img.function_channel Magick::PolynomialFunction, 0.33 }
726
+ assert_nothing_raised { img.function_channel Magick::PolynomialFunction, 4, -1.5 }
727
+ assert_nothing_raised { img.function_channel Magick::PolynomialFunction, 4, -4, 1 }
728
+ assert_nothing_raised { img.function_channel Magick::PolynomialFunction, -25, 53, -36, 8.3, 0.2 }
729
+
730
+ assert_nothing_raised { img.function_channel Magick::SinusoidFunction, 1 }
731
+ assert_nothing_raised { img.function_channel Magick::SinusoidFunction, 1, 90 }
732
+ assert_nothing_raised { img.function_channel Magick::SinusoidFunction, 5, 90, 0.25, 0.75 }
733
+
734
+ assert_nothing_raised { img.function_channel Magick::ArcsinFunction, 1 }
735
+ assert_nothing_raised { img.function_channel Magick::ArcsinFunction, 0.5 }
736
+ assert_nothing_raised { img.function_channel Magick::ArcsinFunction, 0.4, 0.7 }
737
+ assert_nothing_raised { img.function_channel Magick::ArcsinFunction, 0.5, 0.5, 0.5, 0.5 }
738
+
739
+ assert_nothing_raised { img.function_channel Magick::ArctanFunction, 1 }
740
+ assert_nothing_raised { img.function_channel Magick::ArctanFunction, 10, 0.7 }
741
+ assert_nothing_raised { img.function_channel Magick::ArctanFunction, 5, 0.7, 1.2 }
742
+ assert_nothing_raised { img.function_channel Magick::ArctanFunction, 15, 0.7, 0.5, 0.75 }
743
+
744
+ # with channel args
745
+ assert_nothing_raised { img.function_channel Magick::PolynomialFunction, 0.33, Magick::RedChannel }
746
+ assert_nothing_raised { img.function_channel Magick::SinusoidFunction, 1, Magick::RedChannel, Magick::BlueChannel }
747
+
748
+ # invalid args
749
+ assert_raise(ArgumentError) { img.function_channel }
750
+ assert_raise(TypeError) { img.function_channel 1 }
751
+ assert_raise(ArgumentError) { img.function_channel Magick::PolynomialFunction }
752
+ assert_raise(TypeError) { img.function_channel Magick::PolynomialFunction, [] }
753
+ assert_raise(ArgumentError) { img.function_channel Magick::SinusoidFunction, 5, 90, 0.25, 0.75, 0.1 }
754
+ assert_raise(ArgumentError) { img.function_channel Magick::ArcsinFunction, 0.5, 0.5, 0.5, 0.5, 0.1 }
755
+ assert_raise(ArgumentError) { img.function_channel Magick::ArctanFunction, 15, 0.7, 0.5, 0.75, 0.1 }
756
756
  end
757
757
 
758
758
  def test_gramma_correct
759
- assert_raise(ArgumentError) { @img.gamma_correct }
760
- # All 4 arguments can't default to 1.0
761
- assert_raise(ArgumentError) { @img.gamma_correct(1.0) }
762
- assert_nothing_raised do
763
- res = @img.gamma_correct(0.8)
764
- assert_instance_of(Magick::Image, res)
765
- assert_not_same(@img, res)
766
- end
767
- assert_nothing_raised { @img.gamma_correct(0.8, 0.9) }
768
- assert_nothing_raised { @img.gamma_correct(0.8, 0.9, 1.0) }
769
- assert_nothing_raised { @img.gamma_correct(0.8, 0.9, 1.0, 1.1) }
770
- # too many arguments
771
- assert_raise(ArgumentError) { @img.gamma_correct(0.8, 0.9, 1.0, 1.1, 2) }
759
+ assert_raise(ArgumentError) { @img.gamma_correct }
760
+ # All 4 arguments can't default to 1.0
761
+ assert_raise(ArgumentError) { @img.gamma_correct(1.0) }
762
+ assert_nothing_raised do
763
+ res = @img.gamma_correct(0.8)
764
+ assert_instance_of(Magick::Image, res)
765
+ assert_not_same(@img, res)
766
+ end
767
+ assert_nothing_raised { @img.gamma_correct(0.8, 0.9) }
768
+ assert_nothing_raised { @img.gamma_correct(0.8, 0.9, 1.0) }
769
+ assert_nothing_raised { @img.gamma_correct(0.8, 0.9, 1.0, 1.1) }
770
+ # too many arguments
771
+ assert_raise(ArgumentError) { @img.gamma_correct(0.8, 0.9, 1.0, 1.1, 2) }
772
772
  end
773
773
 
774
774
  def test_gaussian_blur
775
- assert_nothing_raised do
776
- res = @img.gaussian_blur
777
- assert_instance_of(Magick::Image, res)
778
- assert_not_same(@img, res)
779
- end
780
- assert_nothing_raised { @img.gaussian_blur(0.0) }
781
- assert_nothing_raised { @img.gaussian_blur(0.0, 3.0) }
782
- # sigma must be != 0.0
783
- assert_raise(ArgumentError) { @img.gaussian_blur(1.0, 0.0) }
784
- assert_raise(ArgumentError) { @img.gaussian_blur(1.0, 3.0, 2) }
775
+ assert_nothing_raised do
776
+ res = @img.gaussian_blur
777
+ assert_instance_of(Magick::Image, res)
778
+ assert_not_same(@img, res)
779
+ end
780
+ assert_nothing_raised { @img.gaussian_blur(0.0) }
781
+ assert_nothing_raised { @img.gaussian_blur(0.0, 3.0) }
782
+ # sigma must be != 0.0
783
+ assert_raise(ArgumentError) { @img.gaussian_blur(1.0, 0.0) }
784
+ assert_raise(ArgumentError) { @img.gaussian_blur(1.0, 3.0, 2) }
785
785
  end
786
786
 
787
787
  def test_gaussian_blur_channel
788
- assert_nothing_raised do
789
- res = @img.gaussian_blur_channel
790
- assert_instance_of(Magick::Image, res)
791
- assert_not_same(@img, res)
792
- end
793
- assert_nothing_raised { @img.gaussian_blur_channel(0.0) }
794
- assert_nothing_raised { @img.gaussian_blur_channel(0.0, 3.0) }
795
- assert_nothing_raised { @img.gaussian_blur_channel(0.0, 3.0, Magick::RedChannel) }
796
- assert_nothing_raised { @img.gaussian_blur_channel(0.0, 3.0, Magick::RedChannel, Magick::BlueChannel) }
797
- assert_raise(TypeError) { @img.gaussian_blur_channel(0.0, 3.0, Magick::RedChannel, 2) }
788
+ assert_nothing_raised do
789
+ res = @img.gaussian_blur_channel
790
+ assert_instance_of(Magick::Image, res)
791
+ assert_not_same(@img, res)
792
+ end
793
+ assert_nothing_raised { @img.gaussian_blur_channel(0.0) }
794
+ assert_nothing_raised { @img.gaussian_blur_channel(0.0, 3.0) }
795
+ assert_nothing_raised { @img.gaussian_blur_channel(0.0, 3.0, Magick::RedChannel) }
796
+ assert_nothing_raised { @img.gaussian_blur_channel(0.0, 3.0, Magick::RedChannel, Magick::BlueChannel) }
797
+ assert_raise(TypeError) { @img.gaussian_blur_channel(0.0, 3.0, Magick::RedChannel, 2) }
798
798
  end
799
799
 
800
800
  def test_get_exif_by_entry
801
- assert_nothing_raised do
802
- res = @img.get_exif_by_entry
803
- assert_instance_of(Array, res)
804
- end
801
+ assert_nothing_raised do
802
+ res = @img.get_exif_by_entry
803
+ assert_instance_of(Array, res)
804
+ end
805
805
  end
806
806
 
807
807
  def test_get_exif_by_number
808
- assert_nothing_raised do
809
- res = @img.get_exif_by_number
810
- assert_instance_of(Hash, res)
811
- end
808
+ assert_nothing_raised do
809
+ res = @img.get_exif_by_number
810
+ assert_instance_of(Hash, res)
811
+ end
812
812
  end
813
813
 
814
814
  def test_get_pixels
815
- assert_nothing_raised do
816
- pixels = @img.get_pixels(0, 0, @img.columns, 1)
817
- assert_instance_of(Array, pixels)
818
- assert_equal(@img.columns, pixels.length)
819
- assert_block do
820
- pixels.all? { |p| p.is_a? Magick::Pixel }
821
- end
815
+ assert_nothing_raised do
816
+ pixels = @img.get_pixels(0, 0, @img.columns, 1)
817
+ assert_instance_of(Array, pixels)
818
+ assert_equal(@img.columns, pixels.length)
819
+ assert_block do
820
+ pixels.all? { |p| p.is_a? Magick::Pixel }
822
821
  end
823
- assert_raise(RangeError) { @img.get_pixels(0, 0, -1, 1) }
824
- assert_raise(RangeError) { @img.get_pixels(0, 0, @img.columns, -1) }
825
- assert_raise(RangeError) { @img.get_pixels(0, 0, @img.columns+1, 1) }
826
- assert_raise(RangeError) { @img.get_pixels(0, 0, @img.columns, @img.rows+1) }
822
+ end
823
+ assert_raise(RangeError) { @img.get_pixels(0, 0, -1, 1) }
824
+ assert_raise(RangeError) { @img.get_pixels(0, 0, @img.columns, -1) }
825
+ assert_raise(RangeError) { @img.get_pixels(0, 0, @img.columns+1, 1) }
826
+ assert_raise(RangeError) { @img.get_pixels(0, 0, @img.columns, @img.rows+1) }
827
827
  end
828
828
 
829
829
  def test_gray?
830
- gray = Magick::Image.new(20, 20) { self.background_color = 'gray50' }
831
- assert(gray.gray?)
832
- red = Magick::Image.new(20, 20) { self.background_color = 'red' }
833
- assert(!red.gray?)
830
+ gray = Magick::Image.new(20, 20) { self.background_color = 'gray50' }
831
+ assert(gray.gray?)
832
+ red = Magick::Image.new(20, 20) { self.background_color = 'red' }
833
+ assert(!red.gray?)
834
834
  end
835
835
 
836
836
  def test_histogram?
837
- assert_nothing_raised { @img.histogram? }
838
- assert(@img.histogram?)
837
+ assert_nothing_raised { @img.histogram? }
838
+ assert(@img.histogram?)
839
839
  end
840
840
 
841
841
  def test_implode
842
- assert_nothing_raised do
843
- res = @img.implode(0.5)
844
- assert_instance_of(Magick::Image, res)
845
- assert_not_same(@img, res)
846
- end
842
+ assert_nothing_raised do
843
+ res = @img.implode(0.5)
844
+ assert_instance_of(Magick::Image, res)
845
+ assert_not_same(@img, res)
846
+ end
847
847
  end
848
848
 
849
849
  def test_import_pixels
850
- pixels = @img.export_pixels(0, 0, @img.columns, 1, 'RGB')
851
- assert_nothing_raised do
852
- res = @img.import_pixels(0, 0, @img.columns, 1, 'RGB', pixels)
853
- assert_same(@img, res)
854
- end
855
- assert_raise(ArgumentError) { @img.import_pixels }
856
- assert_raise(ArgumentError) { @img.import_pixels(0) }
857
- assert_raise(ArgumentError) { @img.import_pixels(0, 0) }
858
- assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns) }
859
- assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, 1) }
860
- assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, 1, 'RGB') }
861
- assert_raise(TypeError) { @img.import_pixels('x', 0, @img.columns, 1, 'RGB', pixels) }
862
- assert_raise(TypeError) { @img.import_pixels(0, 'x', @img.columns, 1, 'RGB', pixels) }
863
- assert_raise(TypeError) { @img.import_pixels(0, 0, 'x', 1, 'RGB', pixels) }
864
- assert_raise(TypeError) { @img.import_pixels(0, 0, @img.columns, 'x', 'RGB', pixels) }
865
- assert_raise(TypeError) { @img.import_pixels(0, 0, @img.columns, 1, [2], pixels) }
866
- assert_raise(ArgumentError) { @img.import_pixels(-1, 0, @img.columns, 1, 'RGB', pixels) }
867
- assert_raise(ArgumentError) { @img.import_pixels(0, -1, @img.columns, 1, 'RGB', pixels) }
868
- assert_raise(ArgumentError) { @img.import_pixels(0, 0, -1, 1, 'RGB', pixels) }
869
- assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, -1, 'RGB', pixels) }
870
-
871
- # pixel array is too small
872
- assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, 2, 'RGB', pixels) }
873
- # pixel array doesn't contain a multiple of the map length
874
- pixels.shift
875
- assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, 1, 'RGB', pixels) }
850
+ pixels = @img.export_pixels(0, 0, @img.columns, 1, 'RGB')
851
+ assert_nothing_raised do
852
+ res = @img.import_pixels(0, 0, @img.columns, 1, 'RGB', pixels)
853
+ assert_same(@img, res)
854
+ end
855
+ assert_raise(ArgumentError) { @img.import_pixels }
856
+ assert_raise(ArgumentError) { @img.import_pixels(0) }
857
+ assert_raise(ArgumentError) { @img.import_pixels(0, 0) }
858
+ assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns) }
859
+ assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, 1) }
860
+ assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, 1, 'RGB') }
861
+ assert_raise(TypeError) { @img.import_pixels('x', 0, @img.columns, 1, 'RGB', pixels) }
862
+ assert_raise(TypeError) { @img.import_pixels(0, 'x', @img.columns, 1, 'RGB', pixels) }
863
+ assert_raise(TypeError) { @img.import_pixels(0, 0, 'x', 1, 'RGB', pixels) }
864
+ assert_raise(TypeError) { @img.import_pixels(0, 0, @img.columns, 'x', 'RGB', pixels) }
865
+ assert_raise(TypeError) { @img.import_pixels(0, 0, @img.columns, 1, [2], pixels) }
866
+ assert_raise(ArgumentError) { @img.import_pixels(-1, 0, @img.columns, 1, 'RGB', pixels) }
867
+ assert_raise(ArgumentError) { @img.import_pixels(0, -1, @img.columns, 1, 'RGB', pixels) }
868
+ assert_raise(ArgumentError) { @img.import_pixels(0, 0, -1, 1, 'RGB', pixels) }
869
+ assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, -1, 'RGB', pixels) }
870
+
871
+ # pixel array is too small
872
+ assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, 2, 'RGB', pixels) }
873
+ # pixel array doesn't contain a multiple of the map length
874
+ pixels.shift
875
+ assert_raise(ArgumentError) { @img.import_pixels(0, 0, @img.columns, 1, 'RGB', pixels) }
876
876
  end
877
877
 
878
878
  def test_level
879
- assert_nothing_raised do
880
- res = @img.level
881
- assert_instance_of(Magick::Image, res)
882
- assert_not_same(@img, res)
883
- end
884
- assert_nothing_raised { @img.level(0.0) }
885
- assert_nothing_raised { @img.level(0.0, 1.0) }
886
- assert_nothing_raised { @img.level(0.0, 1.0, Magick::QuantumRange) }
887
- assert_raise(ArgumentError) { @img.level(0.0, 1.0, Magick::QuantumRange, 2) }
888
- assert_raise(ArgumentError) { @img.level('x') }
889
- assert_raise(ArgumentError) { @img.level(0.0, 'x') }
890
- assert_raise(ArgumentError) { @img.level(0.0, 1.0, 'x') }
879
+ assert_nothing_raised do
880
+ res = @img.level
881
+ assert_instance_of(Magick::Image, res)
882
+ assert_not_same(@img, res)
883
+ end
884
+ assert_nothing_raised { @img.level(0.0) }
885
+ assert_nothing_raised { @img.level(0.0, 1.0) }
886
+ assert_nothing_raised { @img.level(0.0, 1.0, Magick::QuantumRange) }
887
+ assert_raise(ArgumentError) { @img.level(0.0, 1.0, Magick::QuantumRange, 2) }
888
+ assert_raise(ArgumentError) { @img.level('x') }
889
+ assert_raise(ArgumentError) { @img.level(0.0, 'x') }
890
+ assert_raise(ArgumentError) { @img.level(0.0, 1.0, 'x') }
891
891
  end
892
892
 
893
893
  # Ensure that #level properly swaps old-style arg list
894
894
  def test_level2
895
- img1 = @img.level(10, 2, 200)
896
- img2 = @img.level(10, 200, 2)
897
- assert_equal(img2, img1)
895
+ img1 = @img.level(10, 2, 200)
896
+ img2 = @img.level(10, 200, 2)
897
+ assert_equal(img2, img1)
898
898
 
899
- # Ensure that level2 uses new arg order
900
- img1 = @img.level2(10, 200, 2)
901
- assert_equal(img2, img1)
899
+ # Ensure that level2 uses new arg order
900
+ img1 = @img.level2(10, 200, 2)
901
+ assert_equal(img2, img1)
902
902
  end
903
903
 
904
904
  def test_level_channel
905
- assert_raise(ArgumentError) { @img.level_channel }
906
- assert_nothing_raised do
907
- res = @img.level_channel(Magick::RedChannel)
908
- assert_instance_of(Magick::Image, res)
909
- assert_not_same(@img, res)
910
- end
905
+ assert_raise(ArgumentError) { @img.level_channel }
906
+ assert_nothing_raised do
907
+ res = @img.level_channel(Magick::RedChannel)
908
+ assert_instance_of(Magick::Image, res)
909
+ assert_not_same(@img, res)
910
+ end
911
911
 
912
- assert_nothing_raised { @img.level_channel(Magick::RedChannel, 0.0) }
913
- assert_nothing_raised { @img.level_channel(Magick::RedChannel, 0.0, 1.0) }
914
- assert_nothing_raised { @img.level_channel(Magick::RedChannel, 0.0, 1.0, Magick::QuantumRange) }
912
+ assert_nothing_raised { @img.level_channel(Magick::RedChannel, 0.0) }
913
+ assert_nothing_raised { @img.level_channel(Magick::RedChannel, 0.0, 1.0) }
914
+ assert_nothing_raised { @img.level_channel(Magick::RedChannel, 0.0, 1.0, Magick::QuantumRange) }
915
915
 
916
- assert_raise(ArgumentError) { @img.level_channel(Magick::RedChannel, 0.0, 1.0, Magick::QuantumRange, 2) }
917
- assert_raise(TypeError) { @img.level_channel(2) }
918
- assert_raise(TypeError) { @img.level_channel(Magick::RedChannel, 'x') }
919
- assert_raise(TypeError) { @img.level_channel(Magick::RedChannel, 0.0, 'x') }
920
- assert_raise(TypeError) { @img.level_channel(Magick::RedChannel, 0.0, 1.0, 'x') }
916
+ assert_raise(ArgumentError) { @img.level_channel(Magick::RedChannel, 0.0, 1.0, Magick::QuantumRange, 2) }
917
+ assert_raise(TypeError) { @img.level_channel(2) }
918
+ assert_raise(TypeError) { @img.level_channel(Magick::RedChannel, 'x') }
919
+ assert_raise(TypeError) { @img.level_channel(Magick::RedChannel, 0.0, 'x') }
920
+ assert_raise(TypeError) { @img.level_channel(Magick::RedChannel, 0.0, 1.0, 'x') }
921
921
  end
922
922
 
923
923
  def level_colors
@@ -982,212 +982,212 @@ class Image2_UT < Test::Unit::TestCase
982
982
  # end
983
983
 
984
984
  def test_magnify
985
- assert_nothing_raised do
986
- res = @img.magnify
987
- assert_instance_of(Magick::Image, res)
988
- assert_not_same(@img, res)
989
- end
985
+ assert_nothing_raised do
986
+ res = @img.magnify
987
+ assert_instance_of(Magick::Image, res)
988
+ assert_not_same(@img, res)
989
+ end
990
990
 
991
- res = @img.magnify!
992
- assert_same(@img, res)
991
+ res = @img.magnify!
992
+ assert_same(@img, res)
993
993
  end
994
994
 
995
995
  def test_map
996
- map = Magick::Image.read('netscape:').first
997
- assert_nothing_raised do
998
- res = @img.map(map)
999
- assert_instance_of(Magick::Image, res)
1000
- assert_not_same(@img, res)
1001
- end
1002
- assert_nothing_raised { @img.map(map, true) }
1003
- assert_raise(NoMethodError) { @img.map(2) }
1004
- assert_raise(ArgumentError) { @img.map(map, true, 2) }
1005
- assert_raise(ArgumentError) { @img.map }
1006
- map.destroy!
1007
- assert_raise(Magick::DestroyedImageError) { @img.map(map, true) }
996
+ map = Magick::Image.read('netscape:').first
997
+ assert_nothing_raised do
998
+ res = @img.map(map)
999
+ assert_instance_of(Magick::Image, res)
1000
+ assert_not_same(@img, res)
1001
+ end
1002
+ assert_nothing_raised { @img.map(map, true) }
1003
+ assert_raise(NoMethodError) { @img.map(2) }
1004
+ assert_raise(ArgumentError) { @img.map(map, true, 2) }
1005
+ assert_raise(ArgumentError) { @img.map }
1006
+ map.destroy!
1007
+ assert_raise(Magick::DestroyedImageError) { @img.map(map, true) }
1008
1008
  end
1009
1009
 
1010
1010
  def test_marshal
1011
- img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
1012
- d = nil
1013
- img2 = nil
1014
- assert_nothing_raised { d = Marshal.dump(img) }
1015
- assert_nothing_raised { img2 = Marshal.load(d) }
1016
- assert_equal(img, img2)
1011
+ img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
1012
+ d = nil
1013
+ img2 = nil
1014
+ assert_nothing_raised { d = Marshal.dump(img) }
1015
+ assert_nothing_raised { img2 = Marshal.load(d) }
1016
+ assert_equal(img, img2)
1017
1017
  end
1018
1018
 
1019
1019
  def test_mask
1020
- cimg = Magick::Image.new(10,10)
1021
- assert_nothing_raised { @img.mask(cimg) }
1022
- res = nil
1023
- assert_nothing_raised { res = @img.mask }
1024
- assert_not_nil(res)
1025
- assert_not_same(cimg, res)
1026
- assert_equal(20, res.columns)
1027
- assert_equal(20, res.rows)
1020
+ cimg = Magick::Image.new(10,10)
1021
+ assert_nothing_raised { @img.mask(cimg) }
1022
+ res = nil
1023
+ assert_nothing_raised { res = @img.mask }
1024
+ assert_not_nil(res)
1025
+ assert_not_same(cimg, res)
1026
+ assert_equal(20, res.columns)
1027
+ assert_equal(20, res.rows)
1028
1028
 
1029
- # mask expects an Image and calls `cur_image'
1030
- assert_raise(NoMethodError) { @img.mask = 2 }
1029
+ # mask expects an Image and calls `cur_image'
1030
+ assert_raise(NoMethodError) { @img.mask = 2 }
1031
1031
 
1032
- img = @img.copy.freeze
1033
- assert_raise(FreezeError) { img.mask cimg }
1032
+ img = @img.copy.freeze
1033
+ assert_raise(FreezeError) { img.mask cimg }
1034
1034
 
1035
- @img.destroy!
1036
- assert_raise(Magick::DestroyedImageError) { @img.mask cimg }
1035
+ @img.destroy!
1036
+ assert_raise(Magick::DestroyedImageError) { @img.mask cimg }
1037
1037
  end
1038
1038
 
1039
1039
  def test_matte_fill_to_border
1040
- assert_nothing_raised do
1041
- res = @img.matte_fill_to_border(@img.columns/2, @img.rows/2)
1042
- assert_instance_of(Magick::Image, res)
1043
- assert_not_same(@img, res)
1044
- end
1045
- assert_nothing_raised { @img.matte_fill_to_border(@img.columns, @img.rows) }
1046
- assert_raise(ArgumentError) { @img.matte_fill_to_border(@img.columns+1, @img.rows) }
1047
- assert_raise(ArgumentError) { @img.matte_fill_to_border(@img.columns, @img.rows+1) }
1040
+ assert_nothing_raised do
1041
+ res = @img.matte_fill_to_border(@img.columns/2, @img.rows/2)
1042
+ assert_instance_of(Magick::Image, res)
1043
+ assert_not_same(@img, res)
1044
+ end
1045
+ assert_nothing_raised { @img.matte_fill_to_border(@img.columns, @img.rows) }
1046
+ assert_raise(ArgumentError) { @img.matte_fill_to_border(@img.columns+1, @img.rows) }
1047
+ assert_raise(ArgumentError) { @img.matte_fill_to_border(@img.columns, @img.rows+1) }
1048
1048
  end
1049
1049
 
1050
1050
  def test_matte_floodfill
1051
- assert_nothing_raised do
1052
- res = @img.matte_floodfill(@img.columns/2, @img.rows/2)
1053
- assert_instance_of(Magick::Image, res)
1054
- assert_not_same(@img, res)
1055
- end
1056
- assert_nothing_raised { @img.matte_floodfill(@img.columns, @img.rows) }
1057
- assert_raise(ArgumentError) { @img.matte_floodfill(@img.columns+1, @img.rows) }
1058
- assert_raise(ArgumentError) { @img.matte_floodfill(@img.columns, @img.rows+1) }
1051
+ assert_nothing_raised do
1052
+ res = @img.matte_floodfill(@img.columns/2, @img.rows/2)
1053
+ assert_instance_of(Magick::Image, res)
1054
+ assert_not_same(@img, res)
1055
+ end
1056
+ assert_nothing_raised { @img.matte_floodfill(@img.columns, @img.rows) }
1057
+ assert_raise(ArgumentError) { @img.matte_floodfill(@img.columns+1, @img.rows) }
1058
+ assert_raise(ArgumentError) { @img.matte_floodfill(@img.columns, @img.rows+1) }
1059
1059
  end
1060
1060
 
1061
1061
  def test_matte_replace
1062
- assert_nothing_raised do
1063
- res = @img.matte_replace(@img.columns/2, @img.rows/2)
1064
- assert_instance_of(Magick::Image, res)
1065
- assert_not_same(@img, res)
1066
- end
1062
+ assert_nothing_raised do
1063
+ res = @img.matte_replace(@img.columns/2, @img.rows/2)
1064
+ assert_instance_of(Magick::Image, res)
1065
+ assert_not_same(@img, res)
1066
+ end
1067
1067
  end
1068
1068
 
1069
1069
  def test_matte_reset!
1070
- assert_nothing_raised do
1071
- res = @img.matte_reset!
1072
- assert_same(@img, res)
1073
- end
1070
+ assert_nothing_raised do
1071
+ res = @img.matte_reset!
1072
+ assert_same(@img, res)
1073
+ end
1074
1074
  end
1075
1075
 
1076
1076
  def test_median_filter
1077
- assert_nothing_raised do
1078
- res = @img.median_filter
1079
- assert_instance_of(Magick::Image, res)
1080
- assert_not_same(@img, res)
1081
- end
1082
- assert_nothing_raised { @img.median_filter(0.5) }
1083
- assert_raise(ArgumentError) { @img.median_filter(0.5, 'x') }
1084
- assert_raise(TypeError) { @img.median_filter('x') }
1077
+ assert_nothing_raised do
1078
+ res = @img.median_filter
1079
+ assert_instance_of(Magick::Image, res)
1080
+ assert_not_same(@img, res)
1081
+ end
1082
+ assert_nothing_raised { @img.median_filter(0.5) }
1083
+ assert_raise(ArgumentError) { @img.median_filter(0.5, 'x') }
1084
+ assert_raise(TypeError) { @img.median_filter('x') }
1085
1085
  end
1086
1086
 
1087
1087
  def test_minify
1088
- assert_nothing_raised do
1089
- res = @img.minify
1090
- assert_instance_of(Magick::Image, res)
1091
- assert_not_same(@img, res)
1092
- end
1088
+ assert_nothing_raised do
1089
+ res = @img.minify
1090
+ assert_instance_of(Magick::Image, res)
1091
+ assert_not_same(@img, res)
1092
+ end
1093
1093
 
1094
- res = @img.minify!
1095
- assert_same(@img, res)
1094
+ res = @img.minify!
1095
+ assert_same(@img, res)
1096
1096
  end
1097
1097
 
1098
1098
  def test_modulate
1099
- assert_nothing_raised do
1100
- res = @img.modulate
1101
- assert_instance_of(Magick::Image, res)
1102
- assert_not_same(@img, res)
1103
- end
1104
- assert_nothing_raised { @img.modulate(0.5) }
1105
- assert_nothing_raised { @img.modulate(0.5, 0.5) }
1106
- assert_nothing_raised { @img.modulate(0.5, 0.5, 0.5) }
1107
- assert_raise(ArgumentError) { @img.modulate(0.5, 0.5, 0.5, 0.5) }
1108
- assert_raise(TypeError) { @img.modulate('x', 0.5, 0.5) }
1109
- assert_raise(TypeError) { @img.modulate(0.5, 'x', 0.5) }
1110
- assert_raise(TypeError) { @img.modulate(0.5, 0.5, 'x') }
1099
+ assert_nothing_raised do
1100
+ res = @img.modulate
1101
+ assert_instance_of(Magick::Image, res)
1102
+ assert_not_same(@img, res)
1103
+ end
1104
+ assert_nothing_raised { @img.modulate(0.5) }
1105
+ assert_nothing_raised { @img.modulate(0.5, 0.5) }
1106
+ assert_nothing_raised { @img.modulate(0.5, 0.5, 0.5) }
1107
+ assert_raise(ArgumentError) { @img.modulate(0.5, 0.5, 0.5, 0.5) }
1108
+ assert_raise(TypeError) { @img.modulate('x', 0.5, 0.5) }
1109
+ assert_raise(TypeError) { @img.modulate(0.5, 'x', 0.5) }
1110
+ assert_raise(TypeError) { @img.modulate(0.5, 0.5, 'x') }
1111
1111
  end
1112
1112
 
1113
1113
  def test_monochrome?
1114
1114
  # assert_block { @img.monochrome? }
1115
- @img.pixel_color(0,0, 'red')
1116
- assert_block { ! @img.monochrome? }
1115
+ @img.pixel_color(0,0, 'red')
1116
+ assert_block { ! @img.monochrome? }
1117
1117
  end
1118
1118
 
1119
1119
  def test_motion_blur
1120
- assert_nothing_raised do
1121
- res = @img.motion_blur(1.0, 7.0, 180)
1122
- assert_instance_of(Magick::Image, res)
1123
- assert_not_same(@img, res)
1124
- end
1125
- assert_raise(ArgumentError) { @img.motion_blur(1.0, 0.0, 180) }
1126
- assert_nothing_raised { @img.motion_blur(1.0, -1.0, 180) }
1120
+ assert_nothing_raised do
1121
+ res = @img.motion_blur(1.0, 7.0, 180)
1122
+ assert_instance_of(Magick::Image, res)
1123
+ assert_not_same(@img, res)
1124
+ end
1125
+ assert_raise(ArgumentError) { @img.motion_blur(1.0, 0.0, 180) }
1126
+ assert_nothing_raised { @img.motion_blur(1.0, -1.0, 180) }
1127
1127
  end
1128
1128
 
1129
1129
  def test_negate
1130
- assert_nothing_raised do
1131
- res = @img.negate
1132
- assert_instance_of(Magick::Image, res)
1133
- assert_not_same(@img, res)
1134
- end
1135
- assert_nothing_raised { @img.negate(true) }
1136
- assert_raise(ArgumentError) { @img.negate(true, 2) }
1130
+ assert_nothing_raised do
1131
+ res = @img.negate
1132
+ assert_instance_of(Magick::Image, res)
1133
+ assert_not_same(@img, res)
1134
+ end
1135
+ assert_nothing_raised { @img.negate(true) }
1136
+ assert_raise(ArgumentError) { @img.negate(true, 2) }
1137
1137
  end
1138
1138
 
1139
1139
  def test_negate_channel
1140
- assert_nothing_raised do
1141
- res = @img.negate_channel
1142
- assert_instance_of(Magick::Image, res)
1143
- assert_not_same(@img, res)
1144
- end
1145
- assert_nothing_raised { @img.negate_channel(true) }
1146
- assert_nothing_raised { @img.negate_channel(true, Magick::RedChannel) }
1147
- assert_nothing_raised { @img.negate_channel(true, Magick::RedChannel, Magick::BlueChannel) }
1148
- assert_raise(TypeError) { @img.negate_channel(true, Magick::RedChannel, 2) }
1140
+ assert_nothing_raised do
1141
+ res = @img.negate_channel
1142
+ assert_instance_of(Magick::Image, res)
1143
+ assert_not_same(@img, res)
1144
+ end
1145
+ assert_nothing_raised { @img.negate_channel(true) }
1146
+ assert_nothing_raised { @img.negate_channel(true, Magick::RedChannel) }
1147
+ assert_nothing_raised { @img.negate_channel(true, Magick::RedChannel, Magick::BlueChannel) }
1148
+ assert_raise(TypeError) { @img.negate_channel(true, Magick::RedChannel, 2) }
1149
1149
  end
1150
1150
 
1151
1151
  def test_normalize
1152
- assert_nothing_raised do
1153
- res = @img.normalize
1154
- assert_instance_of(Magick::Image, res)
1155
- assert_not_same(@img, res)
1156
- end
1152
+ assert_nothing_raised do
1153
+ res = @img.normalize
1154
+ assert_instance_of(Magick::Image, res)
1155
+ assert_not_same(@img, res)
1156
+ end
1157
1157
  end
1158
1158
 
1159
1159
  def test_normalize_channel
1160
- assert_nothing_raised do
1161
- res = @img.normalize_channel
1162
- assert_instance_of(Magick::Image, res)
1163
- assert_not_same(@img, res)
1164
- end
1165
- assert_nothing_raised { @img.normalize_channel(Magick::RedChannel) }
1166
- assert_nothing_raised { @img.normalize_channel(Magick::RedChannel, Magick::BlueChannel) }
1167
- assert_raise(TypeError) { @img.normalize_channel(Magick::RedChannel, 2) }
1160
+ assert_nothing_raised do
1161
+ res = @img.normalize_channel
1162
+ assert_instance_of(Magick::Image, res)
1163
+ assert_not_same(@img, res)
1164
+ end
1165
+ assert_nothing_raised { @img.normalize_channel(Magick::RedChannel) }
1166
+ assert_nothing_raised { @img.normalize_channel(Magick::RedChannel, Magick::BlueChannel) }
1167
+ assert_raise(TypeError) { @img.normalize_channel(Magick::RedChannel, 2) }
1168
1168
  end
1169
1169
 
1170
1170
  def test_oil_paint
1171
- assert_nothing_raised do
1172
- res = @img.oil_paint
1173
- assert_instance_of(Magick::Image, res)
1174
- assert_not_same(@img, res)
1175
- end
1176
- assert_nothing_raised { @img.oil_paint(2.0) }
1177
- assert_raise(ArgumentError) { @img.oil_paint(2.0, 1.0) }
1171
+ assert_nothing_raised do
1172
+ res = @img.oil_paint
1173
+ assert_instance_of(Magick::Image, res)
1174
+ assert_not_same(@img, res)
1175
+ end
1176
+ assert_nothing_raised { @img.oil_paint(2.0) }
1177
+ assert_raise(ArgumentError) { @img.oil_paint(2.0, 1.0) }
1178
1178
  end
1179
1179
 
1180
1180
  def test_opaque
1181
- assert_nothing_raised do
1182
- res = @img.opaque('white', 'red')
1183
- assert_instance_of(Magick::Image, res)
1184
- assert_not_same(@img, res)
1185
- end
1186
- red = Magick::Pixel.new(Magick::QuantumRange)
1187
- blue = Magick::Pixel.new(0, 0, Magick::QuantumRange)
1188
- assert_nothing_raised { @img.opaque(red, blue) }
1189
- assert_raise(TypeError) { @img.opaque(red, 2) }
1190
- assert_raise(TypeError) { @img.opaque(2, blue) }
1181
+ assert_nothing_raised do
1182
+ res = @img.opaque('white', 'red')
1183
+ assert_instance_of(Magick::Image, res)
1184
+ assert_not_same(@img, res)
1185
+ end
1186
+ red = Magick::Pixel.new(Magick::QuantumRange)
1187
+ blue = Magick::Pixel.new(0, 0, Magick::QuantumRange)
1188
+ assert_nothing_raised { @img.opaque(red, blue) }
1189
+ assert_raise(TypeError) { @img.opaque(red, 2) }
1190
+ assert_raise(TypeError) { @img.opaque(2, blue) }
1191
1191
  end
1192
1192
 
1193
1193
  def test_opaque_channel
@@ -1211,24 +1211,24 @@ class Image2_UT < Test::Unit::TestCase
1211
1211
  end
1212
1212
 
1213
1213
  def test_opaque?
1214
- assert_nothing_raised do
1215
- assert_block { @img.opaque? }
1216
- end
1217
- @img.opacity = Magick::TransparentOpacity
1218
- assert_block { ! @img.opaque? }
1214
+ assert_nothing_raised do
1215
+ assert_block { @img.opaque? }
1216
+ end
1217
+ @img.opacity = Magick::TransparentOpacity
1218
+ assert_block { ! @img.opaque? }
1219
1219
  end
1220
1220
 
1221
1221
  def test_ordered_dither
1222
- assert_nothing_raised do
1223
- res = @img.ordered_dither
1224
- assert_instance_of(Magick::Image, res)
1225
- assert_not_same(@img, res)
1226
- end
1227
- assert_nothing_raised { @img.ordered_dither(2) }
1228
- assert_nothing_raised { @img.ordered_dither(3) }
1229
- assert_nothing_raised { @img.ordered_dither(4) }
1230
- assert_raise(ArgumentError) { @img.ordered_dither(5) }
1231
- assert_raise(ArgumentError) { @img.ordered_dither(2, 1) }
1222
+ assert_nothing_raised do
1223
+ res = @img.ordered_dither
1224
+ assert_instance_of(Magick::Image, res)
1225
+ assert_not_same(@img, res)
1226
+ end
1227
+ assert_nothing_raised { @img.ordered_dither(2) }
1228
+ assert_nothing_raised { @img.ordered_dither(3) }
1229
+ assert_nothing_raised { @img.ordered_dither(4) }
1230
+ assert_raise(ArgumentError) { @img.ordered_dither(5) }
1231
+ assert_raise(ArgumentError) { @img.ordered_dither(2, 1) }
1232
1232
  end
1233
1233
 
1234
1234
  def test_paint_transparent
@@ -1251,31 +1251,31 @@ class Image2_UT < Test::Unit::TestCase
1251
1251
  end
1252
1252
 
1253
1253
  def test_palette?
1254
- img = Magick::Image.read(IMAGES_DIR+'/Flower_Hat.jpg').first
1255
- assert_nothing_raised do
1256
- assert_block { !img.palette? }
1257
- end
1258
- img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
1259
- assert_block { img.palette? }
1254
+ img = Magick::Image.read(IMAGES_DIR+'/Flower_Hat.jpg').first
1255
+ assert_nothing_raised do
1256
+ assert_block { !img.palette? }
1257
+ end
1258
+ img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
1259
+ assert_block { img.palette? }
1260
1260
  end
1261
1261
 
1262
1262
  def test_pixel_color
1263
- assert_nothing_raised do
1264
- res = @img.pixel_color(0,0)
1265
- assert_instance_of(Magick::Pixel, res)
1266
- end
1263
+ assert_nothing_raised do
1267
1264
  res = @img.pixel_color(0,0)
1268
- assert_equal(@img.background_color, res.to_color)
1269
- res = @img.pixel_color(0, 0, 'red')
1270
- assert_equal('white', res.to_color)
1271
- res = @img.pixel_color(0, 0)
1272
- assert_equal('red', res.to_color)
1265
+ assert_instance_of(Magick::Pixel, res)
1266
+ end
1267
+ res = @img.pixel_color(0,0)
1268
+ assert_equal(@img.background_color, res.to_color)
1269
+ res = @img.pixel_color(0, 0, 'red')
1270
+ assert_equal('white', res.to_color)
1271
+ res = @img.pixel_color(0, 0)
1272
+ assert_equal('red', res.to_color)
1273
1273
 
1274
- blue = Magick::Pixel.new(0, 0, Magick::QuantumRange)
1275
- assert_nothing_raised { @img.pixel_color(0,0, blue) }
1276
- # If args are out-of-bounds return the background color
1277
- img = Magick::Image.new(10, 10) { self.background_color = 'blue' }
1278
- assert_equal('blue', img.pixel_color(50, 50).to_color)
1274
+ blue = Magick::Pixel.new(0, 0, Magick::QuantumRange)
1275
+ assert_nothing_raised { @img.pixel_color(0,0, blue) }
1276
+ # If args are out-of-bounds return the background color
1277
+ img = Magick::Image.new(10, 10) { self.background_color = 'blue' }
1278
+ assert_equal('blue', img.pixel_color(50, 50).to_color)
1279
1279
  end
1280
1280
 
1281
1281
  def test_polaroid
@@ -1286,19 +1286,19 @@ class Image2_UT < Test::Unit::TestCase
1286
1286
  end
1287
1287
 
1288
1288
  def test_posterize
1289
- assert_nothing_raised do
1290
- res = @img.posterize
1291
- assert_instance_of(Magick::Image, res)
1292
- assert_not_same(@img, res)
1293
- end
1294
- assert_nothing_raised { @img.posterize(5) }
1295
- assert_nothing_raised { @img.posterize(5, true) }
1296
- assert_raise(ArgumentError) { @img.posterize(5, true, 'x') }
1289
+ assert_nothing_raised do
1290
+ res = @img.posterize
1291
+ assert_instance_of(Magick::Image, res)
1292
+ assert_not_same(@img, res)
1293
+ end
1294
+ assert_nothing_raised { @img.posterize(5) }
1295
+ assert_nothing_raised { @img.posterize(5, true) }
1296
+ assert_raise(ArgumentError) { @img.posterize(5, true, 'x') }
1297
1297
  end
1298
1298
  end
1299
1299
 
1300
1300
  if __FILE__ == $PROGRAM_NAME
1301
- IMAGES_DIR = '../doc/ex/images'
1302
- FILES = Dir[IMAGES_DIR+'/Button_*.gif']
1303
- Test::Unit::UI::Console::TestRunner.run(Image2_UT) unless RUBY_VERSION[/^1\.9|^2/]
1301
+ IMAGES_DIR = '../doc/ex/images'
1302
+ FILES = Dir[IMAGES_DIR+'/Button_*.gif']
1303
+ Test::Unit::UI::Console::TestRunner.run(Image2_UT) unless RUBY_VERSION[/^1\.9|^2/]
1304
1304
  end