rmagick 2.13.4 → 2.16.0

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 (281) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +14 -0
  3. data/.hound.yml +2 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +340 -0
  6. data/.simplecov +27 -0
  7. data/.travis.yml +29 -12
  8. data/CHANGELOG.md +915 -0
  9. data/CODE_OF_CONDUCT.md +13 -0
  10. data/CONTRIBUTING.md +31 -3
  11. data/Gemfile +3 -0
  12. data/README.textile +94 -4
  13. data/Rakefile +57 -45
  14. data/before_install_linux.sh +26 -6
  15. data/deprecated/RMagick.rb +6 -0
  16. data/doc/comtasks.html +1 -1
  17. data/doc/draw.html +7 -4
  18. data/doc/ex/InitialCoords.rb +16 -17
  19. data/doc/ex/NewCoordSys.rb +21 -23
  20. data/doc/ex/OrigCoordSys.rb +8 -10
  21. data/doc/ex/PreserveAspectRatio.rb +182 -183
  22. data/doc/ex/RotateScale.rb +27 -28
  23. data/doc/ex/Skew.rb +27 -27
  24. data/doc/ex/Use01.rb +7 -8
  25. data/doc/ex/Use02.rb +11 -12
  26. data/doc/ex/Use03.rb +7 -7
  27. data/doc/ex/ViewBox.rb +16 -18
  28. data/doc/ex/adaptive_threshold.rb +4 -5
  29. data/doc/ex/add_noise.rb +4 -5
  30. data/doc/ex/affine.rb +4 -4
  31. data/doc/ex/affine_transform.rb +4 -4
  32. data/doc/ex/arc.rb +10 -10
  33. data/doc/ex/arcpath.rb +7 -8
  34. data/doc/ex/arcs01.rb +10 -10
  35. data/doc/ex/arcs02.rb +36 -38
  36. data/doc/ex/average.rb +5 -5
  37. data/doc/ex/axes.rb +4 -4
  38. data/doc/ex/baseline_shift01.rb +11 -12
  39. data/doc/ex/bilevel_channel.rb +2 -3
  40. data/doc/ex/blur_image.rb +2 -2
  41. data/doc/ex/border.rb +2 -2
  42. data/doc/ex/bounding_box.rb +9 -11
  43. data/doc/ex/cbezier1.rb +3 -4
  44. data/doc/ex/cbezier2.rb +3 -4
  45. data/doc/ex/cbezier3.rb +3 -4
  46. data/doc/ex/cbezier4.rb +3 -4
  47. data/doc/ex/cbezier5.rb +2 -3
  48. data/doc/ex/cbezier6.rb +3 -3
  49. data/doc/ex/channel.rb +10 -11
  50. data/doc/ex/charcoal.rb +2 -2
  51. data/doc/ex/chop.rb +2 -2
  52. data/doc/ex/circle.rb +3 -3
  53. data/doc/ex/circle01.rb +6 -7
  54. data/doc/ex/clip_path.rb +12 -12
  55. data/doc/ex/coalesce.rb +32 -35
  56. data/doc/ex/color_fill_to_border.rb +6 -6
  57. data/doc/ex/color_floodfill.rb +2 -2
  58. data/doc/ex/color_histogram.rb +17 -18
  59. data/doc/ex/color_reset.rb +2 -2
  60. data/doc/ex/colorize.rb +2 -2
  61. data/doc/ex/colors.rb +30 -30
  62. data/doc/ex/compose_mask.rb +8 -9
  63. data/doc/ex/composite.rb +14 -16
  64. data/doc/ex/composite_layers.rb +15 -15
  65. data/doc/ex/composite_tiled.rb +5 -7
  66. data/doc/ex/contrast.rb +12 -12
  67. data/doc/ex/crop.rb +3 -3
  68. data/doc/ex/crop_with_gravity.rb +13 -17
  69. data/doc/ex/cubic01.rb +18 -20
  70. data/doc/ex/cubic02.rb +64 -67
  71. data/doc/ex/cycle_colormap.rb +2 -2
  72. data/doc/ex/dissolve.rb +2 -3
  73. data/doc/ex/drawcomp.rb +34 -34
  74. data/doc/ex/drop_shadow.rb +8 -8
  75. data/doc/ex/edge.rb +2 -2
  76. data/doc/ex/ellipse.rb +4 -4
  77. data/doc/ex/ellipse01.rb +10 -11
  78. data/doc/ex/emboss.rb +2 -2
  79. data/doc/ex/enhance.rb +2 -2
  80. data/doc/ex/equalize.rb +2 -2
  81. data/doc/ex/evenodd.rb +31 -32
  82. data/doc/ex/fill_pattern.rb +12 -15
  83. data/doc/ex/flatten_images.rb +13 -13
  84. data/doc/ex/flip.rb +2 -2
  85. data/doc/ex/flop.rb +2 -2
  86. data/doc/ex/font_styles.rb +21 -23
  87. data/doc/ex/fonts.rb +14 -14
  88. data/doc/ex/frame.rb +3 -3
  89. data/doc/ex/gaussian_blur.rb +2 -2
  90. data/doc/ex/get_multiline_type_metrics.rb +6 -7
  91. data/doc/ex/get_pixels.rb +13 -14
  92. data/doc/ex/get_type_metrics.rb +26 -31
  93. data/doc/ex/gradientfill.rb +12 -12
  94. data/doc/ex/grav.rb +4 -5
  95. data/doc/ex/gravity.rb +61 -60
  96. data/doc/ex/group.rb +16 -16
  97. data/doc/ex/hatchfill.rb +10 -10
  98. data/doc/ex/image.rb +29 -31
  99. data/doc/ex/implode.rb +17 -17
  100. data/doc/ex/level.rb +2 -2
  101. data/doc/ex/level_colors.rb +4 -4
  102. data/doc/ex/line.rb +4 -5
  103. data/doc/ex/line01.rb +11 -13
  104. data/doc/ex/mask.rb +7 -8
  105. data/doc/ex/matte_fill_to_border.rb +2 -3
  106. data/doc/ex/matte_floodfill.rb +2 -3
  107. data/doc/ex/matte_replace.rb +2 -3
  108. data/doc/ex/median_filter.rb +2 -2
  109. data/doc/ex/modulate.rb +2 -2
  110. data/doc/ex/mono.rb +4 -4
  111. data/doc/ex/morph.rb +7 -8
  112. data/doc/ex/mosaic.rb +15 -15
  113. data/doc/ex/motion_blur.rb +2 -2
  114. data/doc/ex/negate.rb +2 -2
  115. data/doc/ex/negate_channel.rb +2 -2
  116. data/doc/ex/nested_rvg.rb +11 -11
  117. data/doc/ex/nonzero.rb +31 -32
  118. data/doc/ex/normalize.rb +2 -2
  119. data/doc/ex/oil_paint.rb +2 -2
  120. data/doc/ex/opacity.rb +3 -3
  121. data/doc/ex/ordered_dither.rb +2 -2
  122. data/doc/ex/path.rb +4 -5
  123. data/doc/ex/pattern1.rb +10 -10
  124. data/doc/ex/pattern2.rb +7 -7
  125. data/doc/ex/polaroid.rb +13 -14
  126. data/doc/ex/polygon.rb +6 -7
  127. data/doc/ex/polygon01.rb +10 -12
  128. data/doc/ex/polyline.rb +4 -5
  129. data/doc/ex/polyline01.rb +11 -13
  130. data/doc/ex/posterize.rb +2 -2
  131. data/doc/ex/preview.rb +3 -4
  132. data/doc/ex/qbezierpath.rb +5 -5
  133. data/doc/ex/quad01.rb +23 -25
  134. data/doc/ex/quantize-m.rb +5 -5
  135. data/doc/ex/radial_blur.rb +2 -2
  136. data/doc/ex/raise.rb +2 -2
  137. data/doc/ex/random_threshold_channel.rb +2 -2
  138. data/doc/ex/rect01.rb +6 -7
  139. data/doc/ex/rect02.rb +9 -11
  140. data/doc/ex/rectangle.rb +3 -4
  141. data/doc/ex/reduce_noise.rb +2 -2
  142. data/doc/ex/remap.rb +7 -8
  143. data/doc/ex/remap_images.rb +9 -11
  144. data/doc/ex/resize_to_fill.rb +3 -5
  145. data/doc/ex/resize_to_fit.rb +3 -5
  146. data/doc/ex/roll.rb +2 -2
  147. data/doc/ex/rotate.rb +6 -7
  148. data/doc/ex/rotate_f.rb +2 -2
  149. data/doc/ex/roundrect.rb +4 -5
  150. data/doc/ex/rubyname.rb +11 -11
  151. data/doc/ex/rvg_clippath.rb +5 -7
  152. data/doc/ex/rvg_linecap.rb +25 -26
  153. data/doc/ex/rvg_linejoin.rb +25 -26
  154. data/doc/ex/rvg_opacity.rb +10 -11
  155. data/doc/ex/rvg_pattern.rb +15 -15
  156. data/doc/ex/rvg_stroke_dasharray.rb +6 -7
  157. data/doc/ex/segment.rb +2 -2
  158. data/doc/ex/sepiatone.rb +2 -3
  159. data/doc/ex/shade.rb +2 -2
  160. data/doc/ex/shadow.rb +2 -3
  161. data/doc/ex/shave.rb +2 -2
  162. data/doc/ex/shear.rb +3 -3
  163. data/doc/ex/sketch.rb +2 -3
  164. data/doc/ex/skewx.rb +4 -5
  165. data/doc/ex/skewy.rb +3 -3
  166. data/doc/ex/smile.rb +113 -113
  167. data/doc/ex/solarize.rb +2 -2
  168. data/doc/ex/sparse_color.rb +29 -30
  169. data/doc/ex/splice.rb +2 -3
  170. data/doc/ex/spread.rb +2 -2
  171. data/doc/ex/stegano.rb +34 -34
  172. data/doc/ex/stroke_dasharray.rb +4 -5
  173. data/doc/ex/stroke_fill.rb +4 -5
  174. data/doc/ex/stroke_linecap.rb +3 -3
  175. data/doc/ex/stroke_linejoin.rb +3 -3
  176. data/doc/ex/stroke_width.rb +3 -3
  177. data/doc/ex/swirl.rb +2 -2
  178. data/doc/ex/text.rb +4 -4
  179. data/doc/ex/text01.rb +7 -8
  180. data/doc/ex/text_align.rb +2 -2
  181. data/doc/ex/text_antialias.rb +9 -10
  182. data/doc/ex/text_styles.rb +11 -13
  183. data/doc/ex/text_undercolor.rb +2 -2
  184. data/doc/ex/texture_fill_to_border.rb +6 -6
  185. data/doc/ex/texture_floodfill.rb +2 -2
  186. data/doc/ex/texturefill.rb +10 -11
  187. data/doc/ex/threshold.rb +2 -2
  188. data/doc/ex/to_blob.rb +4 -5
  189. data/doc/ex/translate.rb +6 -6
  190. data/doc/ex/transparent.rb +5 -5
  191. data/doc/ex/transpose.rb +2 -2
  192. data/doc/ex/transverse.rb +2 -2
  193. data/doc/ex/tref01.rb +11 -12
  194. data/doc/ex/triangle01.rb +5 -6
  195. data/doc/ex/trim.rb +1 -2
  196. data/doc/ex/tspan01.rb +8 -9
  197. data/doc/ex/tspan02.rb +9 -11
  198. data/doc/ex/tspan03.rb +9 -11
  199. data/doc/ex/unsharp_mask.rb +2 -2
  200. data/doc/ex/viewex.rb +19 -21
  201. data/doc/ex/vignette.rb +2 -2
  202. data/doc/ex/watermark.rb +15 -16
  203. data/doc/ex/wave.rb +2 -2
  204. data/doc/ex/wet_floor.rb +17 -18
  205. data/doc/ex/writing_mode01.rb +8 -9
  206. data/doc/ex/writing_mode02.rb +8 -8
  207. data/doc/ilist.html +1 -1
  208. data/doc/usage.html +8 -8
  209. data/examples/constitute.rb +6 -6
  210. data/examples/crop_with_gravity.rb +13 -17
  211. data/examples/demo.rb +305 -305
  212. data/examples/describe.rb +27 -28
  213. data/examples/find_similar_region.rb +16 -16
  214. data/examples/histogram.rb +228 -232
  215. data/examples/identify.rb +165 -167
  216. data/examples/image_opacity.rb +4 -4
  217. data/examples/import_export.rb +10 -10
  218. data/examples/pattern_fill.rb +9 -9
  219. data/examples/rotating_text.rb +13 -14
  220. data/examples/spinner.rb +18 -19
  221. data/examples/thumbnail.rb +13 -14
  222. data/examples/vignette.rb +8 -9
  223. data/ext/RMagick/extconf.rb +489 -367
  224. data/ext/RMagick/rmagick.c +11 -4
  225. data/ext/RMagick/rmagick.h +4 -0
  226. data/ext/RMagick/rmdraw.c +49 -18
  227. data/ext/RMagick/rmenum.c +18 -7
  228. data/ext/RMagick/rmfill.c +4 -1
  229. data/ext/RMagick/rmilist.c +49 -13
  230. data/ext/RMagick/rmimage.c +196 -59
  231. data/ext/RMagick/rminfo.c +33 -10
  232. data/ext/RMagick/rmmain.c +18 -6
  233. data/ext/RMagick/rmmontage.c +12 -4
  234. data/ext/RMagick/rmpixel.c +18 -5
  235. data/ext/RMagick/rmstruct.c +108 -31
  236. data/ext/RMagick/rmutil.c +50 -26
  237. data/lib/rmagick/version.rb +4 -3
  238. data/lib/rmagick_internal.rb +1159 -1176
  239. data/lib/rvg/clippath.rb +36 -39
  240. data/lib/rvg/container.rb +115 -124
  241. data/lib/rvg/deep_equal.rb +46 -50
  242. data/lib/rvg/describable.rb +41 -47
  243. data/lib/rvg/embellishable.rb +384 -410
  244. data/lib/rvg/misc.rb +697 -714
  245. data/lib/rvg/paint.rb +42 -47
  246. data/lib/rvg/pathdata.rb +120 -125
  247. data/lib/rvg/rvg.rb +213 -213
  248. data/lib/rvg/stretchable.rb +159 -162
  249. data/lib/rvg/stylable.rb +109 -117
  250. data/lib/rvg/text.rb +9 -24
  251. data/lib/rvg/transformable.rb +120 -127
  252. data/lib/rvg/units.rb +58 -61
  253. data/rmagick.gemspec +46 -15
  254. data/spec/rmagick/ImageList1_spec.rb +24 -0
  255. data/spec/rmagick/draw_spec.rb +156 -0
  256. data/spec/rmagick/image/blue_shift_spec.rb +16 -0
  257. data/spec/rmagick/image/composite_spec.rb +140 -0
  258. data/spec/rmagick/image/constitute_spec.rb +15 -0
  259. data/spec/rmagick/image/dispatch_spec.rb +18 -0
  260. data/spec/rmagick/image/from_blob_spec.rb +14 -0
  261. data/spec/rmagick/image/ping_spec.rb +14 -0
  262. data/spec/rmagick/image/properties_spec.rb +29 -0
  263. data/spec/spec_helper.rb +4 -0
  264. data/test/Image1.rb +529 -727
  265. data/test/Image2.rb +1291 -1299
  266. data/test/Image3.rb +978 -981
  267. data/test/ImageList1.rb +7 -9
  268. data/test/ImageList2.rb +346 -350
  269. data/test/Image_attributes.rb +683 -686
  270. data/test/Import_Export.rb +25 -30
  271. data/test/Info.rb +339 -343
  272. data/test/Magick.rb +250 -253
  273. data/test/Pixel.rb +107 -110
  274. data/test/Preview.rb +48 -53
  275. data/test/test_all_basic.rb +15 -11
  276. data/test/tmpnam_test.rb +3 -3
  277. data/wercker.yml +10 -0
  278. metadata +77 -10
  279. data/ChangeLog +0 -816
  280. data/lib/RMagick.rb +0 -1
  281. data/test/Draw.rb +0 -121
