rmagick 3.1.0 → 3.2.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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/.appveyor.yml +4 -4
  3. data/.circleci/config.yml +1 -1
  4. data/.gitignore +1 -0
  5. data/.rubocop_todo.yml +6 -0
  6. data/.travis.yml +26 -8
  7. data/CHANGELOG.md +104 -0
  8. data/before_install_linux.sh +19 -10
  9. data/benchmarks/memory/README.md +50 -0
  10. data/benchmarks/memory/image_new.rb +8 -0
  11. data/benchmarks/memory/rmagick.gnuplot +16 -0
  12. data/doc/ex/coalesce.rb +2 -2
  13. data/doc/ex/drawcomp.rb +3 -3
  14. data/doc/ex/get_pixels.rb +1 -1
  15. data/doc/ex/images/Coffee.png +0 -0
  16. data/doc/ex/images/No.png +0 -0
  17. data/doc/ex/images/Snake.png +0 -0
  18. data/doc/ex/implode.rb +2 -2
  19. data/doc/ex/mask.rb +1 -1
  20. data/doc/ex/matte_fill_to_border.rb +1 -1
  21. data/doc/ex/matte_floodfill.rb +1 -1
  22. data/doc/ex/matte_replace.rb +1 -1
  23. data/doc/ex/stegano.rb +1 -1
  24. data/examples/constitute.rb +1 -1
  25. data/examples/crop_with_gravity.rb +1 -1
  26. data/examples/demo.rb +4 -4
  27. data/examples/find_similar_region.rb +1 -1
  28. data/examples/histogram.rb +3 -3
  29. data/examples/identify.rb +46 -46
  30. data/examples/image_opacity.rb +2 -2
  31. data/examples/vignette.rb +3 -3
  32. data/ext/RMagick/extconf.rb +19 -15
  33. data/ext/RMagick/rmagick.c +1 -2
  34. data/ext/RMagick/rmagick.h +59 -30
  35. data/ext/RMagick/rmdraw.c +62 -274
  36. data/ext/RMagick/rmenum.c +121 -665
  37. data/ext/RMagick/rmfill.c +7 -7
  38. data/ext/RMagick/rmilist.c +91 -7
  39. data/ext/RMagick/rmimage.c +568 -379
  40. data/ext/RMagick/rminfo.c +152 -110
  41. data/ext/RMagick/rmkinfo.c +17 -1
  42. data/ext/RMagick/rmmain.c +75 -74
  43. data/ext/RMagick/rmmontage.c +33 -33
  44. data/ext/RMagick/rmpixel.c +75 -14
  45. data/ext/RMagick/rmstruct.c +5 -5
  46. data/ext/RMagick/rmutil.c +3 -13
  47. data/lib/obsolete.rb +66 -0
  48. data/lib/rmagick/version.rb +1 -1
  49. data/lib/rmagick_internal.rb +54 -41
  50. data/spec/rmagick/image/composite_spec.rb +5 -76
  51. data/spec/rmagick/image/properties_spec.rb +1 -1
  52. data/test/Draw.rb +52 -115
  53. data/test/Enum.rb +153 -1
  54. data/test/Fill.rb +1 -1
  55. data/test/Image1.rb +97 -43
  56. data/test/Image2.rb +140 -36
  57. data/test/Image3.rb +110 -120
  58. data/test/ImageList1.rb +46 -11
  59. data/test/ImageList2.rb +11 -21
  60. data/test/Image_attributes.rb +81 -127
  61. data/test/Import_Export.rb +2 -2
  62. data/test/Info.rb +5 -1
  63. data/test/KernelInfo.rb +67 -0
  64. data/test/Magick.rb +17 -35
  65. data/test/Pixel.rb +193 -24
  66. data/test/PolaroidOptions.rb +1 -1
  67. data/test/Preview.rb +3 -35
  68. data/test/Struct.rb +45 -0
  69. data/test/appearance/Montage.rb +26 -0
  70. data/test/appearance/appearance_assertion.rb +13 -0
  71. data/test/appearance/expected/montage_border_color.jpg +0 -0
  72. data/test/lib/Obsolete.rb +30 -0
  73. data/test/lib/internal/Draw.rb +823 -0
  74. data/test/lib/internal/Geometry.rb +98 -0
  75. data/test/lib/internal/Magick.rb +40 -0
  76. data/test/test_all_basic.rb +16 -17
  77. metadata +27 -5
  78. data/doc/ex/images/Coffee.wmf +0 -0
  79. data/doc/ex/images/No.wmf +0 -0
  80. data/doc/ex/images/Snake.wmf +0 -0
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'rmagick'
4
4
  require 'test/unit'
