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