rmagick 2.13.2 → 2.13.3.rc1

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.

Files changed (185) hide show
  1. checksums.yaml +15 -0
  2. data/LICENSE +20 -0
  3. data/README +15 -0
  4. data/README.rc +231 -0
  5. data/build_tarball.rake +1 -1
  6. data/doc/comtasks.html +2 -2
  7. data/doc/constants.html +2 -2
  8. data/doc/draw.html +2 -2
  9. data/doc/ex/PreserveAspectRatio.rb +0 -0
  10. data/doc/ex/ViewBox.rb +0 -0
  11. data/doc/ex/adaptive_threshold.rb +0 -0
  12. data/doc/ex/add_noise.rb +0 -0
  13. data/doc/ex/affine.rb +0 -0
  14. data/doc/ex/affine_transform.rb +0 -0
  15. data/doc/ex/arc.rb +0 -0
  16. data/doc/ex/arcpath.rb +0 -0
  17. data/doc/ex/average.rb +0 -0
  18. data/doc/ex/axes.rb +0 -0
  19. data/doc/ex/bilevel_channel.rb +0 -0
  20. data/doc/ex/blur_image.rb +0 -0
  21. data/doc/ex/border.rb +0 -0
  22. data/doc/ex/bounding_box.rb +0 -0
  23. data/doc/ex/cbezier1.rb +0 -0
  24. data/doc/ex/cbezier2.rb +0 -0
  25. data/doc/ex/cbezier3.rb +0 -0
  26. data/doc/ex/cbezier4.rb +0 -0
  27. data/doc/ex/cbezier5.rb +0 -0
  28. data/doc/ex/cbezier6.rb +0 -0
  29. data/doc/ex/channel.rb +0 -0
  30. data/doc/ex/charcoal.rb +0 -0
  31. data/doc/ex/chop.rb +0 -0
  32. data/doc/ex/circle.rb +0 -0
  33. data/doc/ex/clip_path.rb +0 -0
  34. data/doc/ex/coalesce.rb +0 -0
  35. data/doc/ex/color_fill_to_border.rb +0 -0
  36. data/doc/ex/color_floodfill.rb +0 -0
  37. data/doc/ex/color_histogram.rb +0 -0
  38. data/doc/ex/color_reset.rb +0 -0
  39. data/doc/ex/colorize.rb +0 -0
  40. data/doc/ex/colors.rb +0 -0
  41. data/doc/ex/composite.rb +0 -0
  42. data/doc/ex/composite_layers.rb +0 -0
  43. data/doc/ex/contrast.rb +0 -0
  44. data/doc/ex/crop.rb +0 -0
  45. data/doc/ex/cycle_colormap.rb +0 -0
  46. data/doc/ex/drawcomp.rb +0 -0
  47. data/doc/ex/drop_shadow.rb +0 -0
  48. data/doc/ex/edge.rb +0 -0
  49. data/doc/ex/ellipse.rb +0 -0
  50. data/doc/ex/emboss.rb +0 -0
  51. data/doc/ex/enhance.rb +0 -0
  52. data/doc/ex/equalize.rb +0 -0
  53. data/doc/ex/evenodd.rb +0 -0
  54. data/doc/ex/flatten_images.rb +0 -0
  55. data/doc/ex/flip.rb +0 -0
  56. data/doc/ex/flop.rb +0 -0
  57. data/doc/ex/fonts.rb +0 -0
  58. data/doc/ex/frame.rb +0 -0
  59. data/doc/ex/gaussian_blur.rb +0 -0
  60. data/doc/ex/get_pixels.rb +0 -0
  61. data/doc/ex/gradientfill.rb +0 -0
  62. data/doc/ex/grav.rb +0 -0
  63. data/doc/ex/gravity.rb +0 -0
  64. data/doc/ex/hatchfill.rb +0 -0
  65. data/doc/ex/images/logo400x83.gif +0 -0
  66. data/doc/ex/implode.rb +0 -0
  67. data/doc/ex/level.rb +0 -0
  68. data/doc/ex/line.rb +0 -0
  69. data/doc/ex/matte_fill_to_border.rb +0 -0
  70. data/doc/ex/matte_floodfill.rb +0 -0
  71. data/doc/ex/matte_replace.rb +0 -0
  72. data/doc/ex/median_filter.rb +0 -0
  73. data/doc/ex/modulate.rb +0 -0
  74. data/doc/ex/mono.rb +0 -0
  75. data/doc/ex/morph.rb +0 -0
  76. data/doc/ex/mosaic.rb +0 -0
  77. data/doc/ex/motion_blur.rb +0 -0
  78. data/doc/ex/negate.rb +0 -0
  79. data/doc/ex/nested_rvg.rb +0 -0
  80. data/doc/ex/nonzero.rb +0 -0
  81. data/doc/ex/normalize.rb +0 -0
  82. data/doc/ex/oil_paint.rb +0 -0
  83. data/doc/ex/opacity.rb +0 -0
  84. data/doc/ex/ordered_dither.rb +0 -0
  85. data/doc/ex/path.rb +0 -0
  86. data/doc/ex/pattern1.rb +0 -0
  87. data/doc/ex/pattern2.rb +0 -0
  88. data/doc/ex/polygon.rb +0 -0
  89. data/doc/ex/polyline.rb +0 -0
  90. data/doc/ex/preview.rb +0 -0
  91. data/doc/ex/qbezierpath.rb +0 -0
  92. data/doc/ex/quantize-m.rb +0 -0
  93. data/doc/ex/radial_blur.rb +0 -0
  94. data/doc/ex/raise.rb +0 -0
  95. data/doc/ex/rectangle.rb +0 -0
  96. data/doc/ex/reduce_noise.rb +0 -0
  97. data/doc/ex/roll.rb +0 -0
  98. data/doc/ex/rotate.rb +0 -0
  99. data/doc/ex/rotate_f.rb +0 -0
  100. data/doc/ex/roundrect.rb +0 -0
  101. data/doc/ex/rubyname.rb +0 -0
  102. data/doc/ex/rvg_linecap.rb +0 -0
  103. data/doc/ex/rvg_linejoin.rb +0 -0
  104. data/doc/ex/rvg_opacity.rb +0 -0
  105. data/doc/ex/rvg_stroke_dasharray.rb +0 -0
  106. data/doc/ex/segment.rb +0 -0
  107. data/doc/ex/shade.rb +0 -0
  108. data/doc/ex/shave.rb +0 -0
  109. data/doc/ex/shear.rb +0 -0
  110. data/doc/ex/sketch.rb +0 -0
  111. data/doc/ex/skewx.rb +0 -0
  112. data/doc/ex/skewy.rb +0 -0
  113. data/doc/ex/smile.rb +0 -0
  114. data/doc/ex/solarize.rb +0 -0
  115. data/doc/ex/spread.rb +0 -0
  116. data/doc/ex/stegano.rb +0 -0
  117. data/doc/ex/stroke_dasharray.rb +0 -0
  118. data/doc/ex/stroke_fill.rb +0 -0
  119. data/doc/ex/stroke_linecap.rb +0 -0
  120. data/doc/ex/stroke_linejoin.rb +0 -0
  121. data/doc/ex/stroke_width.rb +0 -0
  122. data/doc/ex/swirl.rb +0 -0
  123. data/doc/ex/text.rb +0 -0
  124. data/doc/ex/text_align.rb +0 -0
  125. data/doc/ex/text_antialias.rb +0 -0
  126. data/doc/ex/text_undercolor.rb +0 -0
  127. data/doc/ex/texture_fill_to_border.rb +0 -0
  128. data/doc/ex/texture_floodfill.rb +0 -0
  129. data/doc/ex/texturefill.rb +0 -0
  130. data/doc/ex/threshold.rb +0 -0
  131. data/doc/ex/to_blob.rb +0 -0
  132. data/doc/ex/translate.rb +0 -0
  133. data/doc/ex/transparent.rb +0 -0
  134. data/doc/ex/unsharp_mask.rb +0 -0
  135. data/doc/ex/wave.rb +0 -0
  136. data/doc/ilist.html +2 -2
  137. data/doc/image1.html +2 -2
  138. data/doc/image2.html +2 -2
  139. data/doc/image3.html +2 -2
  140. data/doc/imageattrs.html +2 -2
  141. data/doc/imusage.html +2 -2
  142. data/doc/index.html +3 -3
  143. data/doc/info.html +2 -2
  144. data/doc/magick.html +2 -2
  145. data/doc/optequiv.html +2 -2
  146. data/doc/rvg.html +2 -2
  147. data/doc/rvgclip.html +2 -2
  148. data/doc/rvggroup.html +2 -2
  149. data/doc/rvgimage.html +2 -2
  150. data/doc/rvgpattern.html +2 -2
  151. data/doc/rvgshape.html +2 -2
  152. data/doc/rvgstyle.html +2 -2
  153. data/doc/rvgtext.html +2 -2
  154. data/doc/rvgtspan.html +2 -2
  155. data/doc/rvgtut.html +2 -2
  156. data/doc/rvguse.html +2 -2
  157. data/doc/rvgxform.html +2 -2
  158. data/doc/struct.html +2 -2
  159. data/doc/usage.html +2 -2
  160. data/examples/crop_with_gravity.rb +0 -0
  161. data/examples/demo.rb +0 -0
  162. data/examples/describe.rb +0 -0
  163. data/examples/rotating_text.rb +0 -0
  164. data/ext/RMagick/extconf.rb +1 -9
  165. data/ext/RMagick/rmimage.c +1 -1
  166. data/lib/rvg/to_c.rb +103 -0
  167. data/rmagick.gemspec +5 -3
  168. data/test/Draw.rb +121 -0
  169. data/test/Image1.rb +763 -0
  170. data/test/Image2.rb +1308 -0
  171. data/test/Image3.rb +1002 -0
  172. data/test/ImageList1.rb +808 -0
  173. data/test/ImageList2.rb +389 -0
  174. data/test/Image_attributes.rb +683 -0
  175. data/test/Import_Export.rb +116 -0
  176. data/test/Info.rb +349 -0
  177. data/test/Magick.rb +364 -0
  178. data/test/Pixel.rb +120 -0
  179. data/test/Preview.rb +62 -0
  180. data/test/all_basic.rb +42 -0
  181. data/test/cmyk.icm +0 -0
  182. data/test/srgb.icm +0 -0
  183. metadata +339 -320
  184. data/README.html +0 -10
  185. data/ext/RMagick/MANIFEST +0 -358