5
- require 'test/unit/ui/console/testrunner' unless RUBY_VERSION[/^1\.9|^2/]
5
+ require 'test/unit/ui/console/testrunner'
6
6
 
7
7
  module Magick
8
8
  def self._tmpnam_
@@ -10,7 +10,7 @@ module Magick
10
10
  end
11
11
  end
12
12
 
13
- class Magick::AlphaChannelType
13
+ class Magick::AlphaChannelOption
14
14
  def self.enumerators
15
15
  @@enumerators
16
16
  end
@@ -36,7 +36,7 @@ class MagickUT < Test::Unit::TestCase
36
36
  res.each do |c|
37
37
  assert_instance_of(Magick::Color, c)
38
38
  assert_instance_of(String, c.name)
39
- assert_instance_of(Magick::ComplianceType, c.compliance)
39
+ assert_instance_of(Magick::ComplianceType, c.compliance) unless c.compliance.nil?
40
40
  assert_instance_of(Magick::Pixel, c.color)
41
41
  end
42
42
  Magick.colors { |c| assert_instance_of(Magick::Color, c) }
@@ -47,7 +47,7 @@ class MagickUT < Test::Unit::TestCase
47
47
  def test_enumerators
48
48
  ary = nil
49
49
  assert_nothing_raised do
50
- ary = Magick::AlphaChannelType.enumerators
50
+ ary = Magick::AlphaChannelOption.enumerators
51
51
  end
52
52
  assert_instance_of(Array, ary)
53
53
 
@@ -79,8 +79,8 @@ class MagickUT < Test::Unit::TestCase
79
79
  assert_instance_of(String, f.name)
80
80
  assert_instance_of(String, f.description) unless f.description.nil?
81
81
  assert_instance_of(String, f.family)
82
- assert_instance_of(Magick::StyleType, f.style)
83
- assert_instance_of(Magick::StretchType, f.stretch)
82
+ assert_instance_of(Magick::StyleType, f.style) unless f.style.nil?
83
+ assert_instance_of(Magick::StretchType, f.stretch) unless f.stretch.nil?
84
84
  assert_kind_of(Integer, f.weight)
85
85
  assert_instance_of(String, f.encoding) unless f.encoding.nil?
86
86
  assert_instance_of(String, f.foundry) unless f.foundry.nil?
@@ -89,20 +89,6 @@ class MagickUT < Test::Unit::TestCase
89
89
  Magick.fonts { |f| assert_instance_of(Magick::Font, f) }
90
90
  end
91
91
 
92
- def test_formats
93
- res = nil
94
- assert_nothing_raised { res = Magick.formats }
95
- assert_instance_of(Hash, res)
96
- res.each do |f, v|
97
- assert_instance_of(String, f)
98
- assert_instance_of(String, v)
99
- end
100
- Magick.formats.each do |f, v|
101
- assert_not_nil(f)
102
- assert_not_nil(v)
103
- end
104
- end
105
-
106
92
  def test_geometry
107
93
  g = nil
108
94
  gs = nil
@@ -257,6 +243,14 @@ class MagickUT < Test::Unit::TestCase
257
243
  assert_raise(ArgumentError) { Magick::Geometry.new(40, 20, 10, Magick::AreaGeometry) }
258
244
  end
259
245
 
246
+ def test_init_formats
247
+ assert_instance_of(Hash, Magick.init_formats)
248
+ end
249
+
250
+ def test_opaque_alpha
251
+ assert_equal(Magick::QuantumRange, Magick::OpaqueAlpha)
252
+ end
253
+
260
254
  def test_set_log_event_mask