data/test/Info.rb CHANGED
@@ -1,349 +1,345 @@
1
1
 
2
- #! /usr/local/bin/ruby -w
2
+ #!/usr/bin/env ruby -w
3
3
 
4
- require 'RMagick'
4
+ require 'rmagick'
5
5
  require 'test/unit'
6
- require 'test/unit/ui/console/testrunner' if !RUBY_VERSION[/^1\.9|^2/]
7
-
6
+ require 'test/unit/ui/console/testrunner' unless RUBY_VERSION[/^1\.9|^2/]
8
7
 
9
8
  class Info_UT < Test::Unit::TestCase
10
-
11
- def setup
12
- @info = Magick::Image::Info.new
13
- end
14
-
15
- def test_options
16
-
17
- # 1-argument form
18
- assert_nothing_raised { @info['fill'] }
19
- assert_nil(@info['fill'])
20
-
21
- assert_nothing_raised { @info['fill'] = 'red' }
22
- assert_equal("red", @info['fill'])
23
-
24
- assert_nothing_raised { @info['fill'] = nil }
25
- assert_nil(@info['fill'])
26
-
27
- # 2-argument form
28
- assert_nothing_raised { @info['tiff', 'bits-per-sample'] = 2 }
29
- assert_equal("2", @info['tiff', 'bits-per-sample'])
30
-
31
- # define and undefine
32
- assert_nothing_raised { @info.define('tiff', 'bits-per-sample', 4) }
33
- assert_equal("4", @info['tiff', 'bits-per-sample'])
34
-
35
- assert_nothing_raised { @info.undefine('tiff', 'bits-per-sample') }
36
- assert_nil(@info['tiff', 'bits-per-sample'])
37
- end
38
-
39
- def test_antialias
40
- assert @info.antialias
41
- assert_nothing_raised { @info.antialias = false }
42
- assert !@info.antialias
43
- end
44
-
45
- def test_attenuate
46
- assert_nothing_raised { @info.attenuate = 10 }
47
- assert_equal(10, @info.attenuate)
48
- assert_nothing_raised { @info.attenuate = 5.25 }
49
- assert_equal(5.25, @info.attenuate)
50
- assert_nothing_raised { @info.attenuate = nil }
51
- assert_equal(nil, @info.attenuate)
52
- end
53
-
54
- def test_authenticate
55
- assert_nothing_raised { @info.authenticate = "string" }
56
- assert_equal("string", @info.authenticate)
57
- end
58
-
59
- def test_background_color
60
- assert_nothing_raised { @info.background_color = "red" }
61
- red = Magick::Pixel.new(Magick::QuantumRange)
62
- assert_nothing_raised { @info.background_color = red }
63
- assert_equal("red", @info.background_color)
64
- img = Magick::Image.new(20,20) { self.background_color = "red" }
65
- assert_equal("red", img.background_color)
66
- end
67
-
68
- def test_border_color
69
- assert_nothing_raised { @info.border_color = "red" }
70
- red = Magick::Pixel.new(Magick::QuantumRange)
71
- assert_nothing_raised { @info.border_color = red }
72
- assert_equal("red", @info.border_color)
73
- img = Magick::Image.new(20,20) { self.border_color = "red" }
74
- assert_equal("red", img.border_color)
75
- end
76
-
77
- def caption
78
- assert_nothing_raised { @info.caption = "string" }
79
- assert_equal("string", @info.caption)
80
- img = Magick::Image.new(20,20) { self.caption = "string" }
81
- assert_equal("string", img.caption)
82
- end
83
-
84
- def test_channel
85
- assert_nothing_raised { @info.channel(Magick::RedChannel) }
86
- assert_nothing_raised { @info.channel(Magick::RedChannel, Magick::BlueChannel) }
87
- assert_raise(TypeError) { @info.channel(1) }
88
- assert_raise(TypeError) { @info.channel(Magick::RedChannel, 1) }
89
- end
90
-
91
- def test_colorspace
92
- Magick::ColorspaceType.values.each do |cs|
93
- assert_nothing_raised {@info.colorspace = cs}
94
- assert_equal(cs, @info.colorspace)
95
- end
96
- end
97
-
98
- def test_comment
99
- assert_nothing_raised { @info.comment = "comment" }
100
- assert_equal("comment", @info.comment)
101
- end
102
-
103
- def test_compression
104
- Magick::CompressionType.values.each do |v|
105
- assert_nothing_raised { @info.compression = v }
106
- assert_equal(v, @info.compression)
107
- end
108
- end
109
-
110
- def test_define
111
- assert_nothing_raised { @info.define("tiff", "bits-per-sample", 2) }
112
- assert_nothing_raised { @info.undefine("tiff", "bits-per-sample") }
113
- end
114
-
115
- def test_density
116
- assert_nothing_raised { @info.density = "72x72" }
117
- assert_equal("72x72", @info.density)
118
- assert_nothing_raised { @info.density = Magick::Geometry.new(72, 72) }
119
- assert_equal("72x72", @info.density)
120
- end
121
-
122
- def test_delay
123
- assert_nothing_raised { @info.delay = 60 }
124
- assert_equal(60, @info.delay)
125
- end
126
-
127
- def test_depth
128
- assert_nothing_raised { @info.depth = 8 }
129
- assert_equal(8, @info.depth)
130
- assert_nothing_raised { @info.depth = 16 }
131
- assert_equal(16, @info.depth)
132
- assert_raise(ArgumentError) { @info.depth = 32 }
133
- end
134
-
135
- def test_dispose
136
- Magick::DisposeType.values.each do |v|
137
- assert_nothing_raised { @info.dispose = v }
138
- assert_equal(v, @info.dispose)
139
- end
140
- end
141
-
142
- def test_dither
143
- assert_nothing_raised { @info.dither = true }
144
- assert_equal(true, @info.dither)
145
- assert_nothing_raised { @info.dither = false }
146
- assert_equal(false, @info.dither)
147
- end
148
-
149
- def test_extract
150
- assert_nothing_raised { @info.extract = "100x100" }
151
- assert_equal("100x100", @info.extract)
152
- assert_nothing_raised { @info.extract = Magick::Geometry.new(100, 100) }
153
- assert_equal("100x100", @info.extract)
154
- end
155
-
156
- def test_filename
157
- assert_nothing_raised { @info.filename = "string" }
158
- assert_equal("string", @info.filename)
159
- end
160
-
161
- def test_fill
162
- assert_nothing_raised { @info.fill }
163
- assert_nil(@info.fill)
164
-
165
- assert_nothing_raised { @info.fill = 'white' }
166
- assert_equal("white", @info.fill)
167
-
168
- assert_nothing_raised { @info.fill = nil }
169
- assert_nil(@info.fill)
170
-
171
- assert_raise(ArgumentError) { @info.fill = 'xxx' }
172
- end
173
-
174
- def test_font
175
- assert_nothing_raised { @info.font = "Arial" }
176
- assert_equal("Arial", @info.font)
177
- end
178
-
179
- def test_format
180
- assert_nothing_raised { @info.format = "GIF" }
181
- assert_equal("GIF", @info.format)
182
- end
183
-
184
- def test_fuzz
185
- assert_nothing_raised { @info.fuzz = 50 }
186
- assert_equal(50, @info.fuzz)
187
- assert_nothing_raised { @info.fuzz = "50%" }
188
- assert_equal(Magick::QuantumRange * 0.5, @info.fuzz)
189
- end
190
-
191
- def test_gravity
192
- Magick::GravityType.values.each do |v|
193
- assert_nothing_raised { @info.gravity = v }
194
- assert_equal(v, @info.gravity)
195
- end
196
- end
197
-
198
- def test_image_type
199
- Magick::ImageType.values.each do |v|
200
- assert_nothing_raised { @info.image_type = v }
201
- assert_equal(v, @info.image_type)
202
- end
203
- end
204
-
205
- def test_interlace
206
- Magick::InterlaceType.values.each do |v|
207
- assert_nothing_raised { @info.interlace = v }
208
- assert_equal(v, @info.interlace)
209
- end
210
- end
211
-
212
- def test_label
213
- assert_nothing_raised { @info.label = "string" }
214
- assert_equal("string", @info.label)
215
- end
216
-
217
- def test_matte_color
218
- assert_nothing_raised { @info.matte_color = "red" }
219
- red = Magick::Pixel.new(Magick::QuantumRange)
220
- assert_nothing_raised { @info.matte_color = red }
221
- assert_equal("red", @info.matte_color)
222
- img = Magick::Image.new(20,20) { self.matte_color = "red" }
223
- assert_equal("red", img.matte_color)
224
- end
225
-
226
- def test_monitor
227
- assert_nothing_raised { @info.monitor = lambda {} }
228
- monitor = Proc.new do |mth, q, s|
229
- assert_equal("resize!", mth)
230
- assert_instance_of(Fixnum, q)
231
- assert_instance_of(Fixnum, s)
232
- true
233
- end
234
- img = Magick::Image.new(2000, 2000) { self.monitor = monitor }
235
- img.resize!(20, 20)
236
- img.monitor = nil
237
- end
238
-
239
- def test_monochrome
240
- assert_nothing_raised { @info.monochrome = true }
241
- assert @info.monochrome
242
- end
243
-
244
- def test_orientation
245
- Magick::OrientationType.values.each do |v|
246
- assert_nothing_raised { @info.orientation = v }
247
- assert_equal(v, @info.orientation)
248
- end
249
- end
250
-
251
- def test_origin
252
- assert_nothing_raised { @info.origin = "+10+10" }
253
- assert_equal("+10+10", @info.origin)
254
- assert_nothing_raised { @info.origin = Magick::Geometry.new(nil, nil, 10, 10) }
255
- assert_equal("+10+10", @info.origin)
256
- end
257
-
258
- def test_page
259
- assert_nothing_raised { @info.page = "612x792>" }
260
- assert_equal("612x792>", @info.page)
261
- end
262
-
263
- def test_pointsize
264
- assert_nothing_raised { @info.pointsize = 12 }
265
- assert_equal(12, @info.pointsize)
266
- end
267
-
268
- def test_quality
269
- assert_nothing_raised { @info.quality = 75 }
270
- assert_equal(75, @info.quality)
271
- end
272
-
273
- def test_sampling_factor
274
- assert_nothing_raised { @info.sampling_factor = "2x1" }
275
- assert_equal("2x1", @info.sampling_factor)
276
- end
277
-
278
- def test_server_name
279
- assert_nothing_raised { @info.server_name = "foo" }
280
- assert_equal("foo", @info.server_name)
281
- end
282
-
283
- def test_size
284
- assert_nothing_raised { @info.size = "200x100" }
285
- assert_equal("200x100", @info.size)
286
- assert_nothing_raised { @info.size = Magick::Geometry.new(100,200) }
287
- assert_equal("100x200", @info.size)
288
- end
289
-
290
- def test_stroke
291
- assert_nothing_raised { @info.stroke }
292
- assert_nil(@info.stroke)
293
-
294
- assert_nothing_raised { @info.stroke = 'white' }
295
- assert_equal("white", @info.stroke)
296
-
297
- assert_nothing_raised { @info.stroke = nil }
298
- assert_nil(@info.stroke)
299
-
300
- assert_raise(ArgumentError) { @info.stroke = 'xxx' }
301
- end
302
-
303
- def test_stroke_width
304
- assert_nothing_raised { @info.stroke_width = 10 }
305
- assert_equal(10, @info.stroke_width)
306
- assert_nothing_raised { @info.stroke_width = 5.25 }
307
- assert_equal(5.25, @info.stroke_width)
308
- assert_nothing_raised { @info.stroke_width = nil }
309
- assert_equal(nil, @info.stroke_width)
310
- end
311
-
312
- def test_texture
313
- img = Magick::Image.read("granite:") {self.size = "20x20" }
314
- assert_nothing_raised { @info.texture = img.first }
315
- end
316
-
317
- def test_tile_offset
318
- assert_nothing_raised { @info.tile_offset = "200x100" }
319
- assert_equal("200x100", @info.tile_offset)
320
- assert_nothing_raised { @info.tile_offset = Magick::Geometry.new(100,200) }
321
- assert_equal("100x200", @info.tile_offset)
322
- end
323
-
324
- def test_undercolor
325
- assert_nothing_raised { @info.undercolor }
326
- assert_nil(@info.undercolor)
327
-
328
- assert_nothing_raised { @info.undercolor = 'white' }
329
- assert_equal("white", @info.undercolor)
330
-
331
- assert_nothing_raised { @info.undercolor = nil }
332
- assert_nil(@info.undercolor)
333
-
334
- assert_raise(ArgumentError) { @info.undercolor = 'xxx' }
335
- end
336
-
337
- def test_units
338
- Magick::ResolutionType.values.each do |v|
339
- assert_nothing_raised { @info.units = v }
340
- assert_equal(v, @info.units)
341
- end
342
- end
343
-
344
- def test_view
345
- assert_nothing_raised { @info.view = "string" }
346
- assert_equal("string", @info.view)
347
- end
348
-
9
+ def setup
10
+ @info = Magick::Image::Info.new
11
+ end
12
+
13
+ def test_options
14
+ # 1-argument form
15
+ assert_nothing_raised { @info['fill'] }
16
+ assert_nil(@info['fill'])
17
+
18
+ assert_nothing_raised { @info['fill'] = 'red' }
19
+ assert_equal('red', @info['fill'])
20
+
21
+ assert_nothing_raised { @info['fill'] = nil }
22
+ assert_nil(@info['fill'])
23
+
24
+ # 2-argument form
25
+ assert_nothing_raised { @info['tiff', 'bits-per-sample'] = 2 }
26
+ assert_equal('2', @info['tiff', 'bits-per-sample'])
27
+
28
+ # define and undefine
29
+ assert_nothing_raised { @info.define('tiff', 'bits-per-sample', 4) }
30
+ assert_equal('4', @info['tiff', 'bits-per-sample'])
31
+
32
+ assert_nothing_raised { @info.undefine('tiff', 'bits-per-sample') }
33
+ assert_nil(@info['tiff', 'bits-per-sample'])
34
+ end
35
+
36
+ def test_antialias
37
+ assert @info.antialias
38
+ assert_nothing_raised { @info.antialias = false }
39
+ assert !@info.antialias
40
+ end
41
+
42
+ def test_attenuate
43
+ assert_nothing_raised { @info.attenuate = 10 }
44
+ assert_equal(10, @info.attenuate)
45
+ assert_nothing_raised { @info.attenuate = 5.25 }
46
+ assert_equal(5.25, @info.attenuate)
47
+ assert_nothing_raised { @info.attenuate = nil }
48
+ assert_equal(nil, @info.attenuate)
49
+ end
50
+
51
+ def test_authenticate
52
+ assert_nothing_raised { @info.authenticate = 'string' }
53
+ assert_equal('string', @info.authenticate)
54
+ end
55
+
56
+ def test_background_color
57
+ assert_nothing_raised { @info.background_color = 'red' }
58
+ red = Magick::Pixel.new(Magick::QuantumRange)
59
+ assert_nothing_raised { @info.background_color = red }
60
+ assert_equal('red', @info.background_color)
61
+ img = Magick::Image.new(20,20) { self.background_color = 'red' }
62
+ assert_equal('red', img.background_color)
63
+ end
64
+
65
+ def test_border_color
66
+ assert_nothing_raised { @info.border_color = 'red' }
67
+ red = Magick::Pixel.new(Magick::QuantumRange)
68
+ assert_nothing_raised { @info.border_color = red }
69
+ assert_equal('red', @info.border_color)
70
+ img = Magick::Image.new(20,20) { self.border_color = 'red' }
71
+ assert_equal('red', img.border_color)
72
+ end
73
+
74
+ def caption
75
+ assert_nothing_raised { @info.caption = 'string' }
76
+ assert_equal('string', @info.caption)
77
+ img = Magick::Image.new(20,20) { self.caption = 'string' }
78
+ assert_equal('string', img.caption)
79
+ end
80
+
81
+ def test_channel
82
+ assert_nothing_raised { @info.channel(Magick::RedChannel) }
83
+ assert_nothing_raised { @info.channel(Magick::RedChannel, Magick::BlueChannel) }
84
+ assert_raise(TypeError) { @info.channel(1) }
85
+ assert_raise(TypeError) { @info.channel(Magick::RedChannel, 1) }
86
+ end
87
+
88
+ def test_colorspace
89
+ Magick::ColorspaceType.values.each do |cs|
90
+ assert_nothing_raised {@info.colorspace = cs}
91
+ assert_equal(cs, @info.colorspace)
92
+ end
93
+ end
94
+
95
+ def test_comment
96
+ assert_nothing_raised { @info.comment = 'comment' }
97
+ assert_equal('comment', @info.comment)
98
+ end
99
+
100
+ def test_compression
101
+ Magick::CompressionType.values.each do |v|
102
+ assert_nothing_raised { @info.compression = v }
103
+ assert_equal(v, @info.compression)
104
+ end
105
+ end
106
+
107
+ def test_define
108
+ assert_nothing_raised { @info.define('tiff', 'bits-per-sample', 2) }
109
+ assert_nothing_raised { @info.undefine('tiff', 'bits-per-sample') }
110
+ end
111
+
112
+ def test_density
113
+ assert_nothing_raised { @info.density = '72x72' }
114
+ assert_equal('72x72', @info.density)
115
+ assert_nothing_raised { @info.density = Magick::Geometry.new(72, 72) }
116
+ assert_equal('72x72', @info.density)
117
+ end
118
+
119
+ def test_delay
120
+ assert_nothing_raised { @info.delay = 60 }
121
+ assert_equal(60, @info.delay)
122
+ end
123
+
124
+ def test_depth
125
+ assert_nothing_raised { @info.depth = 8 }
126
+ assert_equal(8, @info.depth)
127
+ assert_nothing_raised { @info.depth = 16 }
128
+ assert_equal(16, @info.depth)
129
+ assert_raise(ArgumentError) { @info.depth = 32 }
130
+ end
131
+
132
+ def test_dispose
133
+ Magick::DisposeType.values.each do |v|
134
+ assert_nothing_raised { @info.dispose = v }
135
+ assert_equal(v, @info.dispose)
136
+ end
137
+ end
138
+
139
+ def test_dither
140
+ assert_nothing_raised { @info.dither = true }
141
+ assert_equal(true, @info.dither)
142
+ assert_nothing_raised { @info.dither = false }
143
+ assert_equal(false, @info.dither)
144
+ end
145
+
146
+ def test_extract
147
+ assert_nothing_raised { @info.extract = '100x100' }
148
+ assert_equal('100x100', @info.extract)
149
+ assert_nothing_raised { @info.extract = Magick::Geometry.new(100, 100) }
150
+ assert_equal('100x100', @info.extract)
151
+ end
152
+
153
+ def test_filename
154
+ assert_nothing_raised { @info.filename = 'string' }
155
+ assert_equal('string', @info.filename)
156
+ end
157
+
158
+ def test_fill
159
+ assert_nothing_raised { @info.fill }
160
+ assert_nil(@info.fill)
161
+
162
+ assert_nothing_raised { @info.fill = 'white' }
163
+ assert_equal('white', @info.fill)
164
+
165
+ assert_nothing_raised { @info.fill = nil }
166
+ assert_nil(@info.fill)
167
+
168
+ assert_raise(ArgumentError) { @info.fill = 'xxx' }
169
+ end
170
+
171
+ def test_font
172
+ assert_nothing_raised { @info.font = 'Arial' }
173
+ assert_equal('Arial', @info.font)
174
+ end
175
+
176
+ def test_format
177
+ assert_nothing_raised { @info.format = 'GIF' }
178
+ assert_equal('GIF', @info.format)
179
+ end
180
+
181
+ def test_fuzz
182
+ assert_nothing_raised { @info.fuzz = 50 }
183
+ assert_equal(50, @info.fuzz)
184
+ assert_nothing_raised { @info.fuzz = '50%' }
185
+ assert_equal(Magick::QuantumRange * 0.5, @info.fuzz)
186
+ end
187
+
188
+ def test_gravity
189
+ Magick::GravityType.values.each do |v|
190
+ assert_nothing_raised { @info.gravity = v }
191
+ assert_equal(v, @info.gravity)
192
+ end
193
+ end
194
+
195
+ def test_image_type
196
+ Magick::ImageType.values.each do |v|
197
+ assert_nothing_raised { @info.image_type = v }
198
+ assert_equal(v, @info.image_type)
199
+ end
200
+ end
201
+
202
+ def test_interlace
203
+ Magick::InterlaceType.values.each do |v|
204
+ assert_nothing_raised { @info.interlace = v }
205
+ assert_equal(v, @info.interlace)
206
+ end
207
+ end
208
+
209
+ def test_label
210
+ assert_nothing_raised { @info.label = 'string' }
211
+ assert_equal('string', @info.label)
212
+ end
213
+
214
+ def test_matte_color
215
+ assert_nothing_raised { @info.matte_color = 'red' }
216
+ red = Magick::Pixel.new(Magick::QuantumRange)
217
+ assert_nothing_raised { @info.matte_color = red }
218
+ assert_equal('red', @info.matte_color)
219
+ img = Magick::Image.new(20,20) { self.matte_color = 'red' }
220
+ assert_equal('red', img.matte_color)
221
+ end
222
+
223
+ def test_monitor
224
+ assert_nothing_raised { @info.monitor = lambda {} }
225
+ monitor = proc do |mth, q, s|
226
+ assert_equal('resize!', mth)
227
+ assert_instance_of(Fixnum, q)
228
+ assert_instance_of(Fixnum, s)
229
+ true
230
+ end
231
+ img = Magick::Image.new(2000, 2000) { self.monitor = monitor }
232
+ img.resize!(20, 20)
233
+ img.monitor = nil
234
+ end
235
+
236
+ def test_monochrome
237
+ assert_nothing_raised { @info.monochrome = true }
238
+ assert @info.monochrome
239
+ end
240
+
241
+ def test_orientation
242
+ Magick::OrientationType.values.each do |v|
243
+ assert_nothing_raised { @info.orientation = v }
244
+ assert_equal(v, @info.orientation)
245
+ end
246
+ end
247
+
248
+ def test_origin
249
+ assert_nothing_raised { @info.origin = '+10+10' }
250
+ assert_equal('+10+10', @info.origin)
251
+ assert_nothing_raised { @info.origin = Magick::Geometry.new(nil, nil, 10, 10) }
252
+ assert_equal('+10+10', @info.origin)
253
+ end
254
+
255
+ def test_page
256
+ assert_nothing_raised { @info.page = '612x792>' }
257
+ assert_equal('612x792>', @info.page)
258
+ end
259
+
260
+ def test_pointsize
261
+ assert_nothing_raised { @info.pointsize = 12 }
262
+ assert_equal(12, @info.pointsize)
263
+ end
264
+
265
+ def test_quality
266
+ assert_nothing_raised { @info.quality = 75 }
267
+ assert_equal(75, @info.quality)
268
+ end
269
+
270
+ def test_sampling_factor
271
+ assert_nothing_raised { @info.sampling_factor = '2x1' }
272
+ assert_equal('2x1', @info.sampling_factor)
273
+ end
274
+
275
+ def test_server_name
276
+ assert_nothing_raised { @info.server_name = 'foo' }
277
+ assert_equal('foo', @info.server_name)
278
+ end
279
+
280
+ def test_size
281
+ assert_nothing_raised { @info.size = '200x100' }
282
+ assert_equal('200x100', @info.size)
283
+ assert_nothing_raised { @info.size = Magick::Geometry.new(100,200) }
284
+ assert_equal('100x200', @info.size)
285
+ end
286
+
287
+ def test_stroke
288
+ assert_nothing_raised { @info.stroke }
289
+ assert_nil(@info.stroke)
290
+
291
+ assert_nothing_raised { @info.stroke = 'white' }
292
+ assert_equal('white', @info.stroke)
293
+
294
+ assert_nothing_raised { @info.stroke = nil }
295
+ assert_nil(@info.stroke)
296
+
297
+ assert_raise(ArgumentError) { @info.stroke = 'xxx' }
298
+ end
299
+
300
+ def test_stroke_width
301
+ assert_nothing_raised { @info.stroke_width = 10 }
302
+ assert_equal(10, @info.stroke_width)
303
+ assert_nothing_raised { @info.stroke_width = 5.25 }
304
+ assert_equal(5.25, @info.stroke_width)
305
+ assert_nothing_raised { @info.stroke_width = nil }
306
+ assert_equal(nil, @info.stroke_width)
307
+ end
308
+
309
+ def test_texture
310
+ img = Magick::Image.read('granite:') {self.size = '20x20' }
311
+ assert_nothing_raised { @info.texture = img.first }
312
+ end
313
+
314
+ def test_tile_offset
315
+ assert_nothing_raised { @info.tile_offset = '200x100' }
316
+ assert_equal('200x100', @info.tile_offset)
317
+ assert_nothing_raised { @info.tile_offset = Magick::Geometry.new(100,200) }
318
+ assert_equal('100x200', @info.tile_offset)
319
+ end
320
+
321
+ def test_undercolor
322
+ assert_nothing_raised { @info.undercolor }
323
+ assert_nil(@info.undercolor)
324
+
325
+ assert_nothing_raised { @info.undercolor = 'white' }
326
+ assert_equal('white', @info.undercolor)
327
+
328
+ assert_nothing_raised { @info.undercolor = nil }
329
+ assert_nil(@info.undercolor)
330
+
331
+ assert_raise(ArgumentError) { @info.undercolor = 'xxx' }
332
+ end
333
+
334
+ def test_units
335
+ Magick::ResolutionType.values.each do |v|
336
+ assert_nothing_raised { @info.units = v }
337
+ assert_equal(v, @info.units)
338
+ end
339
+ end
340
+
341
+ def test_view
342
+ assert_nothing_raised { @info.view = 'string' }
343
+ assert_equal('string', @info.view)
344
+ end
349
345
  end