@@ -0,0 +1,808 @@
1
+ #! /usr/local/bin/ruby -w
2
+
3
+ require 'RMagick'
4
+ require 'test/unit'
5
+ require 'test/unit/ui/console/testrunner' if !RUBY_VERSION[/^1\.9|^2/]
6
+
7
+ class ImageList1_UT < Test::Unit::TestCase
8
+
9
+ def setup
10
+ @list = Magick::ImageList.new(*FILES[0..9])
11
+ @list2 = Magick::ImageList.new # intersection is 5..9
12
+ @list2 << @list[5]
13
+ @list2 << @list[6]
14
+ @list2 << @list[7]
15
+ @list2 << @list[8]
16
+ @list2 << @list[9]
17
+ end
18
+
19
+ def test_delay
20
+ assert_nothing_raised { @list.delay }
21
+ assert_equal(0, @list.delay)
22
+ assert_nothing_raised { @list.delay = 20 }
23
+ assert_equal(20, @list.delay)
24
+ assert_raise(ArgumentError) { @list.delay = 'x' }
25
+ end
26
+
27
+ def test_ticks_per_second
28
+ assert_nothing_raised { @list.ticks_per_second }
29
+ assert_equal(100, @list.ticks_per_second)
30
+ assert_nothing_raised { @list.ticks_per_second = 1000 }
31
+ assert_equal(1000, @list.ticks_per_second)
32
+ assert_raise(ArgumentError) { @list.ticks_per_second = 'x' }
33
+ end
34
+
35
+ def test_iterations
36
+ assert_nothing_raised { @list.iterations }
37
+ assert_equal(1, @list.iterations)
38
+ assert_nothing_raised { @list.iterations = 20 }
39
+ assert_equal(20, @list.iterations)
40
+ assert_raise(ArgumentError) { @list.iterations = 'x' }
41
+ end
42
+
43
+ # also tests #size
44
+ def test_length
45
+ assert_nothing_raised { @list.length }
46
+ assert_equal(10, @list.length)
47
+ assert_raise(NoMethodError) { @list.length = 2 }
48
+ end
49
+
50
+ def test_scene
51
+ assert_nothing_raised { @list.scene }
52
+ assert_equal(9, @list.scene)
53
+ assert_nothing_raised { @list.scene = 0 }
54
+ assert_equal(0, @list.scene)
55
+ assert_nothing_raised { @list.scene = 1 }
56
+ assert_equal(1, @list.scene)
57
+ assert_raise(IndexError) { @list.scene = -1 }
58
+ assert_raise(IndexError) { @list.scene = 1000 }
59
+ assert_raise(IndexError) { @list.scene = nil }
60
+
61
+ # allow nil on empty list
62
+ empty_list = Magick::ImageList.new
63
+ assert_nothing_raised { empty_list.scene = nil }
64
+ end
65
+
66
+ def test_undef_array_methods
67
+ assert_raise(NoMethodError) { @list.assoc }
68
+ assert_raise(NoMethodError) { @list.flatten }
69
+ assert_raise(NoMethodError) { @list.flatten! }
70
+ assert_raise(NoMethodError) { @list.join }
71
+ assert_raise(NoMethodError) { @list.pack }
72
+ assert_raise(NoMethodError) { @list.rassoc }
73
+ end
74
+
75
+ def test_all
76
+ q = nil
77
+ assert_nothing_raised { q = @list.all? { |i| i.class == Magick::Image } }
78
+ assert(q)
79
+ end
80
+
81
+ def test_any
82
+ q = nil
83
+ assert_nothing_raised { q = @list.all? { |i| false } }
84
+ assert(!q)
85
+ assert_nothing_raised { q = @list.all? { |i| i.class == Magick::Image } }
86
+ assert(q)
87
+ end
88
+
89
+ def test_aref
90
+ assert_nothing_raised { @list[0] }
91
+ assert_instance_of(Magick::Image, @list[0])
92
+ assert_instance_of(Magick::Image, @list[-1])
93
+ assert_instance_of(Magick::ImageList, @list[0,1])
94
+ assert_instance_of(Magick::ImageList, @list[0..2])
95
+ assert_nil(@list[20])
96
+ end
97
+
98
+ def test_aset
99
+ img = Magick::Image.new(5,5)
100
+ assert_nothing_raised do
101
+ rv = @list[0] = img
102
+ assert_same(img, rv)
103
+ assert_same(img, @list[0])
104
+ assert_equal(0, @list.scene)
105
+ end
106
+
107
+ # replace 2 images with 1
108
+ assert_nothing_raised do
109
+ img = Magick::Image.new(5,5)
110
+ rv = @list[1,2] = img
111
+ assert_same(img, rv)
112
+ assert_equal(9, @list.length)
113
+ assert_same(img, @list[1])
114
+ assert_equal(1, @list.scene)
115
+ end
116
+
117
+ # replace 1 image with 2
118
+ assert_nothing_raised do
119
+ img = Magick::Image.new(5,5)
120
+ img2 = Magick::Image.new(5,5)
121
+ ary = [img, img2]
122
+ rv = @list[3,1] = ary
123
+ assert_same(ary, rv)
124
+ assert_equal(10, @list.length)
125
+ assert_same(img, @list[3])
126
+ assert_same(img2, @list[4])
127
+ assert_equal(4, @list.scene)
128
+ end
129
+
130
+ assert_nothing_raised do
131
+ img = Magick::Image.new(5,5)
132
+ rv = @list[5..6] = img
133
+ assert_same(img, rv)
134
+ assert_equal(9, @list.length)
135
+ assert_same(img, @list[5])
136
+ assert_equal(5, @list.scene)
137
+ end
138
+
139
+ assert_nothing_raised do
140
+ ary = [img, img]
141
+ rv = @list[7..8] = ary
142
+ assert_same(ary, rv)
143
+ assert_equal(9, @list.length)
144
+ assert_same(img, @list[7])
145
+ assert_same(img, @list[8])
146
+ assert_equal(8, @list.scene)
147
+ end
148
+
149
+ assert_nothing_raised do
150
+ rv = @list[-1] = img
151
+ assert_same(img, rv)
152
+ assert_equal(9, @list.length)
153
+ assert_same(img, @list[8])
154
+ assert_equal(8, @list.scene)
155
+ end
156
+
157
+ assert_raise(ArgumentError) { @list[0] = 1 }
158
+ assert_raise(ArgumentError) { @list[0,1] = [1,2] }
159
+ assert_raise(ArgumentError) { @list[2..3] = 'x' }
160
+ end
161
+
162
+ def test_and
163
+ @list.scene = 7
164
+ cur = @list.cur_image
165
+ assert_nothing_raised do
166
+ res = @list & @list2
167
+ assert_instance_of(Magick::ImageList, res)
168
+ assert_not_same(res, @list)
169
+ assert_not_same(res, @list2)
170
+ assert_equal(5, res.length)
171
+ assert_equal(2, res.scene)
172
+ assert_same(cur, res.cur_image)
173
+ end
174
+
175
+ # current scene not in the result, set result scene to last image in result
176
+ @list.scene = 2
177
+ assert_nothing_raised do
178
+ res = @list & @list2
179
+ assert_instance_of(Magick::ImageList, res)
180
+ assert_equal(4, res.scene)
181
+ end
182
+
183
+ assert_raise(ArgumentError) { @list & 2 }
184
+ end
185
+
186
+ def test_at
187
+ assert_nothing_raised do
188
+ cur = @list.cur_image
189
+ img = @list.at(7)
190
+ assert_same(img, @list[7])
191
+ assert_same(cur, @list.cur_image)
192
+ img = @list.at(10)
193
+ assert_nil(img)
194
+ assert_same(cur, @list.cur_image)
195
+ img = @list.at(-1)
196
+ assert_same(img, @list[9])
197
+ assert_same(cur, @list.cur_image)
198
+ end
199
+ end
200
+
201
+ def test_star
202
+ @list.scene = 7
203
+ cur = @list.cur_image
204
+ assert_nothing_raised do
205
+ res = @list * 2
206
+ assert_instance_of(Magick::ImageList, res)
207
+ assert_equal(20, res.length)
208
+ assert_not_same(res, @list)
209
+ assert_same(cur, res.cur_image)
210
+ end
211
+
212
+ assert_raise(ArgumentError) { @list * 'x' }
213
+ end
214
+
215
+ def test_plus
216
+ @list.scene = 7
217
+ cur = @list.cur_image
218
+ assert_nothing_raised do
219
+ res = @list + @list2
220
+ assert_instance_of(Magick::ImageList, res)
221
+ assert_equal(15, res.length)
222
+ assert_not_same(res, @list)
223
+ assert_not_same(res, @list2)
224
+ assert_same(cur, res.cur_image)
225
+ end
226
+
227
+ assert_raise(ArgumentError) { @list + [2] }
228
+ end
229
+
230
+ def test_minus
231
+ @list.scene = 0
232
+ cur = @list.cur_image
233
+ assert_nothing_raised do
234
+ res = @list - @list2
235
+ assert_instance_of(Magick::ImageList, res)
236
+ assert_equal(5, res.length)
237
+ assert_not_same(res, @list)
238
+ assert_not_same(res, @list2)
239
+ assert_same(cur, res.cur_image)
240
+ end
241
+
242
+ # current scene not in result - set result scene to last image in result
243
+ @list.scene = 7
244
+ cur = @list.cur_image
245
+ assert_nothing_raised do
246
+ res = @list - @list2
247
+ assert_instance_of(Magick::ImageList, res)
248
+ assert_equal(5, res.length)
249
+ assert_equal(4, res.scene)
250
+ end
251
+ end
252
+
253
+ def test_catenate
254
+ assert_nothing_raised do
255
+ @list2.each { |img| @list << img }
256
+ assert_equal(15, @list.length)
257
+ assert_equal(14, @list.scene)
258
+ end
259
+
260
+ assert_raise(ArgumentError) { @list << 2 }
261
+ assert_raise(ArgumentError) { @list << [2] }
262
+ end
263
+
264
+ def test_or
265
+ assert_nothing_raised do
266
+ @list.scene = 7
267
+ # The or of these two lists should be the same as @list
268
+ # but not be the *same* list
269
+ res = @list | @list2
270
+ assert_instance_of(Magick::ImageList, res)
271
+ assert_not_same(res, @list)
272
+ assert_not_same(res, @list2)
273
+ assert_equal(res, @list)
274
+ end
275
+
276
+ # Try or'ing disjoint lists
277
+ temp_list = Magick::ImageList.new(*FILES[10..14])
278
+ res = @list | temp_list
279
+ assert_instance_of(Magick::ImageList, res)
280
+ assert_equal(15, res.length)
281
+ assert_equal(7, res.scene)
282
+
283
+ assert_raise(ArgumentError) { @list | 2 }
284
+ assert_raise(ArgumentError) { @list | [2] }
285
+ end
286
+
287
+ def test_clear
288
+ assert_nothing_raised { @list.clear }
289
+ assert_instance_of(Magick::ImageList, @list)
290
+ assert_equal(0, @list.length)
291
+ assert_nil(@list.scene)
292
+ end
293
+
294
+ def test_collect
295
+ assert_nothing_raised do
296
+ cur = @list.cur_image
297
+ scene = @list.scene
298
+ res = @list.collect { |img| img.negate }
299
+ assert_instance_of(Magick::ImageList, res)
300
+ assert_not_same(res, @list)
301
+ assert_equal(scene, res.scene)
302
+ end
303
+ assert_nothing_raised do
304
+ scene = @list.scene
305
+ @list.collect! { |img| img.negate }
306
+ assert_instance_of(Magick::ImageList, @list)
307
+ assert_equal(scene, @list.scene)
308
+ end
309
+ end
310
+
311
+ def test_compact
312
+ assert_nothing_raised do
313
+ res = @list.compact
314
+ assert_not_same(res, @list)
315
+ assert_equal(res, @list)
316
+ end
317
+ assert_nothing_raised do
318
+ res = @list
319
+ @list.compact!
320
+ assert_instance_of(Magick::ImageList, @list)
321
+ assert_equal(res, @list)
322
+ assert_same(res, @list)
323
+ end
324
+ end
325
+
326
+ def test_concat
327
+ assert_nothing_raised do
328
+ res = @list.concat(@list2)
329
+ assert_instance_of(Magick::ImageList, res)
330
+ assert_equal(15, res.length)
331
+ assert_same(res[14], res.cur_image)
332
+ end
333
+ assert_raise(ArgumentError) { res = @list.concat(2) }
334
+ assert_raise(ArgumentError) { res = @list.concat([2]) }
335
+ end
336
+
337
+ def test_delete
338
+ assert_nothing_raised do
339
+ cur = @list.cur_image
340
+ img = @list[7]
341
+ assert_same(img, @list.delete(img))
342
+ assert_equal(9, @list.length)
343
+ assert_same(cur, @list.cur_image)
344
+
345
+ # Try deleting the current image.
346
+ assert_same(cur, @list.delete(cur))
347
+ assert_same(@list[-1], @list.cur_image)
348
+
349
+ assert_raise(ArgumentError) { @list.delete(2) }
350
+ assert_raise(ArgumentError) { @list.delete([2]) }
351
+
352
+ # Try deleting something that isn't in the list.
353
+ # Should return the value of the block.
354
+ assert_nothing_raised do
355
+ img = Magick::Image.read(FILES[10]).first
356
+ res = @list.delete(img) { 1 }
357
+ assert_equal(1, res)
358
+ end
359
+ end
360
+ end
361
+
362
+ def test_delete_at
363
+ @list.scene = 7
364
+ cur = @list.cur_image
365
+ assert_nothing_raised { @list.delete_at(9) }
366
+ assert_same(cur, @list.cur_image)
367
+ assert_nothing_raised { @list.delete_at(7) }
368
+ assert_same(@list[-1], @list.cur_image)
369
+ end
370
+
371
+ def test_delete_if
372
+ @list.scene = 7
373
+ cur = @list.cur_image
374
+ assert_nothing_raised do
375
+ @list.delete_if { |img| img.filename =~ /5/ }
376
+ assert_instance_of(Magick::ImageList, @list)
377
+ assert_equal(9, @list.length)
378
+ assert_same(cur, @list.cur_image)
379
+ end
380
+
381
+ # Delete the current image
382
+ assert_nothing_raised do
383
+ @list.delete_if { |img| img.filename =~ /7/ }
384
+ assert_instance_of(Magick::ImageList, @list)
385
+ assert_equal(8, @list.length)
386
+ assert_same(@list[-1], @list.cur_image)
387
+ end
388
+ end
389
+
390
+ # defined by Enumerable
391
+ def test_enumerables
392
+ assert_nothing_raised { @list.detect { true } }
393
+ assert_nothing_raised do
394
+ @list.each_with_index { |img, n| assert_instance_of(Magick::Image, img) }
395
+ end
396
+ assert_nothing_raised { @list.entries }
397
+ assert_nothing_raised { @list.include?(@list[0]) }
398
+ assert_nothing_raised { @list.inject(0) { 0 } }
399
+ assert_nothing_raised { @list.max }
400
+ assert_nothing_raised { @list.min }
401
+ assert_nothing_raised { @list.sort }
402
+ assert_nothing_raised { @list.sort_by {|img| img.signature} }
403
+ assert_nothing_raised { @list.zip }
404
+ end
405
+
406
+ def test_eql?
407
+ list2 = @list
408
+ assert(@list.eql?(list2))
409
+ list2 = @list.copy
410
+ assert(! @list.eql?(list2))
411
+ end
412
+
413
+ def test_fill
414
+ list = @list.copy
415
+ img = list[0].copy
416
+ assert_nothing_raised do
417
+ assert_instance_of(Magick::ImageList, list.fill(img))
418
+ end
419
+ list.each {|el| assert_same(el, img) }
420
+
421
+ list = @list.copy
422
+ list.fill(img, 0, 3)
423
+ 0.upto(2) {|i| assert_same(img, list[i]) }
424
+
425
+ list = @list.copy
426
+ list.fill(img, 4..7)
427
+ 4.upto(7) {|i| assert_same(img, list[i]) }
428
+
429
+ list = @list.copy
430
+ list.fill { |i| list[i] = img }
431
+ list.each {|el| assert_same(el, img) }
432
+
433
+ list = @list.copy
434
+ list.fill(0, 3) { |i| list[i] = img }
435
+ 0.upto(2) {|i| assert_same(img, list[i]) }
436
+
437
+ assert_raise(ArgumentError) { list.fill('x', 0) }
438
+ end
439
+
440
+ def test_find
441
+ assert_nothing_raised { @list.find { true } }
442
+ end
443
+
444
+ def find_all
445
+ assert_nothing_raised do
446
+ res = @list.select { |img| img.filename =~ /Button_2/ }
447
+ assert_instance_of(Magick::ImageList, res)
448
+ assert_equal(1, res.length)
449
+ assert_same(res[0], @list[2])
450
+ end
451
+ end
452
+
453
+ def test_insert
454
+ assert_nothing_raised do
455
+ @list.scene = 7
456
+ cur = @list.cur_image
457
+ assert_instance_of(Magick::ImageList, @list.insert(1, @list[2]))
458
+ assert_same(cur, @list.cur_image)
459
+ @list.insert(1, @list[2], @list[3], @list[4])
460
+ assert_same(cur, @list.cur_image)
461
+ end
462
+
463
+ assert_raise(ArgumentError) { @list.insert(0, 'x') }
464
+ assert_raise(ArgumentError) { @list.insert(0, 'x', 'y') }
465
+ end
466
+
467
+ def test_last
468
+ img = Magick::Image.new(5,5)
469
+ @list << img
470
+ img2 = nil
471
+ assert_nothing_raised { img2 = @list.last }
472
+ assert_instance_of(Magick::Image, img2)
473
+ assert_equal(img2, img)
474
+ img2 = Magick::Image.new(5,5)
475
+ @list << img2
476
+ ilist = nil
477
+ assert_nothing_raised { ilist = @list.last(2) }
478
+ assert_instance_of(Magick::ImageList, ilist)
479
+ assert_equal(2, ilist.length)
480
+ assert_equal(1, ilist.scene)
481
+ assert_equal(img, ilist[0])
482
+ assert_equal(img2, ilist[1])
483
+ end
484
+
485
+ def test___map__
486
+ img = @list[0]
487
+ assert_nothing_raised do
488
+ @list.__map__ { |x| img }
489
+ end
490
+ assert_instance_of(Magick::ImageList, @list)
491
+ assert_raise(ArgumentError) { @list.__map__ { 2 } }
492
+ end
493
+
494
+ def test_map!
495
+ img = @list[0]
496
+ assert_nothing_raised do
497
+ @list.map! { img }
498
+ end
499
+ assert_instance_of(Magick::ImageList, @list)
500
+ assert_raise(ArgumentError) { @list.map! { 2 } }
501
+ end
502
+
503
+ if !RUBY_VERSION[/^1\.9|^2/]
504
+ def test_nitems
505
+ n = nil
506
+ assert_nothing_raised { n = @list.nitems }
507
+ assert_equal(10, n)
508
+ end
509
+ end
510
+
511
+ def test_partition
512
+ a = nil
513
+ n = -1
514
+ assert_nothing_raised { a = @list.partition { n += 1; (n&1).zero? } }
515
+ assert_instance_of(Array, a)
516
+ assert_equal(2, a.size)
517
+ assert_instance_of(Magick::ImageList, a[0])
518
+ assert_instance_of(Magick::ImageList, a[1])
519
+ assert_equal(4, a[0].scene)
520
+ assert_equal(5, a[0].length)
521
+ assert_equal(4, a[1].scene)
522
+ assert_equal(5, a[1].length)
523
+ end
524
+
525
+ def test_pop
526
+ @list.scene = 8
527
+ cur = @list.cur_image
528
+ last = @list[-1]
529
+ assert_nothing_raised do
530
+ assert_same(last, @list.pop)
531
+ assert_same(cur, @list.cur_image)
532
+ end
533
+
534
+ assert_same(cur, @list.pop)
535
+ assert_same(@list[-1], @list.cur_image)
536
+ end
537
+
538
+ def test_push
539
+ list = @list
540
+ img1 = @list[0]
541
+ img2 = @list[1]
542
+ assert_nothing_raised { @list.push(img1, img2) }
543
+ assert_same(list, @list) # push returns self
544
+ assert_same(img2, @list.cur_image)
545
+ end
546
+
547
+ def test_reject
548
+ @list.scene = 7
549
+ cur = @list.cur_image
550
+ list = @list
551
+ assert_nothing_raised do
552
+ res = @list.reject {|img| img.filename =~ /Button_9/ }
553
+ assert_equal(9, res.length)
554
+ assert_instance_of(Magick::ImageList, res)
555
+ assert_same(cur, res.cur_image)
556
+ end
557
+ assert_same(list, @list)
558
+ assert_same(cur, @list.cur_image)
559
+
560
+ # Omit current image from result list - result cur_image s/b last image
561
+ res = @list.reject {|img| img.filename =~ /Button_7/}
562
+ assert_equal(9, res.length)
563
+ assert_same(res[-1], res.cur_image)
564
+ assert_same(cur, @list.cur_image)
565
+ end
566
+
567
+ def test_reject!
568
+ @list.scene = 7
569
+ cur = @list.cur_image
570
+ assert_nothing_raised do
571
+ @list.reject! { |img| img.filename =~ /5/ }
572
+ assert_instance_of(Magick::ImageList, @list)
573
+ assert_equal(9, @list.length)
574
+ assert_same(cur, @list.cur_image)
575
+ end
576
+
577
+ # Delete the current image
578
+ assert_nothing_raised do
579
+ @list.reject! { |img| img.filename =~ /7/ }
580
+ assert_instance_of(Magick::ImageList, @list)
581
+ assert_equal(8, @list.length)
582
+ assert_same(@list[-1], @list.cur_image)
583
+ end
584
+
585
+ # returns nil if no changes are made
586
+ assert_nil(@list.reject! { false })
587
+ end
588
+
589
+ def test_replace1
590
+ # Replace with empty list
591
+ assert_nothing_raised do
592
+ res = @list.replace([])
593
+ assert_same(res, @list)
594
+ assert_equal(0, @list.length)
595
+ assert_nil(@list.scene)
596
+ end
597
+
598
+ # Replace empty list with non-empty list
599
+ temp = Magick::ImageList.new
600
+ assert_nothing_raised do
601
+ temp.replace(@list2)
602
+ assert_equal(5, temp.length)
603
+ assert_equal(4, temp.scene)
604
+ end
605
+
606
+ # Try to replace with illegal values
607
+ assert_raise(ArgumentError) { @list.replace([1, 2, 3]) }
608
+ end
609
+
610
+ def test_replace2
611
+ # Replace with shorter list
612
+ assert_nothing_raised do
613
+ @list.scene = 7
614
+ cur = @list.cur_image
615
+ res = @list.replace(@list2)
616
+ assert_same(res, @list)
617
+ assert_equal(5, @list.length)
618
+ assert_equal(2, @list.scene)
619
+ assert_same(cur, @list.cur_image)
620
+ end
621
+ end
622
+
623
+ def test_replace3
624
+ # Replace with longer list
625
+ assert_nothing_raised do
626
+ @list2.scene = 2
627
+ cur = @list2.cur_image
628
+ res = @list2.replace(@list)
629
+ assert_same(res, @list2)
630
+ assert_equal(10, @list2.length)
631
+ assert_equal(7, @list2.scene)
632
+ assert_same(cur, @list2.cur_image)
633
+ end
634
+ end
635
+
636
+ def test_reverse
637
+ list = nil
638
+ cur = @list.cur_image
639
+ assert_nothing_raised { list = @list.reverse }
640
+ assert_equal(list.length, @list.length)
641
+ assert_same(cur, @list.cur_image)
642
+ end
643
+
644
+ def test_reverse!
645
+ list = @list
646
+ cur = @list.cur_image
647
+ assert_nothing_raised { @list.reverse! }
648
+ assert_same(list, @list)
649
+ assert_same(cur, @list.cur_image)
650
+ end
651
+
652
+ # Just validate its existence
653
+ def test_reverse_each
654
+ assert_nothing_raised do
655
+ @list.reverse_each { |img| assert_instance_of(Magick::Image, img) }
656
+ end
657
+ end
658
+
659
+ def test_rindex
660
+ img = @list.last
661
+ n = nil
662
+ assert_nothing_raised { n = @list.rindex(img) }
663
+ assert_equal(9, n)
664
+ end
665
+
666
+ def test_select
667
+ assert_nothing_raised do
668
+ res = @list.select { |img| img.filename =~ /Button_2/ }
669
+ assert_instance_of(Magick::ImageList, res)
670
+ assert_equal(1, res.length)
671
+ assert_same(res[0], @list[2])
672
+ end
673
+ end
674
+
675
+ def test_shift
676
+ assert_nothing_raised do
677
+ @list.scene = 0
678
+ res = @list[0]
679
+ img = @list.shift
680
+ assert_same(res, img)
681
+ assert_equal(8, @list.scene)
682
+ end
683
+ res = @list[0]
684
+ img = @list.shift
685
+ assert_same(res, img)
686
+ assert_equal(7, @list.scene)
687
+ end
688
+
689
+ def test_slice
690
+ assert_nothing_raised { @list.slice(0) }
691
+ assert_nothing_raised { @list.slice(-1) }
692
+ assert_nothing_raised { @list.slice(0,1) }
693
+ assert_nothing_raised { @list.slice(0..2) }
694
+ assert_nothing_raised { @list.slice(20) }
695
+ end
696
+
697
+ def test_slice!
698
+ @list.scene = 7
699
+ assert_nothing_raised do
700
+ img0 = @list[0]
701
+ img = @list.slice!(0)
702
+ assert_same(img0, img)
703
+ assert_equal(9, @list.length)
704
+ assert_equal(6, @list.scene)
705
+ end
706
+ cur = @list.cur_image
707
+ img = @list.slice!(6)
708
+ assert_same(cur, img)
709
+ assert_equal(8, @list.length)
710
+ assert_equal(7, @list.scene)
711
+ assert_nothing_raised { @list.slice!(-1) }
712
+ assert_nothing_raised { @list.slice!(0,1) }
713
+ assert_nothing_raised { @list.slice!(0..2) }
714
+ assert_nothing_raised { @list.slice!(20) }
715
+ end
716
+
717
+ # simply ensure existence
718
+ def test_sort
719
+ assert_nothing_raised { @list.sort }
720
+ assert_nothing_raised { @list.sort! }
721
+ end
722
+
723
+ def test_to_a
724
+ a = nil
725
+ assert_nothing_raised { a = @list.to_a }
726
+ assert_instance_of(Array, a)
727
+ assert_equal(10, a.length)
728
+ end
729
+
730
+ def test_uniq
731
+ assert_nothing_raised { @list.uniq }
732
+ assert_instance_of(Magick::ImageList, @list.uniq)
733
+ @list[1] = @list[0]
734
+ @list.scene = 7
735
+ list = @list.uniq
736
+ assert_equal(9, list.length)
737
+ assert_equal(6, list.scene)
738
+ assert_equal(7, @list.scene)
739
+ @list[6] = @list[7]
740
+ list = @list.uniq
741
+ assert_equal(8, list.length)
742
+ assert_equal(5, list.scene)
743
+ assert_equal(7, @list.scene)
744
+ end
745
+
746
+ def test_uniq!
747
+ assert_nothing_raised do
748
+ assert_nil(@list.uniq!)
749
+ end
750
+ @list[1] = @list[0]
751
+ @list.scene = 7
752
+ cur = @list.cur_image
753
+ list = @list
754
+ @list.uniq!
755
+ assert_same(list, @list)
756
+ assert_same(cur, @list.cur_image)
757
+ assert_equal(6, @list.scene)
758
+ @list[5] = @list[6]
759
+ @list.uniq!
760
+ assert_same(cur, @list.cur_image)
761
+ assert_equal(5, @list.scene)
762
+ end
763
+
764
+ def test_unshift
765
+ img = @list[9]
766
+ @list.scene = 7
767
+ @list.unshift(img)
768
+ assert_equal(0, @list.scene)
769
+ assert_raise(ArgumentError) { @list.unshift(2) }
770
+ assert_raise(ArgumentError) { @list.unshift([1,2]) }
771
+ end
772
+
773
+ def test_values_at
774
+ ilist = nil
775
+ assert_nothing_raised { ilist = @list.values_at(1,3,5) }
776
+ assert_instance_of(Magick::ImageList, ilist)
777
+ assert_equal(3, ilist.length)
778
+ assert_equal(2, ilist.scene)
779
+ end
780
+
781
+ def test_spaceship
782
+ list2 = @list.copy
783
+ assert_equal(@list.scene, list2.scene)
784
+ assert_equal(@list, list2)
785
+ list2.scene = 0
786
+ assert_not_equal(@list, list2)
787
+ list2 = @list.copy
788
+ list2[9] = list2[0]
789
+ assert_not_equal(@list, list2)
790
+ list2 = @list.copy
791
+ list2 << @list[9]
792
+ assert_not_equal(@list, list2)
793
+
794
+ assert_raise(TypeError) { @list <=> 2 }
795
+ list = Magick::ImageList.new
796
+ list2 = Magick::ImageList.new
797
+ assert_raise(TypeError) { list2 <=> @list }
798
+ assert_raise(TypeError) { @list <=> list2 }
799
+ assert_nothing_raised(TypeError) { list <=> list2 }
800
+ end
801
+
802
+ end
803
+
804
+ if __FILE__ == $0
805
+ IMAGES_DIR = '../doc/ex/images'
806
+ FILES = Dir[IMAGES_DIR+'/Button_*.gif'].sort
807
+ Test::Unit::UI::Console::TestRunner.run(ImageList1_UT) if !RUBY_VERSION[/^1\.9|^2/]
808
+ end