261
255
  assert_nothing_raised { Magick.set_log_event_mask('Module,Coder') }
262
256
  end
@@ -309,21 +303,9 @@ class MagickUT < Test::Unit::TestCase
309
303
  assert_raise(ArgumentError) { Magick.limit_resource }
310
304
  end
311
305
 
312
- def test_trace_proc
313
- Magick.trace_proc = proc do |which, description, id, method|
314
- assert(which == :c)
315
- assert_instance_of(String, description)
316
- assert_instance_of(String, id)
317
- assert_equal(:initialize, method)
318
- end
319
- begin
320
- Magick::Image.new(20, 20)
321
- ensure
322
- Magick.trace_proc = nil
323
- end
306
+ def test_transparent_alpha
307
+ assert_equal(0, Magick::TransparentAlpha)
324
308
  end
325
309
  end
326
310
 
327
- if $PROGRAM_NAME == __FILE__
328
- Test::Unit::UI::Console::TestRunner.run(MagickUT) unless RUBY_VERSION[/^1\.9|^2/]
329
- end
311
+ Test::Unit::UI::Console::TestRunner.run(MagickUT) if $PROGRAM_NAME == __FILE__
@@ -2,13 +2,118 @@
2
2
 
3
3
  require 'rmagick'
4
4
  require 'test/unit'
5
- require 'test/unit/ui/console/testrunner' unless RUBY_VERSION[/^1\.9|^2/]
5
+ require 'test/unit/ui/console/testrunner'
6
6
 
7
7
  class PixelUT < Test::Unit::TestCase
8
8
  def setup
9
9
  @pixel = Magick::Pixel.from_color('brown')
10
10
  end
11
11
 
12
+ def test_red
13
+ assert_nothing_raised { @pixel.red = 123 }
14
+ assert_equal(123, @pixel.red)
15
+ assert_nothing_raised { @pixel.red = 255.25 }
16
+ assert_equal(255, @pixel.red)
17
+ assert_raise(TypeError) { @pixel.red = 'x' }
18
+ end
19
+
20
+ def test_green
21
+ assert_nothing_raised { @pixel.green = 123 }
22
+ assert_equal(123, @pixel.green)
23
+ assert_nothing_raised { @pixel.green = 255.25 }
24
+ assert_equal(255, @pixel.green)
25
+ assert_raise(TypeError) { @pixel.green = 'x' }
26
+ end
27
+
28
+ def test_blue
29
+ assert_nothing_raised { @pixel.blue = 123 }
30
+ assert_equal(123, @pixel.blue)
31
+ assert_nothing_raised { @pixel.blue = 255.25 }
32
+ assert_equal(255, @pixel.blue)
33
+ assert_raise(TypeError) { @pixel.blue = 'x' }
34
+ end
35
+
36
+ def test_alpha
37
+ assert_nothing_raised { @pixel.alpha = 123 }
38
+ assert_equal(123, @pixel.alpha)
39
+ assert_nothing_raised { @pixel.alpha = 255.25 }
40
+ assert_equal(255, @pixel.alpha)
41
+ assert_raise(TypeError) { @pixel.alpha = 'x' }
42
+ end
43
+
44
+ def test_opacity
45
+ assert_nothing_raised { @pixel.opacity = 123 }
46
+ assert_equal(123, @pixel.opacity)
47
+ assert_nothing_raised { @pixel.opacity = 255.25 }
48
+ assert_equal(255, @pixel.opacity)
49
+ assert_raise(TypeError) { @pixel.opacity = 'x' }
50
+ end
51
+
52
+ def test_cyan
53
+ assert_nothing_raised { @pixel.cyan = 123 }
54
+ assert_equal(123, @pixel.cyan)
55
+ assert_nothing_raised { @pixel.cyan = 255.25 }
56
+ assert_equal(255, @pixel.cyan)
57
+ assert_raise(TypeError) { @pixel.cyan = 'x' }
58
+ end
59
+
60
+ def test_magenta
61
+ assert_nothing_raised { @pixel.magenta = 123 }
62
+ assert_equal(123, @pixel.magenta)
63
+ assert_nothing_raised { @pixel.magenta = 255.25 }
64
+ assert_equal(255, @pixel.magenta)
65
+ assert_raise(TypeError) { @pixel.magenta = 'x' }
66
+ end
67
+
68
+ def test_yellow
69
+ assert_nothing_raised { @pixel.yellow = 123 }
70
+ assert_equal(123, @pixel.yellow)
71
+ assert_nothing_raised { @pixel.yellow = 255.25 }
72
+ assert_equal(255, @pixel.yellow)
73
+ assert_raise(TypeError) { @pixel.yellow = 'x' }
74
+ end
75
+
76
+ def test_black
77
+ assert_nothing_raised { @pixel.black = 123 }
78
+ assert_equal(123, @pixel.black)
79
+ assert_nothing_raised { @pixel.black = 255.25 }
80
+ assert_equal(255, @pixel.black)
81
+ assert_raise(TypeError) { @pixel.black = 'x' }
82
+ end
83
+
84
+ def test_case_eq
85
+ pixel = Magick::Pixel.from_color('brown')
86
+ assert_true(@pixel === pixel)
87
+ assert_false(@pixel === 'red')
88
+
89
+ pixel = Magick::Pixel.from_color('red')
90
+ assert_false(@pixel === pixel)
91
+ end
92
+
93
+ def test_clone
94
+ pixel = @pixel.clone
95
+ assert_true(@pixel === pixel)
96
+ assert_not_equal(@pixel.object_id, pixel.object_id)
97
+
98
+ pixel = @pixel.taint.clone
99
+ assert_true(pixel.tainted?)
100
+
101
+ pixel = @pixel.freeze.clone
102
+ assert_true(pixel.frozen?)
103
+ end
104
+
105
+ def test_dup
106
+ pixel = @pixel.dup
107
+ assert_true(@pixel === pixel)
108
+ assert_not_equal(@pixel.object_id, pixel.object_id)
109
+
110
+ pixel = @pixel.taint.dup
111
+ assert_true(pixel.tainted?)
112
+
113
+ pixel = @pixel.freeze.dup
114
+ assert_false(pixel.frozen?)
115
+ end
116
+
12
117
  def test_hash
13
118
  hash = nil
14
119
  assert_nothing_raised { hash = @pixel.hash }
@@ -46,39 +151,38 @@ class PixelUT < Test::Unit::TestCase
46
151
  assert_nothing_raised { red.fcmp(blue, 10, Magick::RGBColorspace) }
47
152
  assert_raises(TypeError) { red.fcmp(blue, 'x') }
48
153
  assert_raises(TypeError) { red.fcmp(blue, 10, 'x') }
154
+ assert_raises(ArgumentError) { red.fcmp }
155
+ assert_raises(ArgumentError) { red.fcmp(blue, 10, 'x', 'y') }
49
156
  end
50
157
 
51
158
  def test_from_hsla
52
159
  assert_nothing_raised { Magick::Pixel.from_hsla(127, 50, 50) }
53
160
  assert_nothing_raised { Magick::Pixel.from_hsla(127, 50, 50, 0) }
54
- assert_nothing_raised { Magick::Pixel.from_hsla(127, '50%', 50, 0) }
55
- assert_nothing_raised { Magick::Pixel.from_hsla('10%', '50%', 50, 0) }
161
+ assert_nothing_raised { Magick::Pixel.from_hsla('99%', '100%', '100%', '100%') }
162
+ assert_nothing_raised { Magick::Pixel.from_hsla(0, 0, 0, 0) }
163
+ assert_nothing_raised { Magick::Pixel.from_hsla(359, 255, 255, 1.0) }
56
164
  assert_raise(TypeError) { Magick::Pixel.from_hsla([], 50, 50, 0) }
57
165
  assert_raise(TypeError) { Magick::Pixel.from_hsla(127, [], 50, 0) }
58
166
  assert_raise(TypeError) { Magick::Pixel.from_hsla(127, 50, [], 0) }
59
- assert_raise(TypeError) { Magick::Pixel.from_hsla(127, 50, 50, []) }
167
+ assert_raise(ArgumentError) { Magick::Pixel.from_hsla }
168
+ assert_raise(ArgumentError) { Magick::Pixel.from_hsla(127, 50, 50, 50, 50) }
169
+ assert_raise(ArgumentError) { Magick::Pixel.from_hsla(-0.01, 0, 0) }
170
+ assert_raise(ArgumentError) { Magick::Pixel.from_hsla(0, -0.01, 0) }
171
+ assert_raise(ArgumentError) { Magick::Pixel.from_hsla(0, 0, -0.01) }
172
+ assert_raise(ArgumentError) { Magick::Pixel.from_hsla(0, 0, 0, -0.01) }
173
+ assert_raise(RangeError) { Magick::Pixel.from_hsla(0, 0, 0, 1.01) }
174
+ assert_raise(RangeError) { Magick::Pixel.from_hsla(360, 0, 0) }
175
+ assert_raise(RangeError) { Magick::Pixel.from_hsla(0, 256, 0) }
176
+ assert_raise(RangeError) { Magick::Pixel.from_hsla(0, 0, 256) }
60
177
  assert_nothing_raised { @pixel.to_hsla }
61
178
 
62
- 18.times do |h|
63
- 25.times do |s|
64
- 25.times do |l|
65
- 5.times do |a|
66
- args = [20 * h, s + 25, l + 25, a / 5.0]
67
- px = Magick::Pixel.from_hsla(*args)
68
- hsla = px.to_hsla
69
- # puts "[#{args.join(', ')}] = [#{hsla.join(', ')}]"
70
- # Handle cases where the result is very near 360
71
- # hsla[0] = ((hsla[0] + 0.005) % 360.0) - 0.005
72
- # hsla[1] = ((hsla[1] + 0.005) % 360.0) - 0.005
73
- # hsla[2] = ((hsla[2] + 0.005) % 360.0) - 0.005
74
- assert_in_delta(args[0], hsla[0], 0.25, "expected #{args.inspect} got #{hsla.inspect}")
75
- assert_in_delta(args[1], hsla[1], 0.25, "expected #{args.inspect} got #{hsla.inspect}")
76
- assert_in_delta(args[2], hsla[2], 0.25, "expected #{args.inspect} got #{hsla.inspect}")
77
- assert_in_delta(args[3], hsla[3], 0.005, "expected #{args.inspect} got #{hsla.inspect}")
78
- end
79
- end
80
- end
81
- end
179
+ args = [200, 125.125, 250.5, 0.6]
180
+ px = Magick::Pixel.from_hsla(*args)
181
+ hsla = px.to_hsla
182
+ assert_in_delta(args[0], hsla[0], 0.25, "expected #{args.inspect} got #{hsla.inspect}")
183
+ assert_in_delta(args[1], hsla[1], 0.25, "expected #{args.inspect} got #{hsla.inspect}")
184
+ assert_in_delta(args[2], hsla[2], 0.25, "expected #{args.inspect} got #{hsla.inspect}")
185
+ assert_in_delta(args[3], hsla[3], 0.005, "expected #{args.inspect} got #{hsla.inspect}")
82
186
 
83
187
  # test percentages
84
188
  args = ['20%', '20%', '20%', '20%']
@@ -94,6 +198,67 @@ class PixelUT < Test::Unit::TestCase
94
198
  assert_in_delta(hsla[3], hsla2[3], 0.005, "#{hsla.inspect} != #{hsla2.inspect} with args: #{args.inspect} and #{args2.inspect}")
95
199
  end
96
200
 
201
+ def test_from_hsl
202
+ assert_instance_of(Magick::Pixel, Magick::Pixel.from_HSL([127, 50, 50]))
203
+ assert_raise(ArgumentError) { Magick::Pixel.from_HSL([127, 50]) }
204
+ end
205
+
206
+ def test_intensity
207
+ assert_kind_of(Integer, @pixel.intensity)
208
+ end
209
+
210
+ def test_marshal
211
+ marshal = @pixel.marshal_dump
212
+
213
+ pixel = Magick::Pixel.new
214
+ assert_equal(@pixel, pixel.marshal_load(marshal))
215
+ end
216
+
217
+ def test_spaceship
218
+ @pixel.red = 100
219
+ pixel = @pixel.dup
220
+ assert_equal(0, @pixel <=> pixel)
221
+
222
+ pixel.red -= 10
223
+ assert_equal(1, @pixel <=> pixel)
224
+ pixel.red += 20
225
+ assert_equal(-1, @pixel <=> pixel)
226
+
227
+ @pixel.green = 100
228
+ pixel = @pixel.dup
229
+ pixel.green -= 10
230
+ assert_equal(1, @pixel <=> pixel)
231
+ pixel.green += 20
232
+ assert_equal(-1, @pixel <=> pixel)
233
+
234
+ @pixel.blue = 100
235
+ pixel = @pixel.dup
236
+ pixel.blue -= 10
237
+ assert_equal(1, @pixel <=> pixel)
238
+ pixel.blue += 20
239
+ assert_equal(-1, @pixel <=> pixel)
240
+
241
+ @pixel.opacity = 100
242
+ pixel = @pixel.dup
243
+ pixel.opacity -= 10
244
+ assert_equal(1, @pixel <=> pixel)
245
+ pixel.opacity += 20
246
+ assert_equal(-1, @pixel <=> pixel)
247
+
248
+ @pixel.alpha = 100
249
+ pixel = @pixel.dup
250
+ pixel.alpha -= 10
251
+ assert_equal(-1, @pixel <=> pixel)
252
+ pixel.alpha += 20
253
+ assert_equal(1, @pixel <=> pixel)
254
+ end
255
+
256
+ def test_to_hsl
257
+ hsl = @pixel.to_HSL
258
+ assert_instance_of(Array, hsl)
259
+ assert_equal(3, hsl.size)
260
+ end
261
+
97
262
  def test_to_color
98
263
  assert_nothing_raised { @pixel.to_color(Magick::AllCompliance) }
99
264
  assert_nothing_raised { @pixel.to_color(Magick::SVGCompliance) }
@@ -113,4 +278,8 @@ class PixelUT < Test::Unit::TestCase
113
278
  assert_raise(ArgumentError) { @pixel.to_color(Magick::AllCompliance, false, 32) }
114
279
  assert_raise(TypeError) { @pixel.to_color(1) }
115
280
  end
281
+
282
+ def test_to_s
283
+ assert_match(/red=\d+, green=\d+, blue=\d+, opacity=\d+/, @pixel.to_s)
284
+ end
116
285
  end
@@ -1,6 +1,6 @@
1
1
  require 'rmagick'
2
2
  require 'test/unit'
3
- require 'test/unit/ui/console/testrunner' unless RUBY_VERSION[/^1\.9|^2/]
3
+ require 'test/unit/ui/console/testrunner'
4
4
 
5
5
  class PolaroidOptionsUT < Test::Unit::TestCase
6
6
  def setup
@@ -2,49 +2,17 @@
2
2
 
3
3
  require 'rmagick'
4
4
  require 'test/unit'
5
- require 'test/unit/ui/console/testrunner' unless RUBY_VERSION[/^1\.9|^2/]
5
+ require 'test/unit/ui/console/testrunner'
6
6
 
7
7
  class PreviewUT < Test::Unit::TestCase
8
8
  def test_preview
9
- preview_types = [
10
- Magick::RotatePreview,
11
- Magick::ShearPreview,
12
- Magick::RollPreview,
13
- Magick::HuePreview,
14
- Magick::SaturationPreview,
15
- Magick::BrightnessPreview,
16
- Magick::GammaPreview,
17
- Magick::SpiffPreview,
18
- Magick::DullPreview,
19
- Magick::GrayscalePreview,
20
- Magick::QuantizePreview,
21
- Magick::DespecklePreview,
22
- Magick::ReduceNoisePreview,
23
- Magick::AddNoisePreview,
24
- Magick::SharpenPreview,
25
- Magick::BlurPreview,
26
- Magick::ThresholdPreview,
27
- Magick::EdgeDetectPreview,
28
- Magick::SpreadPreview,
29
- Magick::SolarizePreview,
30
- Magick::ShadePreview,
31
- Magick::RaisePreview,
32
- Magick::SegmentPreview,
33
- Magick::SwirlPreview,
34
- Magick::ImplodePreview,
35
- Magick::WavePreview,
36
- Magick::OilPaintPreview,
37
- Magick::CharcoalDrawingPreview,
38
- Magick::JPEGPreview
39
- ]
40
-
41
9
  hat = Magick::Image.read(IMAGES_DIR + '/Flower_Hat.jpg').first
42
10
  assert_nothing_raised do
43
11
  prev = hat.preview(Magick::RotatePreview)
44
12
  assert_instance_of(Magick::Image, prev)
45
13
  end
46
14
  puts "\n"
47
- preview_types.each do |type|
15
+ Magick::PreviewType.values do |type|
48
16
  puts "testing #{type}..."
49
17
  assert_nothing_raised { hat.preview(type) }
50
18
  end
@@ -54,5 +22,5 @@ end
54
22
 
55
23
  if $PROGRAM_NAME == __FILE__
56
24
  IMAGES_DIR = '../doc/ex/images'
57
- Test::Unit::UI::Console::TestRunner.run(PreviewUT) unless RUBY_VERSION[/^1\.9|^2/]
25
+ Test::Unit::UI::Console::TestRunner.run(PreviewUT)
58
26
  end
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby -w
2
+
3
+ require 'rmagick'
4
+ require 'test/unit'
5
+ require 'test/unit/ui/console/testrunner'
6
+
7
+ class StructUT < Test::Unit::TestCase
8
+ def test_chromaticity_to_s
9
+ image = Magick::Image.new(10, 10)
10
+ assert_match(/red_primary=\(x=.+,y=.+\) green_primary=\(x=.+,y=.+\) blue_primary=\(x=.+,y=.+\) white_point=\(x=.+,y=.+\)/, image.chromaticity.to_s)
11
+ end
12
+
13
+ def test_export_color_info
14
+ color = Magick.colors[0]
15
+ assert_instance_of(Magick::Color, color)
16
+ assert_match(/name=.+, compliance=.+, color.red=.+, color.green=.+, color.blue=.+, color.opacity=.+/, color.to_s)
17
+ end
18
+
19
+ def test_export_type_info
20
+ font = Magick.fonts[0]
21
+ assert_match(/^name=.+, description=.+, family=.+, style=.+, stretch=.+, weight=.+, encoding=.*, foundry=.*, format=.*$/, font.to_s)
22
+ end
23
+
24
+ def test_export_point_info
25
+ draw = Magick::Draw.new
26
+ metric = draw.get_type_metrics('ABCDEF')
27
+ assert_match(/^pixels_per_em=\(x=.+,y=.+\) ascent=.+ descent=.+ width=.+ height=.+ max_advance=.+ bounds.x1=.+ bounds.y1=.+ bounds.x2=.+ bounds.y2=.+ underline_position=.+ underline_thickness=.+$/, metric.to_s)
28
+ end
29
+
30
+ def test_primary_info_to_s
31
+ chrom = Magick::Image.new(10, 10).chromaticity
32
+ red_primary = chrom.red_primary
33
+ assert_match(/^x=.+, y=.+, z=.+$/, red_primary.to_s)
34
+ end
35
+
36
+ def test_rectangle_info_to_s
37
+ rect = Magick::Rectangle.new(10, 20, 30, 40)
38
+ assert_equal('width=10, height=20, x=30, y=40', rect.to_s)
39
+ end
40
+
41
+ def test_segment_info_to_s
42
+ segment = Magick::Segment.new(10, 20, 30, 40)
43
+ assert_equal('x1=10, y1=20, x2=30, y2=40', segment.to_s)
44
+ end
45
+ end